From e54d3461b47dd6610f2a4a95c7e38a2740f5291f Mon Sep 17 00:00:00 2001 From: Joecowboy Date: Thu, 5 Jan 2012 18:04:57 -0600 Subject: Fixed Javascript error in function updateInterfaces(x) Removed the return that revented the updates to widgets in function stats(x) Tweaked Javascript code in function updateTemp(x) for temperature output --- usr/local/www/javascript/index/ajax.js | 47 ++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 22 deletions(-) (limited to 'usr/local') diff --git a/usr/local/www/javascript/index/ajax.js b/usr/local/www/javascript/index/ajax.js index 1759c05..bafdbff 100644 --- a/usr/local/www/javascript/index/ajax.js +++ b/usr/local/www/javascript/index/ajax.js @@ -1,9 +1,9 @@ - /* Most widgets update their backend data every 10 seconds. 11 seconds * will ensure that we update the GUI right after the stats are updated. * Seconds * 1000 = value */ -var update_interval = 11000; +var Seconds = 11; +var update_interval = (Math.abs(Math.ceil(Seconds))-1)*1000 + 990; function updateMeters() { url = '/getstats.php'; @@ -16,7 +16,11 @@ function updateMeters() { stats(data); } }); - setTimeout('updateMeters()', update_interval); + setTimer(); +} + +function setTimer() { + timeout = window.setTimeout('updateMeters()', update_interval); } function stats(x) { @@ -27,17 +31,16 @@ function stats(x) { else return false; })) - return; - - updateCPU(values[0]); - updateMemory(values[1]); - updateUptime(values[2]); - updateState(values[3]); - updateTemp(values[4]); - updateDateTime(values[5]); - updateInterfaceStats(values[6]); - updateInterfaces(values[7]); - updateGatewayStats(values[8]); + + updateUptime(values[2]); + updateDateTime(values[5]); + updateCPU(values[0]); + updateMemory(values[1]); + updateState(values[3]); + updateTemp(values[4]); + updateInterfaceStats(values[6]); + updateInterfaces(values[7]); + updateGatewayStats(values[8]); } function updateMemory(x) { @@ -63,11 +66,12 @@ function updateCPU(x) { } function updateTemp(x) { - if(jQuery("#tempmeter")) { - jQuery("#tempmeter").val(x + 'C'); + if(jQuery("#tempmeter")) + jQuery("#tempmeter").val(x + '\u00B0' + 'C'); + if(jQuery('#tempwidtha')) jQuery("#tempwidtha").css('width',x + 'px'); + if(jQuery('#tempwidthb')) jQuery("#tempwidthb").css('width',(100 - x) + 'px'); - } } function updateDateTime(x) { @@ -111,8 +115,8 @@ function updateInterfaceStats(x){ function updateInterfaces(x){ if (widgetActive("interfaces")){ - interfaces = x.split("~"); - interfaces.each(function(iface){ + interfaces_split = x.split("~"); + interfaces_split.each(function(iface){ details = iface.split(","); switch(details[1]) { case "up": @@ -149,6 +153,5 @@ function widgetActive(x) { /* start updater */ jQuery(document).ready(function(){ - setTimeout('updateMeters()', update_interval); -}); - + setTimer(); +}); \ No newline at end of file -- cgit v1.1