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
|
|
|
/*
|
|
|
|
* Constants
|
|
|
|
*/
|
|
|
|
const backendUrl = '../backend/index.php';
|
|
|
|
const jqOptions = {
|
|
|
|
title: 'volkszaehler.org',
|
|
|
|
series: [],
|
|
|
|
cursor: {
|
|
|
|
zoom: true,
|
|
|
|
showTooltip: true,
|
|
|
|
constrainZoomTo: 'x'
|
|
|
|
},
|
|
|
|
seriesDefaults: {
|
|
|
|
lineWidth: 1,
|
|
|
|
showMarker: false
|
|
|
|
},
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Variables
|
|
|
|
*/
|
2010-09-27 00:26:35 +02:00
|
|
|
var myUUID = '';
|
2010-09-28 18:17:45 +02:00
|
|
|
var uuids = $.parseJSON($.cookie('uuids'));
|
|
|
|
|
|
|
|
if($.getUrlVar('uuid')) {
|
2010-09-27 01:33:49 +02:00
|
|
|
myUUID = $.getUrlVar('uuid');
|
2010-09-28 18:17:45 +02:00
|
|
|
uuids.push($.getUrlVar('uuid'));
|
|
|
|
}
|
2010-09-27 00:26:35 +02:00
|
|
|
|
|
|
|
// storing json data
|
2010-09-28 18:17:45 +02:00
|
|
|
var json;
|
2010-09-27 00:26:35 +02:00
|
|
|
|
2010-09-28 15:44:28 +02:00
|
|
|
//windowEnd parameter for json server
|
|
|
|
var myWindowEnd = new Date().getTime();
|
2010-09-27 00:26:35 +02:00
|
|
|
|
2010-09-28 15:44:28 +02:00
|
|
|
// windowStart parameter for json server
|
|
|
|
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-09-28 16:25:09 +02:00
|
|
|
// initialization of user interface
|
|
|
|
$('#accordion h3').click(function() {
|
2010-09-28 18:17:45 +02:00
|
|
|
$(this).next().toggle('fast');
|
2010-09-28 16:25:09 +02:00
|
|
|
return false;
|
|
|
|
}).next().hide();
|
2010-09-28 18:17:45 +02:00
|
|
|
|
|
|
|
$('#refreshInterval').slider();
|
2010-09-28 16:25:09 +02:00
|
|
|
|
|
|
|
|
2010-09-27 00:26:35 +02:00
|
|
|
// resize chart area for low resolution displays
|
|
|
|
// works fine with HTC hero
|
|
|
|
// perhaps you have to reload after display rotation
|
2010-09-27 01:33:49 +02:00
|
|
|
if($(window).width() < 800) {
|
2010-09-28 18:17:45 +02:00
|
|
|
$('#chart').animate({
|
2010-09-28 15:44:28 +02:00
|
|
|
width: $(window).width() - 40,
|
|
|
|
height: $(window).height() - 3,
|
|
|
|
}, 0);
|
2010-09-27 00:26:35 +02:00
|
|
|
}
|
|
|
|
|
2010-09-28 18:17:45 +02:00
|
|
|
// load all entity information
|
|
|
|
loadEntities();
|
|
|
|
|
|
|
|
window.setInterval(refresh, 5000);
|
2010-09-27 00:26:35 +02:00
|
|
|
|
2010-09-28 16:25:09 +02:00
|
|
|
// load data and show plot
|
2010-09-27 00:26:35 +02:00
|
|
|
getData();
|
2010-09-27 00:36:48 +02:00
|
|
|
});
|