X-Git-Url: http://sru.miketaylor.org.uk/?a=blobdiff_plain;f=src%2Fmkws-widget-main.js;h=ffe00d64d696c5f65e129bad7ce69cacf90705e1;hb=7508a91294fa89cb3f57218eefd7f0354df81ea4;hp=35cfb16ff2d20c3d8528bbc0cfa48f32ab834055;hpb=b36da4a84d0742c0fce7d0f4891f078aa230079e;p=mkws-moved-to-github.git
diff --git a/src/mkws-widget-main.js b/src/mkws-widget-main.js
index 35cfb16..ffe00d6 100644
--- a/src/mkws-widget-main.js
+++ b/src/mkws-widget-main.js
@@ -176,9 +176,9 @@ mkws.registerWidgetType('Perpage', function() {
mkws.registerWidgetType('Done', function() {
var that = this;
-
this.team.queue("complete").subscribe(function(n) {
- that.node.html("Search complete: found " + n + " records");
+ var template = that.team.loadTemplate(that.config.template || "Done");
+ that.node.html(template({count: n}));
});
});
@@ -186,23 +186,21 @@ mkws.registerWidgetType('Done', function() {
mkws.registerWidgetType('Switch', function() {
if (!this.config.show_switch) return;
var tname = this.team.name();
- this.node.html('\
-Records \
-| \
-Targets');
+ var output = {};
+ output.recordClick = "mkws.switchView(\'" + tname + "\', \'records\')";
+ output.targetClick = "mkws.switchView(\'" + tname + "\', \'targets\')";
+ var template = this.team.loadTemplate(this.config.template || "Switch");
+ this.node.html(template(output));
this.hideWhenNarrow();
});
mkws.registerWidgetType('Search', function() {
- var tname = this.team.name();
- var M = mkws.M;
-
- this.node.html('\
-
');
+ var output = {};
+ output.team = this.team.name();
+ output.queryWidth = this.config.query_width;
+ var template = this.team.loadTemplate(this.config.template || "Search");
+ this.node.html(template(output));
});
@@ -217,90 +215,42 @@ mkws.registerWidgetType('SearchForm', function() {
mkws.registerWidgetType('Results', function() {
- var tname = this.team.name();
-
- this.node.html('\
-\
- \
- \
- \
- | \
- \
- \
- \
- \
- \
- | \
-
\
- \
- \
- \
- | \
-
\
-
');
-
+ var template = this.team.loadTemplate(this.config.template || "Results");
+ this.node.html(template({team: this.team.name()}));
this.autosearch();
});
mkws.registerWidgetType('Ranking', function() {
- var tname = this.team.name();
- var that = this;
- var M = mkws.M;
-
- var s = '';
-
- this.node.html(s);
-
-
- function mkwsHtmlSort() {
- var order = that.team.sortOrder();
-
- that.log("making sort HTML, sortOrder = '" + order + "'");
- var sort_html = '';
- return sort_html;
+ var perpage = this.team.perpage();
+ this.log("making perpage, perpage = " + perpage);
+ for(var i = 0; i < this.config.perpage_options.length; i++) {
+ var cur = {};
+ cur.perPage = this.config.perpage_options[i];
+ if (cur.perPage == perpage) cur.selected = true;
+ output.perPage.push(cur);
}
- function mkwsHtmlPerpage() {
- var perpage = that.team.perpage();
-
- that.log("making perpage HTML, perpage = " + perpage);
- var perpage_html = '';
-
- return perpage_html;
- }
+ var template = this.team.loadTemplate(this.config.template || "Ranking");
+ this.node.html(template(output));
});
@@ -321,34 +271,30 @@ mkws.registerWidgetType('Lang', function() {
}
for (var k in mkws.locale_lang) {
- if (toBeIncluded[k] || lang_options.length == 0)
- list.push(k);
+ if (toBeIncluded[k] || lang_options.length == 0) {
+ cur = {};
+ if (lang === k) cur.selected = true;
+ cur.code = k;
+ cur.url = lang_url(k);
+ list.push(cur);
+ }
}
// add english link
- if (lang_options.length == 0 || toBeIncluded[lang_default])
- list.push(lang_default);
+ if (lang_options.length == 0 || toBeIncluded[lang_default]) {
+ cur = {};
+ if (lang === lang_default) cur.selected = true;
+ cur.code = lang_default;
+ cur.url = lang_url(lang_default);
+ list.push(cur);
+ }
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 + ' '
- }
- }
-
- this.node.html(data);
+ var template = this.team.loadTemplate(this.config.template || "Lang");
+ this.node.html(template({languages: list}));
this.hideWhenNarrow();
-
// set or re-set "lang" URL parameter
function lang_url(lang) {
var query = location.search;
@@ -396,19 +342,13 @@ mkws.registerWidgetType('Config', function() {
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);
+ var template = this.team.loadTemplate(this.config.template || "Progress");
+ this.node.html(template({
+ done: data.clients - data.activeclients,
+ waiting: data.activeclients
+ }));
that.node.show();
});
});