diff options
author | root <root@frank.tg14.gathering.org> | 2014-04-18 00:32:39 +0200 |
---|---|---|
committer | root <root@frank.tg14.gathering.org> | 2014-04-18 00:32:39 +0200 |
commit | e686370341e95830125fc1d3b40c9a61a5e8aed4 (patch) | |
tree | 2e60ea8973000a6f80798ed2d06fc6729dd57511 | |
parent | c7ba101d90a5c49167b3355a5a3b0c629964b9b1 (diff) |
Modularize the ping page a bit.
-rw-r--r-- | web/nms.gathering.org/ping.css | 13 | ||||
-rw-r--r-- | web/nms.gathering.org/ping.html | 25 | ||||
-rw-r--r-- | web/nms.gathering.org/ping.js | 22 |
3 files changed, 37 insertions, 23 deletions
diff --git a/web/nms.gathering.org/ping.css b/web/nms.gathering.org/ping.css new file mode 100644 index 0000000..1045a4a --- /dev/null +++ b/web/nms.gathering.org/ping.css @@ -0,0 +1,13 @@ +.switchname { + position: absolute; + font-family: sans-serif; + font-size: small; + white-space: nowrap; +} +.rot { + -webkit-transform: rotate(-90deg); + -webkit-transform-origin: 0% 0%; + transform: rotate(-90deg); + transform-origin: 0% 0%; + bottom: -14px; +} diff --git a/web/nms.gathering.org/ping.html b/web/nms.gathering.org/ping.html index 8205077..3aea383 100644 --- a/web/nms.gathering.org/ping.html +++ b/web/nms.gathering.org/ping.html @@ -1,25 +1,20 @@ <html> + <head> + <title>Ping? Pong!</title> + </head> <body> - <style> -.switchname { - position: absolute; - font-family: sans-serif; - font-size: small; - white-space: nowrap; -} -.rot { - -webkit-transform: rotate(-90deg); - -webkit-transform-origin: 0% 0%; - transform: rotate(-90deg); - transform-origin: 0% 0%; - bottom: -14px; -} -</style> + <link rel="stylesheet" href="/ping.css"> <p id="playground"> <svg id="lines" width="1280" height="736" style="position: absolute; top: 0; left: 0; z-index: 1"> </svg> <img src="tg14-salkart.png" alt="" id="map" /> </p> + <script> + // These are used by ping.js, below. + var switches_url = "/switches-json.pl"; + var ping_url = "/ping-json.pl"; + var draw_linknets = true; + </script> <script type="text/javascript" src="ping.js"></script> </body> </html> diff --git a/web/nms.gathering.org/ping.js b/web/nms.gathering.org/ping.js index ce3d99f..c3d2c63 100644 --- a/web/nms.gathering.org/ping.js +++ b/web/nms.gathering.org/ping.js @@ -22,11 +22,11 @@ function json_request(url, func, repeat_ms) { } function get_switches() { - json_request('/switches-json.pl', draw_switches, 1000); + json_request(switches_url, draw_switches, 1000); } function get_ping() { - json_request('/ping-json.pl', update_ping, 1000); + json_request(ping_url, update_ping, 1000); } function draw_switches(json) { @@ -53,9 +53,11 @@ function draw_switches(json) { parseInt(s['height'])); } - for (var i = 0; i < json['linknets'].length; ++i) { - var linknet = json['linknets'][i]; - create_linknet(linknet['linknet'], linknet['switch1'], linknet['switch2']); + if (draw_linknets) { + for (var i = 0; i < json['linknets'].length; ++i) { + var linknet = json['linknets'][i]; + create_linknet(linknet['linknet'], linknet['switch1'], linknet['switch2']); + } } setTimeout(get_switches, 60000); @@ -137,9 +139,13 @@ function really_update_ping(json) { if (json['switches']) { for (var switchnum in switches) { if (json['switches'][switchnum]) { - switches[switchnum].style.background = - gradient_from_latency(json['switches'][switchnum]['latency'], - json['switches'][switchnum]['latency_secondary']); + if (json['switches'][switchnum]['color']) { + switches[switchnum].style.background = json['switches'][switchnum]['color']; + } else { + switches[switchnum].style.background = + gradient_from_latency(json['switches'][switchnum]['latency'], + json['switches'][switchnum]['latency_secondary']); + } } else { switches[switchnum].style.background = '#0000ff'; } |