1 mkws.registerWidgetType('Termlists', function() {
3 var facets = that.config.facets;
6 this.team.queue("termlists").subscribe(function(data) {
7 // display if we first got results
11 for (var i = 0; i < facets.length; i++) {
13 var ref = mkws.facetConfig[name];
15 alert("bad facet configuration: '" + name + "'");
17 (function(ref, name) {
19 that.team.queue("termlists").subscribe(function(data) {
20 makeSingleFacet(caption, data[name], ref[1], ref[2] ? name : null);
26 function makeSingleFacet(caption, data, max, pzIndex) {
27 that.log("in makeSingleFacet(" + caption + ")");
28 var teamName = that.team.name();
31 acc.push('<div class="termtitle">' + M(caption) + '</div>');
32 for (var i = 0; i < data.length && i < max; i++) {
33 acc.push('<div class="term">');
34 acc.push('<a href="#" ');
37 // Special case: target selection
38 acc.push('target_id='+data[i].id+' ');
39 if (!that.team.targetFiltered(data[i].id)) {
40 action = 'mkws.limitTarget(\'' + teamName + '\', this.getAttribute(\'target_id\'),this.firstChild.nodeValue)';
43 action = 'mkws.limitQuery(\'' + teamName + '\', \'' + pzIndex + '\', this.firstChild.nodeValue)';
45 acc.push('onclick="' + action + ';return false;">' + data[i].name + '</a>'
46 + ' <span>' + data[i].freq + '</span>');
49 that.team.findnode('.mkwsFacet' + caption).html(acc.join(''));
52 widget.autosearch(that);