From 4234ae107c3f5fe71b389a52d4d3e217096c7c2b Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sat, 30 Oct 2010 10:42:08 +0200 Subject: [PATCH] removed cookie options loading --- frontend/javascripts/frontend.js | 56 +++++++++++++++----------------- frontend/javascripts/helper.js | 8 +++++ frontend/javascripts/init.js | 18 +++++----- 3 files changed, 44 insertions(+), 38 deletions(-) diff --git a/frontend/javascripts/frontend.js b/frontend/javascripts/frontend.js index 3404ee0..436bad0 100644 --- a/frontend/javascripts/frontend.js +++ b/frontend/javascripts/frontend.js @@ -31,7 +31,10 @@ /** * Initialize the WUI (Web User Interface) */ -vz.initInterface = function() { +vz.wui.init = function() { + // start auto refresh timer + window.setInterval(this.refresh, 5000); + // initialize dropdown accordion $('#accordion h3').click(function() { $(this).next().toggle('fast'); @@ -42,10 +45,23 @@ vz.initInterface = function() { $('button, input[type=button]').button(); // tuple resolution - $('#tuples').val(vz.options.tuples).change(function() { + var tup = $('#tuples'); + tup.val(vz.options.tuples).change(function() { vz.options.tuples = $(this).val(); vz.entities.loadData(); }); + + $('#backendUrl') + .val(vz.options.backendUrl) + .change(function() { + vz.options.backendUrl = $(this).val(); + }); + + $('#refresh') + .attr('checked', vz.options.refresh) + .change(function() { + vz.options.refresh = $(this).val(); + }); // plot rendering $('#rendering_lines') @@ -63,24 +79,12 @@ vz.initInterface = function() { vz.options.plot.series.points.show = $(this).attr('checked'); vz.drawPlot(); }); - - $('#backendUrl') - .val(vz.options.backendUrl) - .change(function() { - vz.options.backendUrl = $(this).val(); - }); - - $('#refresh') - .attr('checked', vz.options.refresh) - .change(function() { - vz.options.refresh = $(this).val(); - }); }; /** * Initialize dialogs */ -vz.initDialogs = function() { +vz.wui.dialogs.init = function() { // initialize dialogs $('#addUUID').dialog({ autoOpen: false, @@ -122,9 +126,9 @@ vz.initDialogs = function() { /** * Bind events to handle plot zooming & panning */ -vz.bindEvents = function() { +vz.wui.initEvents = function() { // bind plot actions - $('#move input[type=image]').click(vz.handleControls); + $('#move input[type=image]').click(vz.wui.handleControls); $('#plot') @@ -158,7 +162,7 @@ vz.bindEvents = function() { /** * Refresh plot with new data */ -vz.refresh = function() { +vz.wui.refresh = function() { if (vz.options.refresh) { var delta = vz.options.plot.xaxis.max - vz.options.plot.xaxis.min; vz.options.plot.xaxis.max = new Date().getTime(); // move plot @@ -170,7 +174,7 @@ vz.refresh = function() { /** * Move & zoom in the plotting area */ -vz.handleControls = function () { +vz.wui.handleControls = function () { var delta = vz.options.plot.xaxis.max - vz.options.plot.xaxis.min; var middle = vz.options.plot.xaxis.min + delta/2; @@ -433,7 +437,7 @@ vz.definitions.get = function(section, iname) { * Error & Exception handling */ -vz.errorDialog = function(error, description, code) { +vz.wui.dialogs.error = function(error, description, code) { if (typeof code != undefined) { error = code + ': ' + error; } @@ -454,14 +458,6 @@ vz.errorDialog = function(error, description, code) { }); }; -vz.exceptionDialog = function(exception) { - vz.errorDialog(exception.type, exception.message, exception.code); +vz.wui.dialogs.exception = function(exception) { + this.error(exception.type, exception.message, exception.code); }; - -var Exception = function(type, message, code) { - return { - type: type, - message: message, - code: code - }; -} diff --git a/frontend/javascripts/helper.js b/frontend/javascripts/helper.js index 17d4566..b4c40a0 100644 --- a/frontend/javascripts/helper.js +++ b/frontend/javascripts/helper.js @@ -42,6 +42,14 @@ function waitAsync(callback, finished, identifier) { }; } +var Exception = function(type, message, code) { + return { + type: type, + message: message, + code: code + }; +} + /* * Array extensions * according to js language specification ECMA 1.6 diff --git a/frontend/javascripts/init.js b/frontend/javascripts/init.js index 0da5dbe..2ccb756 100644 --- a/frontend/javascripts/init.js +++ b/frontend/javascripts/init.js @@ -28,8 +28,13 @@ // volkszaehler.org namespace (holds all data, options and functions for the frontend) // we dont want to pollute the global namespace var vz = { - // entity information & properties + // entity properties + data entities: new Array, + + // web user interface + wui: { + dialogs: { } + }, // known UUIDs in the browser uuids: new Array, @@ -55,12 +60,12 @@ if ($.getUrlVar('debug')) { $(document).ready(function() { // parse uuids & options from cookie vz.uuids.load(); - vz.options.load(); + //vz.options.load(); // initialize user interface - vz.initInterface(); - vz.initDialogs(); - vz.bindEvents(); + vz.wui.init(); + vz.wui.initEvents(); + vz.wui.dialogs.init(); // add optional uuid from url if($.getUrlVar('uuid')) { @@ -71,9 +76,6 @@ $(document).ready(function() { $('#addUUID').dialog('open'); } - // start auto refresh timer - window.setInterval(vz.refresh, 5000); - vz.definitions.load(); vz.entities.loadDetails(); });