From d38e6ba26931cffd6c09128dfeb7321bc224ede3 Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Sat, 12 Mar 2016 18:14:43 +0000 Subject: NMSjs: Start applying the nmsData logic aka: break * Things are currently somewhat broken, as expected. No handlers are updated. All in all, this isn't a disaster because it reveals a lot of crud that should never have been tied in with this logic to begin with. Will continue working on it after dinner. --- web/nms.gathering.org/js/nms-data.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'web/nms.gathering.org/js/nms-data.js') diff --git a/web/nms.gathering.org/js/nms-data.js b/web/nms.gathering.org/js/nms-data.js index 5f5a2b4..67f71a2 100644 --- a/web/nms.gathering.org/js/nms-data.js +++ b/web/nms.gathering.org/js/nms-data.js @@ -137,6 +137,7 @@ nmsData.removeSource = function (name) { * FIXME: Should be unified with nmsTimers() somehow. */ nmsData.registerSource = function(name, target, cb, cbdata) { + var fresh = false; var cbob = { name: name, cb: cb, @@ -146,12 +147,15 @@ nmsData.registerSource = function(name, target, cb, cbdata) { this._sources[name] = { target: target, cbs: [] }; this._sources[name]['handle'] = setInterval(function(){nmsData.updateSource(name)}, 1000); this.stats.newSource++; + fresh = true; } else { this.stats.oldSource++; } this._sources[name].cbs.push(cbob); this.stats.pollSets++; + if (fresh) + this.updateSource(name); } /* @@ -189,7 +193,6 @@ nmsData._genericUpdater = function(name) { this.stats.ajaxOverflow++; return; } - this.stats.outstandingAjaxRequests++; var now = ""; if (this._now != undefined) now = "now=" + this._now; @@ -210,7 +213,9 @@ nmsData._genericUpdater = function(name) { nmsData[name] = data; for (var i in nmsData._sources[name].cbs) { var tmp = nmsData._sources[name].cbs[i]; - tmp.cb(tmp.cbdata); + if (tmp.cb != undefined) { + tmp.cb(tmp.cbdata); + } } } else { nmsData.stats.identicalFetches++; -- cgit v1.2.3