From 5356362ca3f71efadfd06814ef9f14cf1ff51a56 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Fri, 8 Mar 2013 00:10:09 +0545 Subject: Fix stale bandwidth-by-IP table entries When the number of valid rows in the table reduced by more than 1 between updates, stale entries were left displayed at the end - e.g. 8 rows (0-7), then next update has only 5 rows (0-4). Row 5 is hidden but rows 6 and 7 remain displayed. --- usr/local/www/status_graph.php | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) (limited to 'usr/local/www') diff --git a/usr/local/www/status_graph.php b/usr/local/www/status_graph.php index 636f5d9..2342700 100755 --- a/usr/local/www/status_graph.php +++ b/usr/local/www/status_graph.php @@ -153,32 +153,30 @@ function updateBandwidthHosts(data){ d = document; //parse top ten bandwidth abuser hosts for (var y=0; y<10; y++){ - if (hosts_split[y] != "" && hosts_split[y] != "no info"){ - if (hosts_split[y]) { - hostinfo = hosts_split[y].split(";"); + if ((y < hosts_split.length) && (hosts_split[y] != "") && (hosts_split[y] != "no info")) { + hostinfo = hosts_split[y].split(";"); - //update host ip info - var HostIpID = "hostip" + y; - var hostip = d.getElementById(HostIpID); - hostip.innerHTML = hostinfo[0]; + //update host ip info + var HostIpID = "hostip" + y; + var hostip = d.getElementById(HostIpID); + hostip.innerHTML = hostinfo[0]; - //update bandwidth inbound to host - var hostbandwidthInID = "bandwidthin" + y; - var hostbandwidthin = d.getElementById(hostbandwidthInID); - hostbandwidthin.innerHTML = hostinfo[1] + " Bits/sec"; + //update bandwidth inbound to host + var hostbandwidthInID = "bandwidthin" + y; + var hostbandwidthin = d.getElementById(hostbandwidthInID); + hostbandwidthin.innerHTML = hostinfo[1] + " Bits/sec"; - //update bandwidth outbound from host - var hostbandwidthOutID = "bandwidthout" + y; - var hostbandwidthOut = d.getElementById(hostbandwidthOutID); - hostbandwidthOut.innerHTML = hostinfo[2] + " Bits/sec"; + //update bandwidth outbound from host + var hostbandwidthOutID = "bandwidthout" + y; + var hostbandwidthOut = d.getElementById(hostbandwidthOutID); + hostbandwidthOut.innerHTML = hostinfo[2] + " Bits/sec"; - //make the row appear if hidden - var rowid = "#host" + y; - if (jQuery(rowid).css('display') == "none"){ - //hide rows that contain no data - jQuery(rowid).show(1000); - } - } + //make the row appear if hidden + var rowid = "#host" + y; + if (jQuery(rowid).css('display') == "none"){ + //hide rows that contain no data + jQuery(rowid).show(1000); + } } else { -- cgit v1.1