};
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 + ']'; };
// 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]) {
}
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) {
that.reShow = function() {
+ resetPage();
m_paz.show(0, m_perpage, m_sortOrder);
};
// switching view between targets and records
function switchView(view) {
- var targets = findnode('.mkwsTargets');
+ var targets = widgetNode('Targets');
var results = findnode('.mkwsResults,.mkwsRecords');
var blanket = findnode('.mkwsBlanket');
var motd = findnode('.mkwsMOTD');
</tr>\
</table>');
+ var acc = [];
+ var facets = m_config.facets;
+ acc.push('<div class="title">' + M('Termlists') + '</div>');
+ for (var i = 0; i < facets.length; i++) {
+ acc.push('<div class="mkwsFacet mkwsTeam_' + m_teamName + '" data-mkws-facet="' + facets[i] + '">');
+ acc.push('</div>');
+ }
+ findnode(".mkwsTermlists").html(acc.join(''));
+
var ranking_data = '<form name="mkwsSelect" class="mkwsSelect mkwsTeam_' + m_teamName + '" action="" >';
if (m_config.show_sort) {
ranking_data += M('Sort by') + ' ' + mkwsHtmlSort() + ' ';
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);
that.findnode = findnode;
+ // This much simpler and more efficient function should be usable
+ // in place of most uses of findnode.
+ function widgetNode(type) {
+ var w = that.widget(type);
+ return w ? $(w.node) : undefined;
+ }
+
function renderDetails(data, marker) {
var template = loadTemplate("Record");
var details = template(data);
return s;
}
+ that.addWidget = function(w) {
+ if (!m_widgets[w.type]) {
+ m_widgets[w.type] = w;
+ 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.widgetTypes = function() {
+ var keys = [];
+ for (var k in m_widgets) keys.push(k);
+ return keys.sort();
+ }
+
+ that.widget = function(type) {
+ return m_widgets[type];
+ }
mkwsHtmlAll()