relocated some js functions from frontend/index.html to frontend/javascript/smartmeter.js
This commit is contained in:
parent
ab519bf667
commit
6ea28198e6
2 changed files with 115 additions and 115 deletions
|
@ -279,121 +279,6 @@ $(document).ready(function() {
|
|||
});
|
||||
|
||||
|
||||
function loadChannelList() {
|
||||
|
||||
|
||||
$('#debug').append('<a href="../backend/index.php/data/"' + myUUID + '"/channel">json</a>');
|
||||
// load json data
|
||||
$.getJSON("../backend/index.php/data/" + myUUID + {format: 'json'});
|
||||
|
||||
}
|
||||
|
||||
function autoReload() {
|
||||
|
||||
// call getData if autoReload checkbox is active
|
||||
if(f.autoReload.checked == true) {
|
||||
myWindowEnd = getGroupedTimestamp((new Date()).getTime());
|
||||
getData();
|
||||
}
|
||||
}
|
||||
|
||||
function moveWindow(mode) {
|
||||
|
||||
if(mode == 'last')
|
||||
myWindowEnd = (new Date()).getTime();
|
||||
if(mode == 'back') {
|
||||
myWindowEnd = myWindowStart;
|
||||
}
|
||||
if(mode == 'forward') {
|
||||
myWindowEnd += (myWindowEnd-myWindowStart);
|
||||
}
|
||||
|
||||
getData();
|
||||
}
|
||||
|
||||
|
||||
function getData() {
|
||||
|
||||
/*
|
||||
if(f.ids.length>0)
|
||||
$('#loading').empty().html('<img src="images/ladebild.gif" />');
|
||||
|
||||
// list of channel ids, comma separated
|
||||
ids_parameter = "";
|
||||
|
||||
if(typeof f.ids.length == 'undefined') { // only one channel
|
||||
ids_parameter = f.ids.value;
|
||||
}
|
||||
else { // more than one channel
|
||||
for(i=0;i<f.ids.length;i++) {
|
||||
if(f.ids[i].checked == 1) {
|
||||
ids_parameter += f.ids[i].value + ",";
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
// calcMyWindowStart
|
||||
myWindowStart = calcMyWindowStart();
|
||||
|
||||
$('#debug').append('<a href="../backend/index.php/data/'+myUUID+'/format/json/from/'+myWindowStart+'/to/'+myWindowEnd+'">json</a>');
|
||||
// load json data with given time window
|
||||
//$.getJSON("../backend/index.php/data/" + myUUID + '/format/json/from/'+myWindowStart+'/to/'+myWindowEnd, function(j){
|
||||
$.getJSON("../backend/index.php/data/" + myUUID + '.json?from='+myWindowStart+'&to='+myWindowEnd, function(j){
|
||||
data = j;
|
||||
$('#debug').empty().append(data.toSource());
|
||||
// then show/reload the chart
|
||||
//if(data.channels.length > 0 && data.channels[0].pulses.length > 0)
|
||||
showChart();
|
||||
$('#loading').empty();
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function showChart() {
|
||||
|
||||
var jqData = new Array();
|
||||
var series_chart = new Array();
|
||||
|
||||
$('#ChartInfo').hide();
|
||||
$('#ChartPlot').show();
|
||||
|
||||
jqOptions = {
|
||||
legend:{show:true},
|
||||
series:[],
|
||||
cursor:{zoom:true, showTooltip:true,constrainZoomTo:'x'},
|
||||
seriesDefaults:{lineWidth:1,showMarker:false}}
|
||||
|
||||
// stack plot seiries if add channels is active
|
||||
if(f.stackChannels.checked == true) {
|
||||
jqOptions.stackSeries = true;
|
||||
jqOptions.seriesDefaults.fill = true;
|
||||
jqOptions.seriesDefaults.showShadow = false;
|
||||
}
|
||||
|
||||
// legend entries
|
||||
for( uuid in data.channels ) {
|
||||
jqOptions.series.push({label:data.channels[uuid]['description']});
|
||||
}
|
||||
|
||||
EformatString = '%d.%m.%y %H:%M';
|
||||
|
||||
// power (moving average) gray line
|
||||
for( uuid in data.data ) {
|
||||
jqData.push(data.data[uuid]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
jqOptions.axes = {
|
||||
yaxis:{autoscale:true, min:0, label:"Leistung (Watt)", tickOptions:{formatString:'%.3f'},labelRenderer: $.jqplot.CanvasAxisLabelRenderer},
|
||||
xaxis:{autoscale:true, min:calcMyWindowStart(), max:myWindowEnd, tickOptions:{formatString:EformatString,angle:-30},pad:1, renderer:$.jqplot.DateAxisRenderer,rendererOptions:{tickRenderer:$.jqplot.CanvasAxisTickRenderer}},
|
||||
};
|
||||
|
||||
chart = $.jqplot("ChartDIV",jqData,jqOptions);
|
||||
chart.replot();
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
|
|
@ -52,3 +52,118 @@ function getGroupedTimestamp(timestamp) {
|
|||
return (new Date(year,month,day,hours,minutes)).getTime();
|
||||
}
|
||||
|
||||
function loadChannelList() {
|
||||
|
||||
|
||||
$('#debug').append('<a href="../backend/index.php/data/"' + myUUID + '"/channel">json</a>');
|
||||
// load json data
|
||||
$.getJSON("../backend/index.php/data/" + myUUID + {format: 'json'});
|
||||
|
||||
}
|
||||
|
||||
function autoReload() {
|
||||
|
||||
// call getData if autoReload checkbox is active
|
||||
if(f.autoReload.checked == true) {
|
||||
myWindowEnd = getGroupedTimestamp((new Date()).getTime());
|
||||
getData();
|
||||
}
|
||||
}
|
||||
|
||||
function moveWindow(mode) {
|
||||
|
||||
if(mode == 'last')
|
||||
myWindowEnd = (new Date()).getTime();
|
||||
if(mode == 'back') {
|
||||
myWindowEnd = myWindowStart;
|
||||
}
|
||||
if(mode == 'forward') {
|
||||
myWindowEnd += (myWindowEnd-myWindowStart);
|
||||
}
|
||||
|
||||
getData();
|
||||
}
|
||||
|
||||
|
||||
function getData() {
|
||||
|
||||
/*
|
||||
if(f.ids.length>0)
|
||||
$('#loading').empty().html('<img src="images/ladebild.gif" />');
|
||||
|
||||
// list of channel ids, comma separated
|
||||
ids_parameter = "";
|
||||
|
||||
if(typeof f.ids.length == 'undefined') { // only one channel
|
||||
ids_parameter = f.ids.value;
|
||||
}
|
||||
else { // more than one channel
|
||||
for(i=0;i<f.ids.length;i++) {
|
||||
if(f.ids[i].checked == 1) {
|
||||
ids_parameter += f.ids[i].value + ",";
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
// calcMyWindowStart
|
||||
myWindowStart = calcMyWindowStart();
|
||||
|
||||
$('#debug').append('<a href="../backend/index.php/data/'+myUUID+'/format/json/from/'+myWindowStart+'/to/'+myWindowEnd+'">json</a>');
|
||||
// load json data with given time window
|
||||
//$.getJSON("../backend/index.php/data/" + myUUID + '/format/json/from/'+myWindowStart+'/to/'+myWindowEnd, function(j){
|
||||
$.getJSON("../backend/index.php/data/" + myUUID + '.json?from='+myWindowStart+'&to='+myWindowEnd, function(j){
|
||||
data = j;
|
||||
$('#debug').empty().append(data.toSource());
|
||||
// then show/reload the chart
|
||||
//if(data.channels.length > 0 && data.channels[0].pulses.length > 0)
|
||||
showChart();
|
||||
$('#loading').empty();
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function showChart() {
|
||||
|
||||
var jqData = new Array();
|
||||
var series_chart = new Array();
|
||||
|
||||
$('#ChartInfo').hide();
|
||||
$('#ChartPlot').show();
|
||||
|
||||
jqOptions = {
|
||||
legend:{show:true},
|
||||
series:[],
|
||||
cursor:{zoom:true, showTooltip:true,constrainZoomTo:'x'},
|
||||
seriesDefaults:{lineWidth:1,showMarker:false}}
|
||||
|
||||
// stack plot seiries if add channels is active
|
||||
if(f.stackChannels.checked == true) {
|
||||
jqOptions.stackSeries = true;
|
||||
jqOptions.seriesDefaults.fill = true;
|
||||
jqOptions.seriesDefaults.showShadow = false;
|
||||
}
|
||||
|
||||
// legend entries
|
||||
for( uuid in data.channels ) {
|
||||
jqOptions.series.push({label:data.channels[uuid]['description']});
|
||||
}
|
||||
|
||||
EformatString = '%d.%m.%y %H:%M';
|
||||
|
||||
// power (moving average) gray line
|
||||
for( uuid in data.data ) {
|
||||
jqData.push(data.data[uuid]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
jqOptions.axes = {
|
||||
yaxis:{autoscale:true, min:0, label:"Leistung (Watt)", tickOptions:{formatString:'%.3f'},labelRenderer: $.jqplot.CanvasAxisLabelRenderer},
|
||||
xaxis:{autoscale:true, min:calcMyWindowStart(), max:myWindowEnd, tickOptions:{formatString:EformatString,angle:-30},pad:1, renderer:$.jqplot.DateAxisRenderer,rendererOptions:{tickRenderer:$.jqplot.CanvasAxisTickRenderer}},
|
||||
};
|
||||
|
||||
chart = $.jqplot("ChartDIV",jqData,jqOptions);
|
||||
chart.replot();
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue