diff options
Diffstat (limited to 'usr/local/www/javascript/index/sajax.js')
-rw-r--r-- | usr/local/www/javascript/index/sajax.js | 53 |
1 files changed, 31 insertions, 22 deletions
diff --git a/usr/local/www/javascript/index/sajax.js b/usr/local/www/javascript/index/sajax.js index fd9b00a..b7dd82a 100644 --- a/usr/local/www/javascript/index/sajax.js +++ b/usr/local/www/javascript/index/sajax.js @@ -74,8 +74,7 @@ function updateState(x) } function updateInterfaceStats(x){ - var widget = document.getElementById("interface_statistics-container"); - if (widget.style.display != "none"){ + if (widgetActive("interface_statistics")){ statistics_split = x.split(","); var counter = 1; for (var y=0; y<statistics_split.length-1; y++){ @@ -86,30 +85,40 @@ function updateInterfaceStats(x){ } function updateInterfaces(x){ - interfaces = x.split("~"); - for (var z=0; z<interfaces.length-1; z++){ - details = interfaces[z].split(","); - if (details[1] == "up"){ - document.getElementById(details[0] + '-up').style.display = "inline"; - document.getElementById(details[0] + '-down').style.display = "none"; - document.getElementById(details[0] + '-block').style.display = "none"; - document.getElementById(details[0] + '-ip').innerHTML = details[2]; - document.getElementById(details[0] + '-media').innerHTML = details[3]; - } else if (details[1] == "down"){ - document.getElementById(details[0] + '-down').style.display = "inline"; - document.getElementById(details[0] + '-up').style.display = "none"; - document.getElementById(details[0] + '-block').style.display = "none"; - document.getElementById(details[0] + '-ip').innerHTML = details[2]; - document.getElementById(details[0] + '-media').innerHTML = details[3]; - } else if (details[1] == "block"){ - document.getElementById(details[0] + '-block').style.display = "inline"; - document.getElementById(details[0] + '-down').style.display = "none"; - document.getElementById(details[0] + '-up').style.display = "none"; + if (widgetActive("interfaces")){ + interfaces = x.split("~"); + for (var z=0; z<interfaces.length-1; z++){ + details = interfaces[z].split(","); + if (details[1] == "up"){ + document.getElementById(details[0] + '-up').style.display = "inline"; + document.getElementById(details[0] + '-down').style.display = "none"; + document.getElementById(details[0] + '-block').style.display = "none"; + document.getElementById(details[0] + '-ip').innerHTML = details[2]; + document.getElementById(details[0] + '-media').innerHTML = details[3]; + } else if (details[1] == "down"){ + document.getElementById(details[0] + '-down').style.display = "inline"; + document.getElementById(details[0] + '-up').style.display = "none"; + document.getElementById(details[0] + '-block').style.display = "none"; + document.getElementById(details[0] + '-ip').innerHTML = details[2]; + document.getElementById(details[0] + '-media').innerHTML = details[3]; + } else if (details[1] == "block"){ + document.getElementById(details[0] + '-block').style.display = "inline"; + document.getElementById(details[0] + '-down').style.display = "none"; + document.getElementById(details[0] + '-up').style.display = "none"; + } + } - } } +function widgetActive(x){ + var widget = document.getElementById(x + '-container'); + if (widget.style.display != "none") + return TRUE; + else + return FALSE; +} + /* start ajax helper "thread" if not started */ if(!ajaxStarted) { window.setTimeout('updateMeters()', update_interval); |