/* 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; function updateMeters() { url = '/getstats.php'; jQuery.ajax(url, { type: 'get', success: function(data) { response = data || ""; if (response != "") stats(data); } }); setTimeout('updateMeters()', update_interval); } function stats(x) { var values = x.split("|"); if (values.find(function(value){ if (value == 'undefined' || value == null) return true; 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]); } function updateMemory(x) { if(jQuery('#memusagemeter')) jQuery("#memusagemeter").val(x + '%'); if(jQuery('#memwidtha')) jQuery("#memwidtha").css('width',x + 'px'); if(jQuery('#memwidthb')) jQuery("#memwidthb").css('width', (100 - x) + 'px'); } function updateCPU(x) { if(jQuery('#cpumeter')) jQuery("#cpumeter").val(x + '%'); if(jQuery('#cpuwidtha')) jQuery("#cpuwidtha").css('width',x + 'px'); if(jQuery('#cpuwidthb')) jQuery("#cpuwidthb").css('width',(100 - x) + 'px'); /* Load CPU Graph widget if enabled */ if(widgetActive('cpu_graphs')) { GraphValue(graph[0], x); } } function updateTemp(x) { if(jQuery("#tempmeter")) { jQuery("#tempmeter").val(x + 'C'); jQuery("#tempwidtha").css('width',x + 'px'); jQuery("#tempwidthb").css('width',(100 - x) + 'px'); } } function updateDateTime(x) { if(jQuery('#datetime')) jQuery("#datetime").html(x); } function updateUptime(x) { if(jQuery('#uptime')) jQuery("#uptime").val(x); } function updateState(x) { if(jQuery('#pfstate')) jQuery("#pfstate").val(x); } function updateGatewayStats(x){ if (widgetActive("gateways")){ gateways_split = x.split(","); for (var y=0; y