/** * Javascript functions for the frontend * * @author Florian Ziegler * @author Justin Otherguy * @author Steffen Vogel * @copyright Copyright (c) 2011, 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 . */ /** * Initialize the WUI (Web User Interface) */ vz.wui.init = function() { // initialize dropdown accordion $('#accordion h3').click(function() { $(this).next().toggle('fast'); return false; }).next().hide(); $('#entity-list').show(); // open entity list by default // buttons $('button, input[type=button],[type=image],[type=submit]').button(); $('button[name=options-save]').click(vz.options.save); $('button[name=entity-add]').click(this.dialogs.init); $('#permalink').click(function() { window.location = vz.wui.getPermalink(); }); $('#snapshot').click(function() { window.location = vz.wui.getSnaplink(); }).hide(); // bind plot actions $('#controls button').click(this.handleControls); $('#controls').buttonset(); // tuple resolution vz.options.tuples = Math.round($('#flot').width() / 4); $('#tuples').val(vz.options.tuples).change(function() { vz.options.tuples = $(this).val(); vz.entities.loadData().done(vz.wui.drawPlot); }); // middleware address $('#middleware-url') .val(vz.options.middlewareUrl) .change(function() { vz.options.middlewareUrl = $(this).val(); }); // auto refresh if (vz.options.refresh) { $('#refresh').attr('checked', true); vz.wui.setTimeout(); } $('#refresh').change(function() { if (vz.options.refresh = $(this).attr('checked')) { vz.wui.refresh(); // refresh once vz.wui.setTimeout(); } else { vz.wui.clearTimeout(); } }); // plot rendering $('#render-lines').attr('checked', (vz.options.render == 'lines')); $('#render-points').attr('checked', (vz.options.render == 'points')); $('input[name=render][type=radio]').change(function() { if ($(this).attr('checked')) { vz.options.render = $(this).val(); vz.wui.drawPlot(); } }); }; /** * Initialize dialogs */ vz.wui.dialogs.init = function() { // initialize dialogs $('#entity-add.dialog').dialog({ title: 'Kanal hinzufügen', width: 530, resizable: false }); $('#entity-add.dialog > div').tabs(); // load public entities vz.load({ controller: 'entity', success: function(json) { if (json.entities.length > 0) { json.entities.each(function(index, entity) { $('#entity-subscribe-public select#public').append( $('