Merge the two consecutive facet-generation loops into one.
authorMike Taylor <mike@indexdata.com>
Fri, 4 Apr 2014 15:31:48 +0000 (16:31 +0100)
committerMike Taylor <mike@indexdata.com>
Fri, 4 Apr 2014 15:31:48 +0000 (16:31 +0100)
Throw away the accumulating-state hash.

src/mkws-widget-termlists.js

index 5986a57..d3dc149 100644 (file)
@@ -20,6 +20,7 @@ mkws.registerWidgetType('Termlists', function() {
        // display if we first got results
        $(that.node).show();
 
+
        var acc = [];
        acc.push('<div class="title">' + M('Termlists') + '</div>');
        for (var i = 0; i < facets.length; i++) {
@@ -35,26 +36,19 @@ mkws.registerWidgetType('Termlists', function() {
        $(that.node).html(acc.join(''));
 
 
-       var output = {};
        for (var i = 0; i < facets.length; i++) {
            var name = facets[i]
            var ref = facetConfig[name];
+           var caption = ref[0];
            if (!ref) {
                alert("bad facet configuration: '" + name + "'");
            } else {
-               output[name] = makeSingleFacet(ref[0], data[name], ref[1], ref[2] ? name : null);
+               var output = makeSingleFacet(ref[0], data[name], ref[1], ref[2] ? name : null);
+               that.log("setting HTML for facet '" + name + "'");
+               that.team.findnode('.mkwsFacet' + caption).html(output);
            }
        }
 
-       for (var i = 0; i < facets.length; i++) {
-           var name = facets[i]
-           var ref = facetConfig[name];
-           var caption = ref[0];
-
-           that.log("setting HTML for facet '" + name + "'");
-           that.team.findnode('.mkwsFacet' + caption).html(output[name]);
-       }
-
 
        function makeSingleFacet(caption, data, max, pzIndex) {
            var teamName = that.team.name();