forked from joshplant/Codiad-System-Information
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.js
More file actions
executable file
·68 lines (51 loc) · 1.62 KB
/
init.js
File metadata and controls
executable file
·68 lines (51 loc) · 1.62 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
* (C) 2017 Josh Plant (JPL42)
*/
(function(global, $){
// Define core
var codiad = global.codiad,
scripts = document.getElementsByTagName('script'),
path = scripts[scripts.length-1].src.split('?')[0],
curpath = path.split('/').slice(0, -1).join('/')+'/';
// Instantiates plugin
$(function() {
codiad.System_Information.init();
});
codiad.System_Information = {
path: curpath,
init: function() {
},
Server_Dialog: function() {
codiad.modal.load(400, curpath+"dialog.php");
}
};
})(this, jQuery);
var killed = true;
function colorizeData(data){
if(data <50){
return "<b style='color:green;'>"+data+"%</b>";
}
else if(data < 75){
return "<b style='color:orange;'>"+data+"%</b>";
}
else if(data >= 75){
return "<b style='color:red;'>"+data+"%</b>";
}
};
function poll() {
if(!killed){
$.post( "plugins/Codiad-System-Information/poller.php", { systemInformation: "cpu"},function( data ) {
$("#cpuUsage").html(colorizeData(data));
$("#cpuBar").width(data+"%");
});
$.post( "plugins/Codiad-System-Information/poller.php", { systemInformation: "memory"},function( data ) {
$("#memoryUsage").html(colorizeData(data));
$("#memoryBar").width(data+"%");
});
$.post( "plugins/Codiad-System-Information/poller.php", { systemInformation: "disk"},function( data ) {
$("#diskUsage").html(colorizeData(data));
$("#diskBar").width(data+"%");
});
}
};
setInterval("poll();",1000);