- var facetConfig = {
- xtargets: [ "Sources", 16, false ],
- subject: [ "Subjects", 10, true ],
- author: [ "Authors", 10, true ]
- }
-
- this.team.queue("termlists").subscribe(function(data) {
- // no facets: this should never happen
- var facets = that.config.facets;
- if (!facets || facets.length == 0) {
- alert("onTerm called even though we have no facets: " + $.toJSON(data));
- $(that.node).hide();
- return;
- }
-
- // display if we first got results
- $(that.node).show();
-
- var output = {};
- var acc = [];
- acc.push('<div class="title">' + M('Termlists') + '</div>');
-
- for (var i = 0; i < facets.length; i++) {
- var name = facets[i]
- var ref = facetConfig[name];
- if (!ref) {
- alert("bad facet configuration: '" + name + "'");
- } else {
- addSingleScaffold(acc, ref[0]);
- output[name] = makeSingleFacet(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 addSingleScaffold(acc, caption) {
- var teamName = that.team.name();
- acc.push('<div class="mkwsFacet mkwsFacet' + caption + ' mkwsTeam_' + teamName + '">');
- acc.push('</div>');
- }