X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmkws-widget-main.js;h=f5fb1f731bb02925bc66960bab54c74bed88033c;hb=a4989aded76c2239a89abe0472ead2fc308b8206;hp=161f61fe7355fbed9dc16c4691b413d8881a42c7;hpb=16708a6aebe10acd3b72bcb20b03c54d1195a1b9;p=mkws-moved-to-github.git
diff --git a/src/mkws-widget-main.js b/src/mkws-widget-main.js
index 161f61f..f5fb1f7 100644
--- a/src/mkws-widget-main.js
+++ b/src/mkws-widget-main.js
@@ -116,31 +116,29 @@ 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));
});
- widget.autosearch(that);
+ that.autosearch();
});
@@ -216,7 +214,7 @@ mkws.registerWidgetType('Switch', function() {
Records \
| \
Targets');
- widget.hideWhenNarrow(this);
+ this.hideWhenNarrow();
});
@@ -265,7 +263,7 @@ mkws.registerWidgetType('Results', function() {
\
');
- widget.autosearch(this);
+ this.autosearch();
});
@@ -372,7 +370,7 @@ mkws.registerWidgetType('Lang', function() {
}
this.node.html(data);
- widget.hideWhenNarrow(this);
+ this.hideWhenNarrow();
// set or re-set "lang" URL parameter
@@ -405,6 +403,41 @@ mkws.registerWidgetType('MOTD', function() {
});
+// This widget has no functionality of its own, but its configuration
+// is copied up into its team, allowing it to affect other widgets in
+// the team.
+//
+mkws.registerWidgetType('Config', function() {
+ var c = this.config;
+ for (var name in c) {
+ if (c.hasOwnProperty(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 = '';
+ for (var i = 0; i < data.clients; i++) {
+ if (i == data.clients - data.activeclients) {
+ s += '';
+ s += '';
+ }
+ s += '█';
+ }
+ s += '';
+ 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