diff --git a/htdocs/frontend/javascripts/frontend.js b/htdocs/frontend/javascripts/frontend.js index 6d0dcf6..b03d3f5 100644 --- a/htdocs/frontend/javascripts/frontend.js +++ b/htdocs/frontend/javascripts/frontend.js @@ -92,16 +92,16 @@ vz.wui.init = function() { // auto refresh if (vz.options.refresh) { $('#refresh').attr('checked', true); - vz.wui.interval = window.setInterval(vz.wui.refresh, vz.options.refreshInterval); + vz.wui.timeout = window.setTimeout(vz.wui.refresh, 3000); } $('#refresh').change(function() { if ($(this).attr('checked')) { vz.options.refresh = true; - vz.wui.interval = window.setInterval(vz.wui.refresh, vz.options.refreshInterval); + vz.wui.timeout = window.setTimeout(vz.wui.refresh, 3000); } else { vz.options.refresh = false; - window.clearInterval(vz.wui.interval); + window.clearTimeout(vz.wui.timeout); } }); @@ -167,9 +167,12 @@ vz.wui.initEvents = function() { */ vz.wui.refresh = function() { var delta = vz.options.plot.xaxis.max - vz.options.plot.xaxis.min; + vz.options.plot.xaxis.max = new Date().getTime(); // move plot vz.options.plot.xaxis.min = vz.options.plot.xaxis.max - delta; // move plot vz.entities.loadData(); + + vz.wui.timeout = window.setTimeout(vz.wui.refresh, (delta / 100 < 3000) ? 3000 : delta / 100); // TODO update timeout after zooming }; /** @@ -527,7 +530,7 @@ vz.wui.dialogs.error = function(error, description, code) { modal: true, buttons: { Ok: function() { - $( this ).dialog( "close" ); + $(this).dialog('close'); } } }); diff --git a/htdocs/frontend/javascripts/helper.js b/htdocs/frontend/javascripts/helper.js index a5f2da1..20ff51a 100644 --- a/htdocs/frontend/javascripts/helper.js +++ b/htdocs/frontend/javascripts/helper.js @@ -80,12 +80,10 @@ Array.prototype.clear = function() { Array.prototype.unique = function () { var r = new Array(); - this.each(function(key, value) { if (!r.contains(value)) { r.push(value); } }); - return r; } diff --git a/htdocs/frontend/javascripts/options.js b/htdocs/frontend/javascripts/options.js index b3d5a42..f61cf10 100644 --- a/htdocs/frontend/javascripts/options.js +++ b/htdocs/frontend/javascripts/options.js @@ -32,9 +32,8 @@ vz.options = { rounding: 1, render: 'lines', refresh: false, - refreshInterval: 5*1000, // 5 secs defaultInterval: 24*60*60*1000, // 1 day - timezoneOffset: -(new Date().getTimezoneOffset() * 60*1000) // TODO add option with timezone dropdown + timezoneOffset: -(new Date().getTimezoneOffset() * 60000) // TODO add option with timezone dropdown }; vz.options.plot = {