vzlogger/frontend/javascripts/init.js

87 lines
2.2 KiB
JavaScript
Raw Normal View History

2010-09-27 01:33:49 +02:00
/**
* Initialization and configuration of frontend
2010-09-27 01:33:49 +02:00
*
* @author Florian Ziegler <fz@f10-home.de>
* @author Justin Otherguy <justin@justinotherguy.org>
* @author Steffen Vogel <info@steffenvogel.de>
* @copyright Copyright (c) 2010, The volkszaehler.org project
* @package default
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/
/*
* This file is part of volkzaehler.org
*
* volkzaehler.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* volkzaehler.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with volkszaehler.org. If not, see <http://www.gnu.org/licenses/>.
*/
// volkszaehler.org namespace (holds all data, options and functions for the frontend)
// we dont want to pollute the global namespace
var vz = {
2010-10-30 10:42:08 +02:00
// entity properties + data
entities: new Array,
2010-10-30 10:42:08 +02:00
// web user interface
wui: {
dialogs: { }
},
2010-10-04 21:10:58 +02:00
// known UUIDs in the browser
uuids: new Array,
2010-10-04 21:10:58 +02:00
// flot instance
plot: { },
2010-10-04 21:10:58 +02:00
// definitions of entities & properties
// for validation, translation etc..
2010-10-06 06:34:36 +02:00
definitions: { },
// options loaded from cookies in options.js
options: { }
2010-09-28 18:17:45 +02:00
};
// check for debugging & load firebug
if ($.getUrlVar('debug')) {
$.getScript('javascripts/firebug-lite.js');
}
// executed on document loaded complete
// this is where it all starts...
$(document).ready(function() {
// parse uuids & options from cookie
vz.uuids.load();
2010-10-30 10:42:08 +02:00
//vz.options.load();
// initialize user interface
2010-10-30 10:42:08 +02:00
vz.wui.init();
vz.wui.initEvents();
vz.wui.dialogs.init();
2010-10-01 23:06:40 +02:00
// add optional uuid from url
if($.getUrlVar('uuid')) {
2010-10-04 21:10:58 +02:00
vz.uuids.add($.getUrlVar('uuid'));
}
2010-10-04 22:37:29 +02:00
if (vz.uuids.length == 0) {
2010-10-06 06:34:36 +02:00
$('#addUUID').dialog('open');
2010-10-04 22:37:29 +02:00
}
2010-10-06 06:34:36 +02:00
vz.definitions.load();
vz.entities.loadDetails();
});
$(window).unload(function() {
vz.uuids.save();
vz.options.save();
});