From: Jason Skomorowski Date: Tue, 5 Aug 2014 13:56:36 +0000 (-0400) Subject: Template Targets widget X-Git-Tag: 1.0.0~324^2~47 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=abf1cc56493d7dc696ee5848459ac895c2c3e5e8;p=mkws-moved-to-github.git Template Targets widget --- diff --git a/src/mkws-widget-main.js b/src/mkws-widget-main.js index e327941..224595e 100644 --- a/src/mkws-widget-main.js +++ b/src/mkws-widget-main.js @@ -6,30 +6,25 @@ 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 ='' + - '' + - '' + - '' + - '' + - '' + - ''; - + // There is a bug in pz2.js + var cleandata = []; for (var i = 0; i < data.length; i++) { - table += ""; + 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 += '
' + M('Target ID') + '' + M('Hits') + '' + M('Diags') + '' + M('Records') + '' + M('State') + '
" + data[i].id + - "" + data[i].hits + - "" + data[i].diagnostic + - "" + data[i].records + - "" + data[i].state + "
'; - that.node.html(table); + var template = that.team.loadTemplate(that.config.template || "Targets"); + that.node.html(template({data: cleandata})); }); }); diff --git a/src/mkws-widget-main.templates/Targets.handlebars b/src/mkws-widget-main.templates/Targets.handlebars new file mode 100644 index 0000000..4be3a21 --- /dev/null +++ b/src/mkws-widget-main.templates/Targets.handlebars @@ -0,0 +1,33 @@ +{{! +Target detail + +data: + id - target id + hits - number of hits for this target + diagnostic - + records - + state - target state +}} + + + + + + + + + + + + + {{#each data}} + + + + + + + + {{/each}} + +
{{mkws-translate "Target ID"}}{{mkws-translate "Hits"}}{{mkws-translate "Diags"}}{{mkws-translate "Records"}}{{mkws-translate "State"}}
{{{id}}}{{hits}}{{diagnostic}}{{records}}{{hits}}