|
|
@@ -1,9 +1,3 @@ |
|
|
|
//jquery |
|
|
|
#include "jquery.js" |
|
|
|
|
|
|
|
//highcharts |
|
|
|
#include "highstock.js" |
|
|
|
|
|
|
|
socket.onopen = function() { |
|
|
|
// connected |
|
|
|
} |
|
|
@@ -19,12 +13,25 @@ var msgNumbs = { |
|
|
|
c: "#consumption", |
|
|
|
}; |
|
|
|
|
|
|
|
function netgridcolor(v) { |
|
|
|
if (v <= 0) |
|
|
|
return "#00ff00"; |
|
|
|
else |
|
|
|
return "#ff0000"; |
|
|
|
} |
|
|
|
|
|
|
|
socket.onmessage = function(m) { |
|
|
|
var msg = m.data.split(" "); |
|
|
|
if (msg[0] in msgNumbs) { |
|
|
|
// simple update values |
|
|
|
var num = parseFloat(msg[1]); |
|
|
|
$(msgNumbs[msg[0]]).text(num.toString()); |
|
|
|
var targ = $(msgNumbs[msg[0]]); |
|
|
|
targ.text(num.toString()); |
|
|
|
|
|
|
|
// update color for ng |
|
|
|
if (msg[0] == "ng") { |
|
|
|
$(".gridpower").css('background', netgridcolor(num)); |
|
|
|
} |
|
|
|
} else if (msg[0] == 'o') { |
|
|
|
// received overview data |
|
|
|
var data = JSON.parse(msg[1]); |
|
|
|