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 ='<table><thead><tr>' +
- '<td>' + M('Target ID') + '</td>' +
- '<td>' + M('Hits') + '</td>' +
- '<td>' + M('Diags') + '</td>' +
- '<td>' + M('Records') + '</td>' +
- '<td>' + M('State') + '</td>' +
- '</tr></thead><tbody>';
-
+ // There is a bug in pz2.js
+ var cleandata = [];
for (var i = 0; i < data.length; i++) {
- table += "<tr><td>" + data[i].id +
- "</td><td>" + data[i].hits +
- "</td><td>" + data[i].diagnostic +
- "</td><td>" + data[i].records +
- "</td><td>" + data[i].state + "</td></tr>";
+ 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 += '</tbody></table>';
- that.node.html(table);
+ var template = that.team.loadTemplate(that.config.template || "Targets");
+ that.node.html(template({data: cleandata}));
});
});
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('<div class="mkwsSummary mkwsTeam_' + team.name() + ' ' + divId + '">', renderSummary(hit), '</div>');
+ 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));
});
- widget.autosearch(that);
+ that.autosearch();
});
<a href="#" onclick="mkws.switchView(\'' + tname + '\', \'records\')">Records</a><span> \
| \
</span><a href="#" onclick="mkws.switchView(\'' + tname + '\', \'targets\')">Targets</a>');
- widget.hideWhenNarrow(this);
+ this.hideWhenNarrow();
});
</tr>\
</table>');
- widget.autosearch(this);
+ this.autosearch();
});
}
this.node.html(data);
- widget.hideWhenNarrow(this);
+ this.hideWhenNarrow();
// set or re-set "lang" URL parameter
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");
}
}
});
+mkws.registerWidgetType('Progress', function() {
+ var that = this;
+
+ this.node.hide();
+ this.team.queue("stat").subscribe(function(data) {
+ var s = '<span class="mkwsDone">';
+ for (var i = 0; i < data.clients; i++) {
+ if (i == data.clients - data.activeclients) {
+ s += '</span>';
+ s += '<span class="mkwsWaiting">';
+ }
+ s += '█';
+ }
+ s += '</span>';
+ that.node.html(s);
+ that.node.show();
+ });
+});
+
+
// Some elements have mkws* classes that makes them appear as widgets
// -- for example, because we want to style them using CSS -- but have
// no actual functionality. We register these to prevent ignorable
mkws.registerWidgetType('Query', function() {});
mkws.registerWidgetType('MOTDContainer', function() {});
mkws.registerWidgetType('Button', function() {});
-mkws.registerWidgetType('Popup', function() {});