From 7e9bf49237333c81ce6946ee735ba454dd0198b3 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Fri, 4 Apr 2014 16:12:07 +0100 Subject: [PATCH] We now use a silly half-and-half scheme where an accumulator fills up the scaffolding HTML while we also gather separately the HTML of each individual facet. Working towards facet separation. --- src/mkws-widget-termlists.js | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/mkws-widget-termlists.js b/src/mkws-widget-termlists.js index 6175100..eb299f0 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 output = {}; var acc = []; acc.push('
' + M('Termlists') + '
'); @@ -29,34 +30,46 @@ mkws.registerWidgetType('Termlists', function() { if (!ref) { alert("bad facet configuration: '" + name + "'"); } else { - addSingleFacet(acc, ref[0], data[name], ref[1], ref[2] ? name : null); + output[name] = addSingleFacet(acc, ref[0], data[name], ref[1], ref[2] ? name : null); } } $(that.node).html(acc.join('')); + 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 addSingleFacet(acc, caption, data, max, pzIndex) { var teamName = that.team.name(); acc.push('
'); - acc.push('
' + M(caption) + '
'); + + var a2 = []; + a2.push('
' + M(caption) + '
'); for (var i = 0; i < data.length && i < max; i++) { - acc.push('
'); - acc.push(''); + a2.push('' + data[i].name + '' + a2.push('onclick="' + action + ';return false;">' + data[i].name + '' + ' ' + data[i].freq + ''); - acc.push('
'); + a2.push('
'); } acc.push(''); + return a2.join(''); } }); -- 1.7.10.4