From cff96794c88bb2d964e3fdda0885ed41a7945f7c Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Tue, 4 Mar 2014 14:54:54 +0000 Subject: [PATCH] Status line implemented using pub/sub --- tools/htdocs/mkws.js | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) 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); } -- 1.7.10.4