- var facetConfig = {
- xtargets: [ "Sources", 16, false ],
- subject: [ "Subjects", 10, true ],
- author: [ "Author", 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 {
- 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];
+ var template = team.loadTemplate(this.config.template || "Termlists");
+ this.node.html(template({
+ team: team.name(),
+ facets: this.config.facets
+ }));
+ this.autosearch();
+});