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 /web/nms.gathering.org/ping.js | |
parent | c7ba101d90a5c49167b3355a5a3b0c629964b9b1 (diff) |
Modularize the ping page a bit.
Diffstat (limited to 'web/nms.gathering.org/ping.js')
-rw-r--r-- | web/nms.gathering.org/ping.js | 22 |
1 files changed, 14 insertions, 8 deletions
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'; } |