From: Mike Taylor Date: Tue, 10 Jun 2014 12:37:17 +0000 (+0100) Subject: Radically simplify and generalise generation of facet HTML. X-Git-Tag: 1.0.0~503 X-Git-Url: http://git.indexdata.com/?p=mkws-moved-to-github.git;a=commitdiff_plain;h=139d7f620e0fb02a7cb1136d3d9e7250bf4a30a5 Radically simplify and generalise generation of facet HTML. Preparation for moving the (much simpler) HTML-generation into a template. --- diff --git a/src/mkws-widget-termlists.js b/src/mkws-widget-termlists.js index c0dd474..715eff2 100644 --- a/src/mkws-widget-termlists.js +++ b/src/mkws-widget-termlists.js @@ -41,27 +41,30 @@ mkws.registerWidgetType('Facet', function() { that.team.queue("termlists").subscribe(function(data) { data = data[name]; - - var teamName = that.team.name(); - var acc = []; var template = that.team.loadTemplate('facetTitle-' + caption, mkws.M(caption)) var title = template({ query: that.config.query }); - acc.push('
' + title + '
'); + var acc = []; + acc.push('
', title, '
'); + + var teamName = that.team.name(); for (var i = 0; i < data.length && i < max; i++) { - acc.push('
'); - acc.push('' + data[i].name + '' - + ' ' + data[i].freq + ''); - acc.push('
'); + + var action = ''; + if (fn) { + action = 'mkws.' + fn + '(\'' + teamName + '\', \'' + datum + '\', this.firstChild.nodeValue)'; + } + + acc.push('
', + '', data[i].name, '', + '', data[i].freq, '', + '
'); } that.node.html(acc.join(''));