// vim: set filetype=javascript expandtab tabstop=4 shiftwidth=4 autoindent smartindent: var d = new Object(); d.ms = 1; d.sec = 1000*d.ms; d.min = 60 * d.sec; d.hour = 60 * d.min; d.day = 24 * d.hour; d.week = 7 * d.day; d.month = 30.5 * d.day; d.now = new Date().getTime(); var timeToUTC = function(d) { return d + new Date().getTimezoneOffset() * 60 * 1000; } var timeToLocal = function(d) { return d - new Date().getTimezoneOffset() * 60 * 1000; } $(document).ready(function(){ var from = d.now - 2*d.day; var to = d.now; var fromOverview = d.now - 1.5 * d.month; var toOverview = d.now; var numberOfValues = function() { return jQuery("#ebusgraph").width(); }; var datasetDetail = []; var datasetOverview = []; var plotOverview = null; var plotDetail = null; var indexFound = null; var defaultSensorConfigList = [ { "name":"heizkreisregler10.betriebsdatenRegler1.kesselTemperatur", "description":"Kessel Temperatur", "values":Math.ceil(jQuery("#ebusgraph").width()/6), "lines":{fill: true, lineWidth: 1, fillColor: "rgba(80,40,100, 0.05)"}, "show":true, "color":"rgb(80,40,100)" }, { "name":"heizkreisregler9.solarDaten.tempKollektor", "description":"Kollektortemperatur", "lines":{fill: true, fillColor: "rgba(255, 0, 0, 0.4)"}, "values":Math.ceil(jQuery("#ebusgraph").width()/1), "show":true, "color":"#f30000" }, { "name":"heizkreisregler9.solarDaten.tempWarmwasserSolar", "description":"Warmwasser Solar", "lines":{fill: true, fillColor: "rgba(252,133,30,0.1)"}, "values":Math.ceil(jQuery("#ebusgraph").width()/8), "show":false, "color":"rgba(252,133,34,0.5)" }, { "name":"heizkreisregler10.betriebsdatenRegler1.boilerTemperatur", "description":"Boilertemperatur", "values":Math.ceil(jQuery("#ebusgraph").width()/8), "show":false, "color":"#48b4ff" }, { "name":"de.wettermichel.temperature", "description":"Temperatur (Celsius) (wettermichel)", "show":false, "values":Math.ceil(jQuery("#ebusgraph").width()/4), "lines":{fill: true, fillColor: "rgba(132, 181, 0, 0.2)"}, "color":"#84b500" }, { "name":"dockstar.load5", "description":"System Load (5m, *10)", "lines":{lineWidth:1}, "show":false, "color":"blue", "mapFunc":function(d){return [d[0],d[1]*10]} }, { "name":"dockstar.internet.latency_ns", "description":"Internet latency in ms", "lines":{lineWidth:1}, "show":false, "color":"black", "mapFunc":function(d){return [d[0],d[1]/1000/1000]} }, ]; var sensorConfigList = JSON.parse(window.localStorage.getItem("ebusConfig")) || defaultSensorConfigList; var pickSensorConfig = function(sensorname) { var sensorConfigFound; $.each(sensorConfigList, function(i,sensorConfig) { if (sensorConfig["name"] == sensorname) { sensorConfigFound = sensorConfig; return false; } }); return sensorConfigFound; } var replot = function() { plotDetail.setData(datasetDetail); plotDetail.getOptions().xaxes[0].min = timeToLocal(from); plotDetail.getOptions().xaxes[0].max = timeToLocal(to); plotDetail.setupGrid(); plotDetail.draw(); } var redrawLegend = function() { $("#legend").children().remove(); var table = jQuery("
").addClass("legendColorBox").appendTo(row);
var colorBoxBox = jQuery(" ").css({background:config.color}).appendTo(colorBox);
var checkbox = jQuery("").attr("type","checkbox").appendTo(colorBoxBox);
checkbox.attr("checked", config.show);
checkbox.css({opacity:0.6});
checkbox.data("name", config.name);
checkbox.click(function() {
var config = pickSensorConfig($(this).data("name"));
config.show = $(this).prop("checked");
if (config.show) {
plotSensor(config);
} else {
unplotSensor(config.name);
}
});
var label = jQuery(" ").addClass("legendLabel").appendTo(row);
jQuery("").text(sensorConfigList[i].description).appendTo(label);
table.append(row);
}
$("#legend").append($(" | |