From 49755d111343f112ca0b0d8ed1f0e5bc0bd4f72e Mon Sep 17 00:00:00 2001 From: Justin Otherguy Date: Sat, 25 Sep 2010 17:57:10 +0200 Subject: [PATCH 1/4] removed unused function generateAxisTicks --- frontend/index.html | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/frontend/index.html b/frontend/index.html index 318b72b..83ef266 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -407,19 +407,6 @@ function showChart() { } -function generateAxisTicks() { - - var data_grouped_time = getEmptyGroupArray(); - var ticks = new Array(); - - for(var timestamp in data_grouped_time) { - var time = new Date(timestamp*1000); - ticks.push(time.getDate()+'.'+(time.getMonth()+1)+'.'+' '+time.getHours()+':00'); - } - - return ticks; -} - From 50b8e04d9d8d9f17df0a2e9d25947397eb73f418 Mon Sep 17 00:00:00 2001 From: Justin Otherguy Date: Sat, 25 Sep 2010 17:58:26 +0200 Subject: [PATCH 2/4] removed unused function checkRegexp --- frontend/index.html | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/frontend/index.html b/frontend/index.html index 83ef266..b8c1bbe 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -233,18 +233,6 @@ $(document).ready(function() { } } - function checkRegexp(o,regexp,n) { - - if ( !( regexp.test( o.val() ) ) ) { - o.addClass('ui-state-error'); - updateTips(n); - return false; - } else { - return true; - } - } - - $("#dialog-form").dialog({ autoOpen: false, height: 300, From ab519bf667ec710ea14a9e605fdc7009a22ed029 Mon Sep 17 00:00:00 2001 From: Justin Otherguy Date: Sat, 25 Sep 2010 18:15:39 +0200 Subject: [PATCH 3/4] removed unused function getEmptyGroupArray --- frontend/javascript/smartmeter.js | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/frontend/javascript/smartmeter.js b/frontend/javascript/smartmeter.js index 2197a17..a85c20f 100644 --- a/frontend/javascript/smartmeter.js +++ b/frontend/javascript/smartmeter.js @@ -18,35 +18,6 @@ * http://www.gnu.org/copyleft/gpl.html */ -// return an array with timestamps of e.g. -// 2010-05-01 00:00:00, 2010-05-01 01:00, 2010-05-01 02:00 for grouping=hour -// between windowStart and windowEnd of json response -function getEmptyGroupArray() { - var empty_array = new Object(); - - var iterator = getGroupedTimestamp(myWindowStart); - //$('#debug').empty().append('start:'+myWindowStart+'end:'+myWindowEnd); - - if(myWindowStart < myWindowEnd && iterator < myWindowEnd) { - var i=0; - while(iterator < myWindowEnd) { - i++; - - empty_array[iterator] = 0; - - var iteratorDate = new Date(iterator); - //$('#debug').append('#'+i+':'+iteratorDate+'
'); - iteratorDate.setDate(iteratorDate.getDate()+1); - // very bad bug: infinity loop for summer winter change - if(i==750) return empty_array; - - iterator = iteratorDate.getTime(); - } - } - - return empty_array -} - function calcMyWindowStart() { var myWindowStart = new Date(myWindowEnd); From 6ea28198e63664da94f92255c634e69d3e0f68c3 Mon Sep 17 00:00:00 2001 From: Justin Otherguy Date: Sat, 25 Sep 2010 18:18:08 +0200 Subject: [PATCH 4/4] relocated some js functions from frontend/index.html to frontend/javascript/smartmeter.js --- frontend/index.html | 115 ------------------------------ frontend/javascript/smartmeter.js | 115 ++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+), 115 deletions(-) diff --git a/frontend/index.html b/frontend/index.html index b8c1bbe..2f1a88c 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -279,121 +279,6 @@ $(document).ready(function() { }); -function loadChannelList() { - - - $('#debug').append('json'); - // 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(''); - - // 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;ijson'); - // 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(); - -} diff --git a/frontend/javascript/smartmeter.js b/frontend/javascript/smartmeter.js index a85c20f..0405e03 100644 --- a/frontend/javascript/smartmeter.js +++ b/frontend/javascript/smartmeter.js @@ -52,3 +52,118 @@ function getGroupedTimestamp(timestamp) { return (new Date(year,month,day,hours,minutes)).getTime(); } +function loadChannelList() { + + + $('#debug').append('json'); + // 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(''); + + // 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;ijson'); + // 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(); + +}