1 mkws.registerWidgetType('Termlists', function() {
6 xtargets: [ "Sources", 16, false ],
7 subject: [ "Subjects", 10, true ],
8 author: [ "Author", 10, true ]
11 this.team.queue("termlists").subscribe(function(data) {
12 // no facets: this should never happen
13 var facets = that.config.facets;
14 if (!facets || facets.length == 0) {
15 alert("onTerm called even though we have no facets: " + $.toJSON(data));
20 // display if we first got results
25 acc.push('<div class="title">' + M('Termlists') + '</div>');
27 for (var i = 0; i < facets.length; i++) {
29 var ref = facetConfig[name];
31 alert("bad facet configuration: '" + name + "'");
33 output[name] = addSingleFacet(acc, ref[0], data[name], ref[1], ref[2] ? name : null);
37 $(that.node).html(acc.join(''));
39 for (var i = 0; i < facets.length; i++) {
41 var ref = facetConfig[name];
44 that.log("setting HTML for facet '" + name + "'");
45 that.team.findnode('.mkwsFacet' + caption).html(output[name]);
48 function addSingleFacet(acc, caption, data, max, pzIndex) {
49 var teamName = that.team.name();
50 acc.push('<div class="mkwsFacet mkwsFacet' + caption + ' mkwsTeam_' + teamName + '">');
53 a2.push('<div class="termtitle">' + M(caption) + '</div>');
54 for (var i = 0; i < data.length && i < max; i++) {
55 a2.push('<div class="term">');
56 a2.push('<a href="#" ');
59 // Special case: target selection
60 a2.push('target_id='+data[i].id+' ');
61 if (!that.team.targetFiltered(data[i].id)) {
62 action = 'mkws.limitTarget(\'' + teamName + '\', this.getAttribute(\'target_id\'),this.firstChild.nodeValue)';
65 action = 'mkws.limitQuery(\'' + teamName + '\', \'' + pzIndex + '\', this.firstChild.nodeValue)';
67 a2.push('onclick="' + action + ';return false;">' + data[i].name + '</a>'
68 + ' <span>' + data[i].freq + '</span>');
76 widget.autosearch(that);