2010-09-27 01:33:49 +02:00
|
|
|
/**
|
2010-10-04 03:29:12 +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/>.
|
|
|
|
*/
|
2010-09-27 00:26:35 +02:00
|
|
|
|
2010-10-28 01:31:44 +02:00
|
|
|
// volkszaehler.org namespace (holds all data, options and functions for the frontend)
|
|
|
|
// we dont want to pollute the global namespace
|
2010-10-02 18:12:55 +02:00
|
|
|
var vz = {
|
2010-10-30 10:42:08 +02:00
|
|
|
// entity properties + data
|
2010-10-02 18:12:55 +02:00
|
|
|
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
|
2010-10-02 18:12:55 +02:00
|
|
|
uuids: new Array,
|
2010-10-04 21:10:58 +02:00
|
|
|
|
2010-10-28 01:31:44 +02:00
|
|
|
// flot instance
|
|
|
|
plot: { },
|
2010-10-04 21:10:58 +02:00
|
|
|
|
2011-03-07 17:31:28 +01:00
|
|
|
// debugging and runtime information from backend
|
|
|
|
capabilities: {
|
|
|
|
definitions: { } // definitions of entities & properties
|
|
|
|
},
|
2010-10-28 01:31:44 +02:00
|
|
|
|
|
|
|
// options loaded from cookies in options.js
|
|
|
|
options: { }
|
2010-09-28 18:17:45 +02:00
|
|
|
};
|
|
|
|
|
2010-09-27 00:26:35 +02:00
|
|
|
// executed on document loaded complete
|
|
|
|
// this is where it all starts...
|
|
|
|
$(document).ready(function() {
|
2010-11-07 23:25:14 +01:00
|
|
|
$(window).resize(function() {
|
|
|
|
vz.options.tuples = Math.round($('#flot').width() / 3);
|
|
|
|
$('#tuples').val(vz.options.tuples);
|
|
|
|
vz.drawPlot();
|
|
|
|
});
|
2010-11-07 23:08:08 +01:00
|
|
|
|
2011-03-07 17:31:28 +01:00
|
|
|
vz.uuids.load(); // load uuids from cookie
|
|
|
|
vz.options.load(); // load options from cookie
|
|
|
|
vz.parseUrlParams(); // parse additional url params (new uuid etc..)
|
2010-12-10 22:13:19 +01:00
|
|
|
|
2010-12-10 22:36:10 +01:00
|
|
|
// initialize user interface
|
|
|
|
vz.wui.init();
|
|
|
|
vz.wui.initEvents();
|
|
|
|
vz.wui.dialogs.init();
|
|
|
|
|
2010-10-04 22:37:29 +02:00
|
|
|
if (vz.uuids.length == 0) {
|
2010-12-10 22:13:19 +01:00
|
|
|
$('#entity-add').dialog('open');
|
2010-10-04 22:37:29 +02:00
|
|
|
}
|
|
|
|
|
2011-03-07 17:31:28 +01:00
|
|
|
// starting with request to backend:
|
|
|
|
// capabiltities -> entities -> data
|
|
|
|
// try to follow the callbacks ;)
|
|
|
|
vz.capabilities.load(); // load properties, entity types and other capabilities from backend
|
2010-09-27 00:36:48 +02:00
|
|
|
});
|