From 93cf4e90320df21215a081a389cd2ab98a8a2d0d Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Sat, 12 Mar 2016 23:31:36 +0000 Subject: NMSjs: Bump map handlers and more The idea is that map handlers just register for events instead of this periodic update. --- web/nms.gathering.org/js/nms-map.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'web/nms.gathering.org/js/nms-map.js') diff --git a/web/nms.gathering.org/js/nms-map.js b/web/nms.gathering.org/js/nms-map.js index 69a76e0..65b5b68 100644 --- a/web/nms.gathering.org/js/nms-map.js +++ b/web/nms.gathering.org/js/nms-map.js @@ -43,7 +43,8 @@ var nmsMap = nmsMap || { nmsMap.init = function() { this._initContexts(); this._drawBG(); - nmsData.registerSource("switches","/api/public/switches",function(){nmsMap._drawAllSwitches();}); + nmsData.registerSource("switches","/api/public/switches"); + nmsData.addHandler("switches","nmsMap",function(){nmsMap._drawAllSwitches();}); window.addEventListener('resize',nmsMap._resizeEvent,true); document.addEventListener('load',nmsMap._resizeEvent,true); this._drawAllSwitches(); @@ -153,6 +154,10 @@ nmsMap._getBox = function(sw) { nmsMap._drawSwitch = function(sw) { + // XXX: If a handler sets a color before switches are loaded... The + // color will get set fine so this isn't a problem. + if (nmsData.switches == undefined || nmsData.switches.switches == undefined) + return; var box = this._getBox(sw); var color = nmsMap._color[sw]; if (color == undefined) { -- cgit v1.2.3