';
-
- for (var i = 0; i < data.length; i++) {
- table += "
" + data[i].id +
- "
" + data[i].hits +
- "
" + data[i].diagnostic +
- "
" + data[i].records +
- "
" + data[i].state + "
";
- }
-
- table += '
';
- var subnode = $(that.node).children('.mkwsBytarget');
- subnode.html(table);
- });
+ 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') + '
' +
+ '
';
+
+ for (var i = 0; i < data.length; i++) {
+ table += "
';
-
- return s;
- }
- });
+ var that = this;
+ var M = mkws.M;
+
+ this.team.queue("pager").subscribe(function(data) {
+ that.node.html(drawPager(data))
+
+ function drawPager(data) {
+ var teamName = that.team.name();
+ var s = '
';
+
+ return s;
+ }
+ });
});
mkws.registerWidgetType('Records', function() {
- var that = this;
- 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), '
');
- // ### 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()));
- }
- }
- $(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 that = this;
+ 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), '
');
+ // ### 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()));
+ }
+ }
+ that.node.html(html.join(''));
- widget.autosearch(that);
+ 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);
+ }
+ });
+
+ that.autosearch();
});
mkws.registerWidgetType('Navi', function() {
- var that = this;
- var teamName = this.team.name();
- var M = mkws.M;
-
- this.team.queue("navi").subscribe(function() {
- var filters = that.team.filters();
- var text = "";
-
- filters.visitTargets(function(id, name) {
- if (text) text += " | ";
- text += M('source') + ': ' + name + '';
- });
-
- filters.visitFields(function(field, value) {
- if (text) text += " | ";
- text += M(field) + ': ' + value + '';
- });
-
- $(that.node).html(text);
+ var that = this;
+ var teamName = this.team.name();
+ var M = mkws.M;
+
+ this.team.queue("navi").subscribe(function() {
+ var filters = that.team.filters();
+ var text = "";
+
+ filters.visitTargets(function(id, name) {
+ if (text) text += " | ";
+ text += M('source') + ': ' + name + '';
+ });
+
+ filters.visitFields(function(field, value) {
+ if (text) text += " | ";
+ text += M(field) + ': ' + value + '';
});
+
+ that.node.html(text);
+ });
});
@@ -181,55 +175,56 @@ mkws.registerWidgetType('Navi', function() {
// anything, since they produce events rather than consuming them.
//
mkws.registerWidgetType('Sort', function() {
- var that = this;
-
- $(this.node).change(function() {
- that.team.set_sortOrder($(that.node).val());
- if (that.team.submitted()) {
- that.team.reShow();
- }
- return false;
- });
+ var that = this;
+
+ this.node.change(function() {
+ that.team.set_sortOrder(that.node.val());
+ if (that.team.submitted()) {
+ that.team.reShow();
+ }
+ return false;
+ });
});
mkws.registerWidgetType('Perpage', function() {
- var that = this;
-
- $(this.node).change(function() {
- that.team.set_perpage($(that.node).val());
- if (that.team.submitted()) {
- that.team.reShow();
- }
- return false;
- });
+ var that = this;
+
+ this.node.change(function() {
+ that.team.set_perpage(that.node.val());
+ if (that.team.submitted()) {
+ that.team.reShow();
+ }
+ return false;
+ });
});
mkws.registerWidgetType('Done', function() {
- var that = this;
+ var that = this;
- this.team.queue("complete").subscribe(function(n) {
- $(that.node).html("Search complete: found " + n + " records");
- });
+ this.team.queue("complete").subscribe(function(n) {
+ that.node.html("Search complete: found " + n + " records");
+ });
});
mkws.registerWidgetType('Switch', function() {
- var tname = this.team.name();
- $(this.node).html('\
+ if (!this.config.show_switch) return;
+ var tname = this.team.name();
+ this.node.html('\
Records \
| \
Targets');
- widget.hideWhenNarrow(this);
+ this.hideWhenNarrow();
});
mkws.registerWidgetType('Search', function() {
- var tname = this.team.name();
- var M = mkws.M;
+ var tname = this.team.name();
+ var M = mkws.M;
- $(this.node).html('\
+ this.node.html('\
';
+
+ this.node.html(s);
+
+
+ function mkwsHtmlSort() {
+ var order = that.team.sortOrder();
+
+ that.log("making sort HTML, sortOrder = '" + order + "'");
+ var sort_html = '';
- function mkwsHtmlSort() {
- var order = that.team.sortOrder();
+ return sort_html;
+ }
- that.log("HTML sort, sortOrder = '" + order + "'");
- var sort_html = '';
- function mkwsHtmlPerpage() {
- var perpage = that.team.perpage();
-
- that.log("HTML perpage, perpage = " + perpage);
- var perpage_html = '';
-
- for(var i = 0; i < that.config.perpage_options.length; i++) {
- var key = that.config.perpage_options[i];
-
- perpage_html += '';
- }
- perpage_html += '';
-
- return perpage_html;
- }
+ return perpage_html;
+ }
});
mkws.registerWidgetType('Lang', function() {
- // dynamic URL or static page? /path/foo?query=test
- /* create locale language menu */
- if (!this.config.show_lang) return;
-
- var lang_default = "en";
- var lang = this.config.lang || lang_default;
- var list = [];
-
- /* display a list of configured languages, or all */
- var lang_options = this.config.lang_options || [];
- var toBeIncluded = {};
- for (var i = 0; i < lang_options.length; i++) {
- toBeIncluded[lang_options[i]] = true;
+ // dynamic URL or static page? /path/foo?query=test
+ /* create locale language menu */
+ if (!this.config.show_lang) return;
+
+ var lang_default = "en";
+ var lang = this.config.lang || lang_default;
+ var list = [];
+
+ /* display a list of configured languages, or all */
+ var lang_options = this.config.lang_options || [];
+ var toBeIncluded = {};
+ for (var i = 0; i < lang_options.length; i++) {
+ toBeIncluded[lang_options[i]] = true;
+ }
+
+ for (var k in mkws.locale_lang) {
+ if (toBeIncluded[k] || lang_options.length == 0)
+ list.push(k);
+ }
+
+ // add english link
+ if (lang_options.length == 0 || toBeIncluded[lang_default])
+ list.push(lang_default);
+
+ this.log("language menu: " + list.join(", "));
+
+ /* the HTML part */
+ var data = "";
+ for (var i = 0; i < list.length; i++) {
+ var l = list[i];
+ if (data)
+ data += ' | ';
+
+ if (lang == l) {
+ data += ' ' + l + ' ';
+ } else {
+ data += ' ' + l + ' '
}
+ }
- for (var k in mkws.locale_lang) {
- if (toBeIncluded[k] || lang_options.length == 0)
- list.push(k);
- }
-
- // add english link
- if (lang_options.length == 0 || toBeIncluded[lang_default])
- list.push(lang_default);
+ this.node.html(data);
+ this.hideWhenNarrow();
- this.log("Language menu for: " + list.join(", "));
- /* the HTML part */
- var data = "";
- for (var i = 0; i < list.length; i++) {
- var l = list[i];
- if (data)
- data += ' | ';
+ // set or re-set "lang" URL parameter
+ function lang_url(lang) {
+ var query = location.search;
+ // no query parameters? done
+ if (!query) {
+ return "?lang=" + lang;
+ }
- if (lang == l) {
- data += ' ' + l + ' ';
- } else {
- data += ' ' + l + ' '
- }
+ // parameter does not exist
+ if (!query.match(/[\?&]lang=/)) {
+ return query + "&lang=" + lang;
}
- $(this.node).html(data);
- widget.hideWhenNarrow(this);
+ // replace existing parameter
+ query = query.replace(/\?lang=([^]*)/, "?lang=" + lang);
+ query = query.replace(/\&lang=([^]*)/, "&lang=" + lang);
+ return query;
+ }
+});
- // set or re-set "lang" URL parameter
- function lang_url(lang) {
- var query = location.search;
- // no query parameters? done
- if (!query) {
- return "?lang=" + lang;
- }
+mkws.registerWidgetType('MOTD', function() {
+ var container = this.team.widget('MOTDContainer');
+ if (container) {
+ // Move the MOTD from the provided element down into the container
+ this.node.appendTo(container.node);
+ }
+});
- // parameter does not exist
- if (!query.match(/[\?&]lang=/)) {
- return query + "&lang=" + lang;
- }
- // replace existing parameter
- query = query.replace(/\?lang=([^]*)/, "?lang=" + lang);
- query = query.replace(/\&lang=([^]*)/, "&lang=" + lang);
- return query;
+// 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('MOTD', function() {
- var container = this.team.widget('MOTDContainer');
- if (container) {
- // Move the MOTD from the provided element down into the container
- $(this.node).appendTo(container.node);
+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();
+ });
});
@@ -420,8 +450,4 @@ mkws.registerWidgetType('MOTDContainer', function() {});
mkws.registerWidgetType('Button', function() {});
mkws.registerWidgetType('Popup', function() {});
-// Not sure whether the following should have functionality:
-// Select HTMLFormElement
-// *-Container-wide HTMLTableCellElement
-// *-Container-narrow HTMLDivElement
-// Bytarget HTMLDivElement
+