X-Git-Url: http://sru.miketaylor.org.uk/?a=blobdiff_plain;f=src%2Fmkws-widget-main.js;h=91c2d9311ca8e48a0ac75087e895ed8087bddab6;hb=9d552877ef9bfbb92887942b9ac1870ddd12ba58;hp=fcffe5bbacb51b06fdfa2ed80b881eb9891f8822;hpb=a3507a2e136008e3e2e0ae407ce52cf2657fce6e;p=mkws-moved-to-github.git
diff --git a/src/mkws-widget-main.js b/src/mkws-widget-main.js
index fcffe5b..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 ='
' +
- '' + M('Target ID') + ' | ' +
- '' + M('Hits') + ' | ' +
- '' + M('Diags') + ' | ' +
- '' + M('Records') + ' | ' +
- '' + M('State') + ' | ' +
- '
';
-
+ // There is a bug in pz2.js
+ var cleandata = [];
for (var i = 0; i < data.length; i++) {
- table += "" + data[i].id +
- " | " + data[i].hits +
- " | " + data[i].diagnostic +
- " | " + data[i].records +
- " | " + data[i].state + " |
";
+ 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 += '
';
- 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();