Handlebars.registerHelper('mkws-index1', function(obj) {
return obj.data.index + 1;
});
+
+Handlebars.registerHelper('mkws-repeat', function(count, options) {
+ var out = "";
+ for (var i = 0; i < count; i++) {
+ out += options.fn(this);
+ }
+ return out;
+});
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);
+ var template = this.team.loadTemplate(this.config.template || "Progress");
+ this.node.html(template({
+ done: data.clients - data.activeclients,
+ waiting: data.activeclients
+ }));
that.node.show();
});
});
--- /dev/null
+{{!
+Progress
+
+done - number of targets complete
+waiting - number of targets waiting
+}}
+<span class="mkwsDone">{{#mkws-repeat done}}█{{/mkws-repeat}}</span>
+{{~#if waiting~}}
+<span class="mkwsWaiting">{{#mkws-repeat waiting}}█{{/mkws-repeat}}</span>
+{{~/if~}}
+