From 9c71c78725f6a32d02409a3449277b0c86e96106 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Fri, 10 Dec 2010 22:36:10 +0100 Subject: [PATCH] smaller bugfixes (auto refresh) --- frontend/javascripts/frontend.js | 39 ++++++++++++++++---------------- frontend/javascripts/init.js | 11 +++++---- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/frontend/javascripts/frontend.js b/frontend/javascripts/frontend.js index 33de892..21d9e60 100644 --- a/frontend/javascripts/frontend.js +++ b/frontend/javascripts/frontend.js @@ -78,18 +78,20 @@ vz.wui.init = function() { }); // auto refresh - $('#refresh') - .attr('checked', vz.options.refresh) - .change(function() { - if ($(this).attr('checked')) { - vz.options.refresh = true; - vz.wui.refreshTimeout = window.setTimeout(vz.wui.refresh, vz.options.refreshInterval); - } - else { - vz.options.refresh = false; - window.clearTimeout(vz.wui.refreshTimeout); - } - }); + if (vz.options.refresh) { + $('#refresh').attr('checked', true); + vz.wui.interval = window.setInterval(vz.wui.refresh, vz.options.refreshInterval); + } + $('#refresh').change(function() { + if ($(this).attr('checked')) { + vz.options.refresh = true; + vz.wui.interval = window.setInterval(vz.wui.refresh, vz.options.refreshInterval); + } + else { + vz.options.refresh = false; + window.clearInterval(vz.wui.interval); + } + }); // plot rendering $('#render-lines').attr('checked', (vz.options.render == 'lines')); @@ -156,9 +158,6 @@ vz.wui.refresh = function() { 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(); - - // schedule next refresh - this.refreshTimeout = window.setTimeout(vz.wui.refresh, vz.options.refreshInterval); }; /** @@ -325,7 +324,7 @@ vz.entities.show = function() { treeColumn: 2, clickableNodeNames: true }); - + // load data and show plot vz.entities.loadData(); }; @@ -360,10 +359,10 @@ vz.entities.loadData = function() { if (entity.data.min && entity.data.max && entity.data.min) { $('#entity-' + entity.uuid + ' .min') .text(entity.data.min.value) - .attr('title', $.plot.formatDate(new Date(entity.data.min.timestamp), vz.options.plot.xaxis.timeformat, vz.options.plot.xaxis.monthNames)); + .attr('title', $.plot.formatDate(new Date(entity.data.min.timestamp), '%d. %b %h:%M:%S', vz.options.plot.xaxis.monthNames)); $('#entity-' + entity.uuid + ' .max') .text(entity.data.max.value) - .attr('title', $.plot.formatDate(new Date(entity.data.max.timestamp), vz.options.plot.xaxis.timeformat, vz.options.plot.xaxis.monthNames)); + .attr('title', $.plot.formatDate(new Date(entity.data.max.timestamp), '%d. %b %h:%M:%S', vz.options.plot.xaxis.monthNames)); $('#entity-' + entity.uuid + ' .average').text(entity.data.average); } }, vz.drawPlot, 'data') @@ -373,8 +372,8 @@ vz.entities.loadData = function() { }; vz.wui.updateHeadline = function() { - var from = $.plot.formatDate(new Date(vz.options.plot.xaxis.min + vz.options.timezoneOffset), vz.options.plot.xaxis.timeformat, vz.options.plot.xaxis.monthNames); - var to = $.plot.formatDate(new Date(vz.options.plot.xaxis.max + vz.options.timezoneOffset), vz.options.plot.xaxis.timeformat, vz.options.plot.xaxis.monthNames); + var from = $.plot.formatDate(new Date(vz.options.plot.xaxis.min + vz.options.timezoneOffset), '%d. %b %h:%M:%S', vz.options.plot.xaxis.monthNames); + var to = $.plot.formatDate(new Date(vz.options.plot.xaxis.max + vz.options.timezoneOffset), '%d. %b %h:%M:%S', vz.options.plot.xaxis.monthNames); $('#title').text(from + ' - ' + to); } diff --git a/frontend/javascripts/init.js b/frontend/javascripts/init.js index 7b216ed..26d3dbf 100644 --- a/frontend/javascripts/init.js +++ b/frontend/javascripts/init.js @@ -59,20 +59,21 @@ $(document).ready(function() { vz.drawPlot(); }); - // initialize user interface - vz.wui.init(); - vz.wui.initEvents(); - vz.wui.dialogs.init(); - // parse uuids & options from cookie vz.definitions.load(); vz.uuids.load(); vz.options.load(); vz.parseUrlVars(); + // initialize user interface + vz.wui.init(); + vz.wui.initEvents(); + vz.wui.dialogs.init(); + if (vz.uuids.length == 0) { $('#entity-add').dialog('open'); } + // load entity details & properties vz.entities.loadDetails(); });