diff options
author | Kristian Lyngstol <kristian@bohemians.org> | 2015-04-28 10:30:14 +0200 |
---|---|---|
committer | Kristian Lyngstol <kristian@bohemians.org> | 2015-04-28 10:30:14 +0200 |
commit | 9502fc0d398de46cea301a921b16f945289fdffd (patch) | |
tree | 5ec793d050beb2213ac0cc56dcf328fb724071e8 | |
parent | b1d8375df1e5539e20dad1d647f6e1505b796217 (diff) |
NMS: Better refresh/sticky maps
-rw-r--r-- | web/nms.gathering.org/nms2/index.html | 11 | ||||
-rw-r--r-- | web/nms.gathering.org/nms2/js/nms-map-handlers.js | 15 | ||||
-rw-r--r-- | web/nms.gathering.org/nms2/js/nms.js | 44 |
3 files changed, 51 insertions, 19 deletions
diff --git a/web/nms.gathering.org/nms2/index.html b/web/nms.gathering.org/nms2/index.html index a916bc1..b9bc2b7 100644 --- a/web/nms.gathering.org/nms2/index.html +++ b/web/nms.gathering.org/nms2/index.html @@ -303,6 +303,17 @@ </h3> </div> <div class="panel-body"> + <p>Some features do not have time travel support (comment + spotting and DHCP map at the moment). We also lack + compatible SNMP data for the first day or so, so you'll + only have ping data for the first day of TG15.</p> + <p>It could take some time to load a specific point in time + for the first time. See "About performance" under the help + menu for more information.</p> + <p>You can also step backwards and forwards in time, stop + and start replay and go back to real time using keyboard + shortcuts. See the help menu for an overview of keyboard + shortcuts.</p> <div class="input-group"> <input type="text" class="form-control" placeholder="YYYY-MM-DD hh:mm:ss" id="nowPicker"> <span class="input-group-btn"> diff --git a/web/nms.gathering.org/nms2/js/nms-map-handlers.js b/web/nms.gathering.org/nms2/js/nms-map-handlers.js index 5966692..531b686 100644 --- a/web/nms.gathering.org/nms2/js/nms-map-handlers.js +++ b/web/nms.gathering.org/nms2/js/nms-map-handlers.js @@ -21,39 +21,54 @@ var handler_uplinks = { updater:uplinkUpdater, init:uplinkInit, + tag:"uplink", name:"Uplink map" }; var handler_temp = { updater:tempUpdater, init:tempInit, + tag:"temp", name:"Temperature map" }; var handler_ping = { updater:pingUpdater, init:pingInit, + tag:"ping", name:"IPv4 Ping map" }; var handler_traffic = { updater:trafficUpdater, init:trafficInit, + tag:"traffic", name:"Uplink traffic map" }; var handler_disco = { updater:randomizeColors, init:discoInit, + tag:"disco", name:"Disco fever" }; var handler_comment = { updater:commentUpdater, init:commentInit, + tag:"comment", name:"Fresh comment spotter" }; +var handlers = [ + handler_uplinks, + handler_temp, + handler_ping, + handler_traffic, + handler_disco, + handler_comment + ]; + /* * Update function for uplink map * Run periodically when uplink map is active. diff --git a/web/nms.gathering.org/nms2/js/nms.js b/web/nms.gathering.org/nms2/js/nms.js index 5f03dfa..f6d7bb0 100644 --- a/web/nms.gathering.org/nms2/js/nms.js +++ b/web/nms.gathering.org/nms2/js/nms.js @@ -613,6 +613,18 @@ function updateAjaxInfo() */ function updateMap() { + /* + * XXX: This a bit hacky: There are a bunch of links that use + * href="#foo" but probably shouldn't. This breaks refresh since we + * base this on the location hash. To circumvent that issue + * somewhat, we just update the location hash if it's not + * "correct". + */ + if (nms.updater) { + if (document.location.hash != ('#' + nms.updater.tag)) { + document.location.hash = nms.updater.tag; + } + } if (!newerSwitches()) return; if (!nms.drawn) @@ -624,7 +636,7 @@ function updateMap() nms.update_time = Date.now(); if (nms.updater != undefined && nms.switches_now && nms.switches_then) { - nms.updater(); + nms.updater.updater(); } drawNow(); } @@ -637,12 +649,13 @@ function setUpdater(fo) nms.updater = undefined; resetColors(); fo.init(); - nms.updater = fo.updater; + nms.updater = fo; var foo = document.getElementById("updater_name"); foo.innerHTML = fo.name + " "; + document.location.hash = fo.tag; initialUpdate(); if (nms.ping_data && nms.switches_then && nms.switches_now) { - nms.updater(); + nms.updater.updater(); } } @@ -660,7 +673,7 @@ function initialUpdate() drawSwitches(); drawLinknets(); } - nms.updater(); + nms.updater.updater(); nms.did_update = true; } } @@ -1087,7 +1100,8 @@ function setScale() } nms.nightBlur = {}; nms.textDrawn = {}; - drawGradient(nms.gradients); + if (nms.gradients) + drawGradient(nms.gradients); drawBG(); drawScene(); drawNow(); @@ -1392,21 +1406,13 @@ function initNMS() { function detectHandler() { var url = document.URL; - if (/#ping/.exec(url)) { - setUpdater(handler_ping); - }else if (/#uplink/.exec(url)) { - setUpdater(handler_uplinks); - } else if (/#temp/.exec(url)) { - setUpdater(handler_temp); - } else if (/#traffic/.exec(url)) { - setUpdater(handler_traffic); - } else if (/#comment/.exec(url)) { - setUpdater(handler_comment); - } else if (/#disco/.exec(url)) { - setUpdater(handler_disco); - } else { - setUpdater(handler_ping); + for (var i in handlers) { + if (('#' + handlers[i].tag) == document.location.hash) { + setUpdater(handlers[i]); + return; + } } + setUpdater(handler_ping); } /* |