From: Mike Taylor Date: Tue, 4 Mar 2014 14:54:54 +0000 (+0000) Subject: Status line implemented using pub/sub X-Git-Tag: 1.0.0~1337 X-Git-Url: http://git.indexdata.com/?p=mkws-moved-to-github.git;a=commitdiff_plain;h=cff96794c88bb2d964e3fdda0885ed41a7945f7c Status line implemented using pub/sub --- diff --git a/tools/htdocs/mkws.js b/tools/htdocs/mkws.js index 43fc455..60b9388 100644 --- a/tools/htdocs/mkws.js +++ b/tools/htdocs/mkws.js @@ -183,11 +183,16 @@ function widget($, team, type, node) { if (type === 'Targets') { promoteTargets(); + } else if (type === 'Stat') { + promoteStat(); + } else { + // Unsupported widget type: call an extension? } // ### More to do here, surely: e.g. wiring into the team mkws.debug("made widget(team=" + team + ", type=" + type + ", node=" + node); + function promoteTargets() { mkws.queue("targets").subscribe(function(data) { if (node.length === 0) alert("huh?!"); @@ -214,6 +219,20 @@ function widget($, team, type, node) { }); } + + function promoteStat() { + mkws.queue("stat").subscribe(function(data) { + if (node.length === 0) alert("huh?!"); + + $(node).html('' + M('Status info') + '' + + ' -- ' + + '' + M('Active clients') + ': ' + data.activeclients + '/' + data.clients + '' + + ' -- ' + + '' + M('Retrieved records') + ': ' + data.records + '/' + data.hits + ''); + }); + } + + return that; } @@ -296,14 +315,7 @@ function team($, teamName) { function onStat(data, teamName) { debug("stat"); - var node = findnode('.mkwsStat'); - if (node.length === 0) return; - - node.html('' + M('Status info') + '' + - ' -- ' + - '' + M('Active clients') + ': ' + data.activeclients + '/' + data.clients + '' + - ' -- ' + - '' + M('Retrieved records') + ': ' + data.records + '/' + data.hits + ''); + mkws.queue("stat").publish(data); }