From b1678e2d72a59dc066eb09c24240877fe4553f58 Mon Sep 17 00:00:00 2001 From: Vinicius Coque Date: Tue, 20 Sep 2011 21:25:24 -0300 Subject: Convert dashboard ajax code from Prototype to jQuery --- usr/local/www/javascript/index/ajax.js | 96 +++++++++++++++++----------------- 1 file changed, 48 insertions(+), 48 deletions(-) (limited to 'usr/local/www/javascript/index') diff --git a/usr/local/www/javascript/index/ajax.js b/usr/local/www/javascript/index/ajax.js index 5b18480..6fd26d7 100644 --- a/usr/local/www/javascript/index/ajax.js +++ b/usr/local/www/javascript/index/ajax.js @@ -6,14 +6,14 @@ var update_interval = 11000; function updateMeters() { - url = '/getstats.php' + url = '/getstats.php'; - new Ajax.Request(url, { - method: 'get', - onSuccess: function(transport) { - response = transport.responseText || ""; + jQuery.ajax(url, { + type: 'get', + success: function(data) { + response = data || ""; if (response != "") - stats(transport.responseText); + stats(data); } }); setTimeout('updateMeters()', update_interval); @@ -41,21 +41,21 @@ function stats(x) { } function updateMemory(x) { - if($('memusagemeter')) - $("memusagemeter").value = x + '%'; - if($('memwidtha')) - $("memwidtha").style.width = x + 'px'; - if($('memwidthb')) - $("memwidthb").style.width = (100 - x) + 'px'; + 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($('cpumeter')) - $("cpumeter").value = x + '%'; - if($('cpuwidtha')) - $("cpuwidtha").style.width = x + 'px'; - if($('cpuwidthb')) - $("cpuwidthb").style.width = (100 - x) + 'px'; + 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); @@ -63,34 +63,34 @@ function updateCPU(x) { } function updateTemp(x) { - if($("tempmeter")) { - $("tempmeter").value = x + 'C'; - $("tempwidtha").style.width = x + 'px'; - $("tempwidthb").style.width = (100 - x) + 'px'; + 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($('datetime')) - $("datetime").firstChild.data = x; + if(jQuery('#datetime')) + jQuery("#datetime").html(x); } function updateUptime(x) { - if($('uptime')) - $("uptime").value = x; + if(jQuery('#uptime')) + jQuery("#uptime").val(x); } function updateState(x) { - if($('pfstate')) - $("pfstate").value = x; + if(jQuery('#pfstate')) + jQuery("#pfstate").val(x); } function updateGatewayStats(x){ if (widgetActive("gateways")){ gateways_split = x.split(","); for (var y=0; y