forked from Th3-822/rapidleech
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathajax_refresh.js
36 lines (35 loc) · 1.12 KB
/
ajax_refresh.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
var idleTime = 0;
$(document).ready(function(){
var idleInterval = setInterval("idleTime++;", 1000);
$(this).mousemove(function(e){
var tmp = idleTime;
idleTime = 0;
if (tmp >= 120) { stats_timer = setTimeout("refreshStats()",1000); }
});
});
var stats_timed = 10;
function refreshStats() {
$.ajax({
type: "GET",
url: 'ajax.php?ajax=server_stats',
dataType: 'json',
success: function (data) {
$('#cpuload').html(data.CPULoad);
$('#inuse').html(data.InUse);
$('#inusepercent').html(data.InUsePercent);
$('#freespace').html(data.FreeSpace);
$('#diskspace').html(data.DiskSpace);
diskPercent = new Image();
diskPercent.src = "classes/bar.php?rating=" + data.DiskPercent;
$('#diskpercent').attr('src',diskPercent.src);
cpuPercent = new Image();
cpuPercent.src = "classes/bar.php?rating=" + data.CPUPercent;
$('#cpupercent').attr('src',cpuPercent.src);
if (stats_timed < 60) { stats_timed = stats_timed + 10; }
if (idleTime < 120) {
clearTimeout(stats_timer);
stats_timer = setTimeout("refreshStats()",stats_timed * 1000);
}
}
});
}