diff options
author | Kristian Lyngstol <kly@kly.no> | 2016-03-12 23:31:36 +0000 |
---|---|---|
committer | Kristian Lyngstol <kly@kly.no> | 2016-03-12 23:31:36 +0000 |
commit | 93cf4e90320df21215a081a389cd2ab98a8a2d0d (patch) | |
tree | e79fede0d7730b13d3282100f405fac3e4b37762 /web/nms.gathering.org/js/nms-map.js | |
parent | 83e6b5e193799cabdc0af876178f385faef5e172 (diff) |
NMSjs: Bump map handlers and more
The idea is that map handlers just register for events instead of this
periodic update.
Diffstat (limited to 'web/nms.gathering.org/js/nms-map.js')
-rw-r--r-- | web/nms.gathering.org/js/nms-map.js | 7 |
1 files changed, 6 insertions, 1 deletions
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) { |