X-Git-Url: http://git.indexdata.com/?p=mkws-moved-to-github.git;a=blobdiff_plain;f=tools%2Fhtdocs%2Fmkws.js;h=fb72ddb02df2acac3774dbadfa492013fb97b3fb;hp=e1bcd0631839c43caab9a8b5bf1d54448aa59c34;hb=93fbae933da149a1aeaf84db02fa5f08966bacaf;hpb=efb560394dd731154a378cfa4c64cb89f67a9a38
diff --git a/tools/htdocs/mkws.js b/tools/htdocs/mkws.js
index e1bcd06..fb72ddb 100644
--- a/tools/htdocs/mkws.js
+++ b/tools/htdocs/mkws.js
@@ -162,6 +162,8 @@ function widget($, team, type, node) {
promoteTargets();
} else if (type === 'Stat') {
promoteStat();
+ } else if (type === 'Termlists') {
+ promoteTermlists();
} else {
// ### Handle other types here
}
@@ -212,6 +214,68 @@ function widget($, team, type, node) {
'' + M('Retrieved records') + ': ' + data.records + '/' + data.hits + '');
});
}
+
+
+ function promoteTermlists() {
+ team.queue("termlists").subscribe(function(data) {
+ mkws.debug("in termlist consumer");
+ if (!node) {
+ alert("termlists event when there are no termlists");
+ return;
+ }
+
+ // no facets: this should never happen
+ if (!mkws_config.facets || mkws_config.facets.length == 0) {
+ alert("onTerm called even though we have no facets: " + $.toJSON(data));
+ $(node).hide();
+ return;
+ }
+
+ // display if we first got results
+ $(node).show();
+
+ var acc = [];
+ acc.push('
' + M('Termlists') + '
');
+ var facets = mkws_config.facets;
+
+ for (var i = 0; i < facets.length; i++) {
+ if (facets[i] == "xtargets") {
+ addSingleFacet(acc, "Sources", data.xtargets, 16, null);
+ } else if (facets[i] == "subject") {
+ addSingleFacet(acc, "Subjects", data.subject, 10, "subject");
+ } else if (facets[i] == "author") {
+ addSingleFacet(acc, "Authors", data.author, 10, "author");
+ } else {
+ alert("bad facet configuration: '" + facets[i] + "'");
+ }
+ }
+
+ $(node).html(acc.join(''));
+
+ function addSingleFacet(acc, caption, data, max, pzIndex) {
+ acc.push('');
+ acc.push('
' + M(caption) + '
');
+ for (var i = 0; i < data.length && i < max; i++) {
+ acc.push('
');
+ }
+ acc.push('
');
+ }
+ });
+ }
}
@@ -300,36 +364,7 @@ function team($, teamName) {
function onTerm(data) {
debug("term");
- var node = findnode(".mkwsTermlists");
- if (node.length == 0) return;
-
- // no facets: this should never happen
- if (!mkws_config.facets || mkws_config.facets.length == 0) {
- alert("onTerm called even though we have no facets: " + $.toJSON(data));
- node.hide();
- return;
- }
-
- // display if we first got results
- node.show();
-
- var acc = [];
- acc.push('' + M('Termlists') + '
');
- var facets = mkws_config.facets;
-
- for(var i = 0; i < facets.length; i++) {
- if (facets[i] == "xtargets") {
- addSingleFacet(acc, "Sources", data.xtargets, 16, null);
- } else if (facets[i] == "subject") {
- addSingleFacet(acc, "Subjects", data.subject, 10, "subject");
- } else if (facets[i] == "author") {
- addSingleFacet(acc, "Authors", data.author, 10, "author");
- } else {
- alert("bad facet configuration: '" + facets[i] + "'");
- }
- }
-
- node.html(acc.join(''));
+ queue("termlists").publish(data);
}
@@ -376,31 +411,7 @@ function team($, teamName) {
}
- function addSingleFacet(acc, caption, data, max, pzIndex) {
- acc.push('');
- acc.push('
' + M(caption) + '
');
- for (var i = 0; i < data.length && i < max; i++) {
- acc.push('
');
- }
- acc.push('
');
- }
-
-
- function targetFiltered(id) {
+ that.targetFiltered = function(id) {
for (var i = 0; i < m_filters.length; i++) {
if (m_filters[i].id === id ||
m_filters[i].id === 'pz:id=' + id) {
@@ -1464,7 +1475,7 @@ function team($, teamName) {
}
});
- // Find all nodes with an class, and determine their team from
+ // Find all nodes with an MKWS class, and determine their team from
// the mkwsTeam_* class. Make all team objects.
var then = $.now();
$('[class^="mkws"],[class*=" mkws"]').each(function () {