From: Mike Taylor Date: Fri, 4 Apr 2014 15:31:48 +0000 (+0100) Subject: Merge the two consecutive facet-generation loops into one. X-Git-Tag: 1.0.0~1023 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=438d9003c3d82eb7695d5adf12c6b3f380f1e46a;p=mkws-moved-to-github.git Merge the two consecutive facet-generation loops into one. Throw away the accumulating-state hash. --- diff --git a/src/mkws-widget-termlists.js b/src/mkws-widget-termlists.js index 5986a57..d3dc149 100644 --- a/src/mkws-widget-termlists.js +++ b/src/mkws-widget-termlists.js @@ -20,6 +20,7 @@ mkws.registerWidgetType('Termlists', function() { // display if we first got results $(that.node).show(); + var acc = []; acc.push('
' + M('Termlists') + '
'); 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();