From af92652a288e7f9b66ad46f0aaf977b828f683d8 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Tue, 20 May 2014 13:34:09 +0100 Subject: [PATCH] Add new "firstrecords" event, published when a new search gets back first records. --- src/mkws-team.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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) { -- 1.7.10.4