From: Mike Taylor Date: Tue, 20 May 2014 12:34:09 +0000 (+0100) Subject: Add new "firstrecords" event, published when a new search gets back first records. X-Git-Tag: 1.0.0~635 X-Git-Url: http://git.indexdata.com/?a=commitdiff_plain;h=af92652a288e7f9b66ad46f0aaf977b828f683d8;p=mkws-moved-to-github.git Add new "firstrecords" event, published when a new search gets back first records. --- diff --git a/src/mkws-team.js b/src/mkws-team.js index 519fd7e..633052f 100644 --- a/src/mkws-team.js +++ b/src/mkws-team.js @@ -30,6 +30,7 @@ function team($, teamName) { var m_template = {}; // compiled templates, from any source var m_config = mkws.objectInheritingFrom(mkws.config); var m_widgets = {}; // Maps widget-type to array of widget objects + var m_gotRecords = false; that.toString = function() { return '[Team ' + teamName + ']'; }; @@ -119,8 +120,14 @@ function team($, teamName) { function onStat(data) { queue("stat").publish(data); - if (parseInt(data.activeclients[0], 10) === 0) - queue("complete").publish(parseInt(data.hits[0], 10)); + var hitcount = parseInt(data.hits[0], 10); + if (!m_gotRecords && hitcount > 0) { + m_gotRecords = true; + queue("firstrecords").publish(hitcount); + } + if (parseInt(data.activeclients[0], 10) === 0) { + queue("complete").publish(hitcount); + } } function onTerm(data) {