2010-09-27 01:33:49 +02:00
|
|
|
/**
|
|
|
|
* Main javascript file
|
|
|
|
*
|
|
|
|
* @author Florian Ziegler <fz@f10-home.de>
|
|
|
|
* @author Justin Otherguy <justin@justinotherguy.org>
|
|
|
|
* @author Steffen Vogel <info@steffenvogel.de>
|
|
|
|
* @copyright Copyright (c) 2010, The volkszaehler.org project
|
|
|
|
* @package default
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* This file is part of volkzaehler.org
|
|
|
|
*
|
|
|
|
* volkzaehler.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* volkzaehler.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with volkszaehler.org. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2010-09-27 00:26:35 +02:00
|
|
|
|
2010-09-28 18:17:45 +02:00
|
|
|
/*
|
2010-10-01 11:23:31 +02:00
|
|
|
* Constants & settings
|
2010-09-28 18:17:45 +02:00
|
|
|
*/
|
2010-10-01 11:23:31 +02:00
|
|
|
var backendUrl = '../backend/index.php';
|
|
|
|
var tuples = 300;
|
|
|
|
var colors = ['#83CAFF', '#7E0021', '#579D1C', '#FFD320', '#FF420E', '#004586', '#0084D1', '#C5000B', '#FF950E', '#4B1F6F', '#AECF00', '#314004'];
|
|
|
|
var jqOptions = {
|
2010-09-28 18:17:45 +02:00
|
|
|
series: [],
|
|
|
|
cursor: {
|
|
|
|
zoom: true,
|
|
|
|
showTooltip: true,
|
|
|
|
constrainZoomTo: 'x'
|
|
|
|
},
|
|
|
|
seriesDefaults: {
|
|
|
|
lineWidth: 1,
|
2010-09-29 21:59:49 +02:00
|
|
|
showMarker: true,
|
|
|
|
showLine: false,
|
|
|
|
markerOptions: {
|
|
|
|
style: 'dash',
|
2010-10-01 11:23:31 +02:00
|
|
|
shadow: false,
|
2010-09-29 21:59:49 +02:00
|
|
|
size: 2
|
2010-10-01 11:23:31 +02:00
|
|
|
},
|
|
|
|
trendline: {
|
|
|
|
shadow: false
|
2010-09-29 21:59:49 +02:00
|
|
|
}
|
2010-09-28 18:17:45 +02:00
|
|
|
},
|
|
|
|
axes: {
|
|
|
|
yaxis: {
|
|
|
|
autoscale: true,
|
|
|
|
min: 0,
|
|
|
|
label: 'Leistung (Watt)',
|
|
|
|
tickOptions: {
|
|
|
|
formatString: '%.3f'
|
|
|
|
},
|
|
|
|
labelRenderer: $.jqplot.CanvasAxisLabelRenderer
|
|
|
|
},
|
|
|
|
xaxis: {
|
|
|
|
autoscale: true,
|
|
|
|
min: myWindowStart,
|
|
|
|
max: myWindowEnd,
|
|
|
|
tickOptions: {
|
|
|
|
formatString: '%d.%m.%y %H:%M',
|
|
|
|
angle: -35
|
|
|
|
},
|
|
|
|
pad: 1,
|
|
|
|
renderer: $.jqplot.DateAxisRenderer,
|
|
|
|
rendererOptions: {
|
|
|
|
tickRenderer: $.jqplot.CanvasAxisTickRenderer
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-10-01 11:23:31 +02:00
|
|
|
// storing entities
|
|
|
|
var entities = new Array;
|
2010-09-29 21:59:49 +02:00
|
|
|
var uuids = new Array;
|
|
|
|
|
|
|
|
// windowEnd parameter for json server
|
2010-09-28 15:44:28 +02:00
|
|
|
var myWindowEnd = new Date().getTime();
|
2010-09-27 00:26:35 +02:00
|
|
|
|
2010-10-01 11:23:31 +02:00
|
|
|
// windowStart parameter for json server (last 24 hours)
|
2010-09-28 15:44:28 +02:00
|
|
|
var myWindowStart = myWindowEnd - 24*60*60*1000;
|
2010-09-27 00:26:35 +02:00
|
|
|
|
|
|
|
// executed on document loaded complete
|
|
|
|
// this is where it all starts...
|
|
|
|
$(document).ready(function() {
|
2010-10-01 23:06:40 +02:00
|
|
|
// parse uuids from cookie
|
2010-10-01 11:23:31 +02:00
|
|
|
uuids = getUUIDs();
|
|
|
|
|
2010-10-01 23:06:40 +02:00
|
|
|
// add optional uuid from url
|
|
|
|
if($.getUrlVar('uuid')) {
|
|
|
|
addUUID($.getUrlVar('uuid'));
|
2010-09-27 00:26:35 +02:00
|
|
|
}
|
2010-10-01 23:06:40 +02:00
|
|
|
console.log('cookie uuids', uuids);
|
2010-09-27 00:26:35 +02:00
|
|
|
|
2010-09-29 21:59:49 +02:00
|
|
|
// start auto refresh timer
|
2010-10-01 11:23:31 +02:00
|
|
|
window.setInterval(refreshWindow, 5000);
|
2010-09-27 00:26:35 +02:00
|
|
|
|
2010-09-29 21:59:49 +02:00
|
|
|
$('#accordion h3').click(function() {
|
|
|
|
$(this).next().toggle('fast');
|
|
|
|
return false;
|
|
|
|
}).next().hide();
|
|
|
|
|
2010-10-01 11:23:31 +02:00
|
|
|
// add new entity to list
|
|
|
|
$('#addEntity button').click(function() {
|
|
|
|
uuids.push($(this).prev().val());
|
|
|
|
loadEntities(uuids);
|
|
|
|
});
|
|
|
|
|
|
|
|
// options
|
|
|
|
$('input[name=trendline]').change(function() {
|
|
|
|
jqOptions.seriesDefaults.trendline.show = $(this).attr('checked');
|
|
|
|
});
|
2010-09-29 21:59:49 +02:00
|
|
|
|
2010-10-01 11:23:31 +02:00
|
|
|
$('input[name=backendUrl]').val(backendUrl);
|
|
|
|
$('input[name=tuples]').val(tuples);
|
|
|
|
|
|
|
|
// load all entity information
|
|
|
|
loadEntities(uuids);
|
2010-09-27 00:36:48 +02:00
|
|
|
});
|