summaryrefslogtreecommitdiff
path: root/ebus/webapp/static/ebus.js
diff options
context:
space:
mode:
authoryvesf <yvesf-git@xapek.org>2011-07-24 11:05:42 +0200
committeryvesf <yvesf-git@xapek.org>2011-07-24 11:05:42 +0200
commit75017423563a18986aa096566d8a2969c32c3588 (patch)
treebd86ab746dd06f71ebd1b723e3bec754805e8736 /ebus/webapp/static/ebus.js
parenta0382ecfbef32b47b7438170feaa7b81d7bc22db (diff)
downloadebus-alt-75017423563a18986aa096566d8a2969c32c3588.tar.gz
ebus-alt-75017423563a18986aa096566d8a2969c32c3588.zip
clean up file structure, use bottle soup plugin
Diffstat (limited to 'ebus/webapp/static/ebus.js')
-rw-r--r--ebus/webapp/static/ebus.js150
1 files changed, 0 insertions, 150 deletions
diff --git a/ebus/webapp/static/ebus.js b/ebus/webapp/static/ebus.js
deleted file mode 100644
index ad98d91..0000000
--- a/ebus/webapp/static/ebus.js
+++ /dev/null
@@ -1,150 +0,0 @@
-$(document).ready(function(){
- var from = Math.round(new Date().getTime()/1000) - 24*60*60; //86400;
- var fromOverview = Math.round(new Date().getTime()/1000) - 30*24*60*60; //86400;
- var to = Math.round(new Date().getTime()/1000);
- var datasetDetail = []
- var datasetOverview = [];
- var plotOverview = null;
- var plotDetail = null;
- var indexFound = null;
- var sensorList = [{"sensorname":"heizkreisregler9.solarDaten.tempKollektor","show":true},
- {"sensorname":"heizkreisregler10.betriebsdatenRegler1.kesselTemperatur","show":true},
- {"sensorname":"heizkreisregler9.solarDaten.tempWarmwasserSolar","show":false},
- {"sensorname":"feuerungsautomat1.betriebsdatenRegler1.aussenTemperatur","show":true},
- {"sensorname":"heizkreisregler10.betriebsdatenRegler1.boilerTemperatur","show":true}];
- var replot = function() {
- if (plotDetail == null) {
- plotDetail = $.plot($("#ebusgraph"),
- datasetDetail,
- {
- xaxis: { mode: "time"},
- legend: { show : true}
- });
- } else {
- plotDetail.setData(datasetDetail);
- plotDetail.draw();
- plotDetail.setupGrid(); // redraw legend
- }
- };
- var replotOverview = function() {
- if (plotOverview == null) {
- plotOverview = $.plot($("#overview"),
- datasetOverview,
- { // options
- series: {
- lines: { show: true, lineWidth: 1 },
- shadowSize: 0
- },
- xaxis: { mode: "time" },
- yaxis: { ticks: [], min: 0, max: 100, autoscaleMargin: 0.1 },
- legend: { show: false },
- selection: { mode: "x" }
- });
- } else {
- plotOverview.setData(datasetOverview);
- plotOverview.draw();
- }
- plotOverview.setSelection({xaxis: {'from': from*1000, 'to': to*1000}}, true);
- };
- var plotSensor = function(sensorname) {
- plotSensorDetail(sensorname);
- plotSensorOverview(sensorname);
- };
- var unplotSensor = function(sensorname) {
- unplotSensorDetail(sensorname);
- unplotSensorOverview(sensorname);
- };
- var plotSensorDetail = function(sensorname) {
- $.getJSON("sensor/"+escape(sensorname)+"/"+from+"/"+to,
- function(response) {
- if (response['data']) {
- datasetDetail.push({'data':response['data'],
- 'label':sensorname});
- replot();
- } else {
- alert("Fehler: " + response["error"]);
- }
- });
- };
-
- var unplotSensorDetail = function(sensorname) {
- $.each(datasetDetail, function(i, sensor) {
- if (sensor.label == sensorname) {
- datasetDetail.splice(i,1);
- replot();
- return false;
- }
- });
- };
-
- var plotSensorOverview = function(sensorname) {
- $.getJSON("sensor_cached/"+escape(sensorname)+"/"+fromOverview, //+"/"+to,
- function(response) {
- if (response['data']) {
- datasetOverview.push({'data':response['data'],
- 'label':sensorname});
- replotOverview();
- } else {
- alert("Overview Fehler: " + response["error"]);
- }
- });
-
- };
- var unplotSensorOverview = function(sensorname) {
- $.each(datasetOverview, function(i, sensor) {
- if (sensor.label == sensorname) {
- datasetOverview.splice(i,1);
- replotOverview();
- return false;
- }
- });
- }
-
- $("#overview").bind("plotselected", function (event, ranges) {
- range_from = Math.round(ranges.xaxis.from / 1000);
- range_to = Math.round(ranges.xaxis.to / 1000);
- // max selection range 14 days
- if (range_to - range_from > 14 * 24 * 60 * 60) {
- plotOverview.setSelection({xaxis: {'from': from*1000, 'to': to*1000}}, true);
- return;
- } else {
- from = range_from;
- to = range_to;
- }
- sensors = [];
- for (elem in datasetOverview) {
- sensor = datasetDetail[elem]["label"];
- sensors.push(sensor);
- }
- datasetDetail =[];
- for (i in sensors) {
- plotSensorDetail(sensors[i]);
- }
- });
-
- $.each(sensorList, function(i,sensorname) {
- var pickerDiv = $("<div>").attr("id","pick_"+sensorname.sensorname.replace(/\./g,"_"))
- .addClass("picker")
- .appendTo("#sensorpicker");
-
- var pickerCheckbox = $("<input>").attr("type","checkbox")
- .appendTo(pickerDiv);
- $(pickerDiv).append(sensorname.sensorname);
- if (sensorname.show) {
- //Plot
- plotSensor(sensorname.sensorname);
- $(pickerCheckbox).attr("checked","checked");
- }
- });
- // TODO http://people.iola.dk/olau/flot/examples/annotating.html
-
-
- $('.picker input').click( function() {
- var sensorname = $(this).parent().attr("id").replace("pick_","").replace(/_/g,".");
- if ($(this).is(":checked")) {
- plotSensor(sensorname);
- } else {
- unplotSensor(sensorname);
- }
- });
-});