X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmkws-team.js;h=1ea6a6378552eef6687ec1055ae4d54209105ccd;hb=836c6e64d8f244df2675e7b70b9a95ac71adfda0;hp=a5a2d03b99a908b0db9c9e5cc17fc559bf70db00;hpb=f96e7cab250556606852c8bf6d6ee65d505ff77a;p=mkws-moved-to-github.git diff --git a/src/mkws-team.js b/src/mkws-team.js index a5a2d03..1ea6a63 100644 --- a/src/mkws-team.js +++ b/src/mkws-team.js @@ -27,7 +27,8 @@ function team($, teamName) { }; var m_paz; // will be initialised below var m_template = {}; - var m_config = Object.create(mkws.config); + var m_config = mkws.objectInheritingFrom(mkws.config); + var m_widgets = {}; // Maps widget-type to object that.toString = function() { return '[Team ' + teamName + ']'; }; @@ -48,12 +49,12 @@ function team($, teamName) { // The following PubSub code is modified from the jQuery manual: - // https://api.jquery.com/jQuery.Callbacks/ + // http://api.jquery.com/jQuery.Callbacks/ // // Use as: // team.queue("eventName").subscribe(function(param1, param2 ...) { ... }); // team.queue("eventName").publish(arg1, arg2, ...); - + // var queues = {}; function queue(id) { if (!queues[id]) { @@ -115,8 +116,9 @@ function team($, teamName) { } function onStat(data) { - log("stat"); queue("stat").publish(data); + if (parseInt(data.activeclients[0], 10) === 0) + queue("complete").publish(parseInt(data.hits[0], 10)); } function onTerm(data) { @@ -239,6 +241,7 @@ function team($, teamName) { that.reShow = function() { + resetPage(); m_paz.show(0, m_perpage, m_sortOrder); }; @@ -602,7 +605,12 @@ function team($, teamName) { teamName = teamName || m_teamName; selector = $.map(selector.split(','), function(s, i) { - return s + '.mkwsTeam_' + teamName; + if (teamName === 'AUTO') { + return (s + '.mkwsTeam_' + teamName + ',' + + s + ':not([class^="mkwsTeam"],[class*=" mkwsTeam"])'); + } else { + return s + '.mkwsTeam_' + teamName; + } }).join(','); var node = $(selector); @@ -734,6 +742,22 @@ function team($, teamName) { return s; } + that.addWidget = function(w) { + if (!m_widgets[w.type]) { + m_widgets[w.type] = widget; + log("Registered '" + w.type + "' widget in team '" + m_teamName + "'"); + } else if (typeof(m_widgets[w.type]) !== 'number') { + m_widgets[w.type] = 2; + log("Registered duplicate '" + w.type + "' widget in team '" + m_teamName + "'"); + } else { + m_widgets[w.type] += 1; + log("Registered '" + w.type + "' widget #" + m_widgets[w.type] + "' in team '" + m_teamName + "'"); + } + } + + that.widget =function(type) { + return m_widgets[type]; + } mkwsHtmlAll()