X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmkws-widget-main.js;h=91c2d9311ca8e48a0ac75087e895ed8087bddab6;hb=9d552877ef9bfbb92887942b9ac1870ddd12ba58;hp=5951c1c140c802f98a2c9d64e2969baf182ae93a;hpb=c302068454a4f0a77574eae189b582a01138e763;p=mkws-moved-to-github.git diff --git a/src/mkws-widget-main.js b/src/mkws-widget-main.js index 5951c1c..91c2d93 100644 --- a/src/mkws-widget-main.js +++ b/src/mkws-widget-main.js @@ -6,43 +6,34 @@ mkws.registerWidgetType('Targets', function() { if (!this.config.show_switch) return; var that = this; - var M = mkws.M; this.node.html('No information available yet.'); this.node.css("display", "none"); this.team.queue("targets").subscribe(function(data) { - var table ='' + - '' + - '' + - '' + - '' + - '' + - ''; - + // There is a bug in pz2.js + var cleandata = []; for (var i = 0; i < data.length; i++) { - table += ""; + var cur = {}; + cur.id = data[i].id; + cur.hits = data[i].hits; + cur.diagnostic = data[i].diagnostic; + cur.records = data[i].records; + cur.state = data[i].state; + cleandata.push(cur); } - table += '
' + M('Target ID') + '' + M('Hits') + '' + M('Diags') + '' + M('Records') + '' + M('State') + '
" + data[i].id + - "" + data[i].hits + - "" + data[i].diagnostic + - "" + data[i].records + - "" + data[i].state + "
'; - that.node.html(table); + var template = that.team.loadTemplate(that.config.template || "Targets"); + that.node.html(template({data: cleandata})); }); }); mkws.registerWidgetType('Stat', function() { var that = this; - var M = mkws.M; - this.team.queue("stat").subscribe(function(data) { - that.node.html(' -- ' + - '' + M('Active clients') + ': ' + data.activeclients + '/' + data.clients + '' + - ' -- ' + - M('Retrieved records') + ': ' + data.records + '/' + data.hits); + var template = that.team.loadTemplate(that.config.template || "Stat"); + that.node.html(template(data)); }); }); @@ -116,28 +107,26 @@ mkws.registerWidgetType('Records', function() { var team = this.team; this.team.queue("records").subscribe(function(data) { - var html = []; for (var i = 0; i < data.hits.length; i++) { var hit = data.hits[i]; that.team.queue("record").publish(hit); - var divId = team.recordElementId(hit.recid[0]); - html.push('
', renderSummary(hit), '
'); + hit.detailLinkId = team.recordElementId(hit.recid[0]); + hit.detailClick = "mkws.showDetails('" + team.name() + "', '" + hit.recid[0] + "');return false;" + hit.containerClass = "mkwsSummary mkwsTeam_" + team.name(); + hit.containerClass += " " + hit.detailLinkId; // ### At some point, we may be able to move the // m_currentRecordId and m_currentRecordData members // from the team object into this widget. if (hit.recid == team.currentRecordId()) { - if (team.currentRecordData()) - html.push(team.renderDetails(team.currentRecordData())); + if (team.currentRecordData()) { + hit.renderedDetails = team.renderDetails(team.currentRecordData()); + console.log(hit.renderedDetails); + } } } - that.node.html(html.join('')); - - function renderSummary(hit) { - var template = team.loadTemplate(that.config.template || "Summary"); - hit._id = team.recordElementId(hit.recid[0]); - hit._onclick = "mkws.showDetails('" + team.name() + "', '" + hit.recid[0] + "');return false;" - return template(hit); - } + var template = team.loadTemplate(that.config.template || "Records"); + var targs = $.extend({}, {"hits": data.hits}, that.config.template_vars); + that.node.html(template(targs)); }); that.autosearch(); @@ -216,7 +205,7 @@ mkws.registerWidgetType('Switch', function() { Records \ | \ Targets'); - widget.hideWhenNarrow(this); + this.hideWhenNarrow(); }); @@ -372,7 +361,7 @@ mkws.registerWidgetType('Lang', function() { } this.node.html(data); - widget.hideWhenNarrow(this); + this.hideWhenNarrow(); // set or re-set "lang" URL parameter @@ -413,7 +402,7 @@ mkws.registerWidgetType('Config', function() { var c = this.config; for (var name in c) { if (c.hasOwnProperty(name)) { - this.team.config()[name] = c[name]; + this.team.config[name] = c[name]; this.log(this + " copied property " + name + "='" + c[name] + "' up to team"); } } @@ -431,7 +420,7 @@ mkws.registerWidgetType('Progress', function() { s += ''; s += ''; } - s += '█'; + s += '█'; } s += ''; that.node.html(s); @@ -448,6 +437,5 @@ mkws.registerWidgetType('Progress', function() { mkws.registerWidgetType('Query', function() {}); mkws.registerWidgetType('MOTDContainer', function() {}); mkws.registerWidgetType('Button', function() {}); -mkws.registerWidgetType('Popup', function() {});