diff --git a/htdocs/frontend/javascripts/entity.js b/htdocs/frontend/javascripts/entity.js index d04749e..729b554 100644 --- a/htdocs/frontend/javascripts/entity.js +++ b/htdocs/frontend/javascripts/entity.js @@ -192,17 +192,13 @@ Entity.prototype.getRow = function() { }; Entity.prototype.loadData = function() { - //var delta = vz.options.plot.xaxis.max - vz.options.plot.xaxis.min; - //var offset = delta * 0.1; - var offset = 1000*30*60; // load additional data to avoid paddings - return vz.load({ controller: 'data', identifier: this.uuid, context: this, data: { - from: Math.floor(vz.options.plot.xaxis.min - offset), // TODO fuzy-logic to get enough data - to: Math.ceil(vz.options.plot.xaxis.max + offset), + from: Math.floor(vz.options.plot.xaxis.min), + to: Math.ceil(vz.options.plot.xaxis.max), tuples: vz.options.tuples }, success: function(json) { @@ -231,7 +227,11 @@ Entity.prototype.loadData = function() { ); } if (this.cost !== undefined) { - $('#entity-' + this.uuid + ' .cost').text(vz.wui.formatNumber(this.cost * this.data.consumption) + ' €'); + var delta = this.data.to - this.data.from; + + $('#entity-' + this.uuid + ' .cost') + .text(vz.wui.formatNumber(this.cost * this.data.consumption) + ' €') + .attr(vz.wui.formatNumber(this.cost * this.data.consumption * (60*60*24*265/delta))); } } else { // no data available, clear table diff --git a/htdocs/frontend/javascripts/jquery/jquery-extensions.js b/htdocs/frontend/javascripts/jquery/jquery-extensions.js index c461e0c..7136645 100644 --- a/htdocs/frontend/javascripts/jquery/jquery-extensions.js +++ b/htdocs/frontend/javascripts/jquery/jquery-extensions.js @@ -4,7 +4,7 @@ * @author Florian Ziegler * @author Justin Otherguy * @author Steffen Vogel - * @copyright Copyright (c) 2010, The volkszaehler.org project + * @copyright Copyright (c) 2011, The volkszaehler.org project * @package default * @license http://opensource.org/licenses/gpl-license.php GNU Public License */ @@ -31,8 +31,8 @@ $.extend( { getUrlParams : function() { var vars = {}, hash; - var hashes = window.location.href.slice( - window.location.href.indexOf('?') + 1).split('&'); + var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); + for (var i = 0; i < hashes.length; i++) { hash = hashes[i].split('='); switch (typeof vars[hash[0]]) {