/** * Frontend configuration * * @author Florian Ziegler * @author Justin Otherguy * @author Steffen Vogel * @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 . */ // default time interval to show vz.options = { language: 'de', backendUrl: '../backend.php', // TODO default backend, store backend urls in cookies tuples: 300, precission: 2, // TODO update from backend capabilities? render: 'lines', refresh: false, defaultInterval: 24*60*60*1000, // 1 day timezoneOffset: -(new Date().getTimezoneOffset() * 60000) // TODO add option with timezone dropdown }; vz.options.plot = { colors: ['#579D1C', '#7E0021', '#FFD320', '#FF420E', '#004586', '#0084D1', '#C5000B', '#FF950E', '#4B1F6F', '#AECF00', '#314004', '#83CAFF'], series: { shadowSize: 0, points: { radius: 1, //symbol: 'square' symbol: function(ctx, x, y, radius, shadow) { // just draw simple pixels ctx.lineWidth = 1; ctx.strokeRect(x-1, y-1, 2, 2); } } }, legend: { show: false }, xaxis: { mode: 'time', max: new Date().getTime(), // timeinterval to request min: new Date().getTime() - vz.options.defaultInterval, timeformat: '%d. %b %h:%M', monthNames: ['Jan', 'Feb', 'Mär', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez'], tickFormatter: function(val, axis) { var date = new Date(val + vz.options.timezoneOffset); /* add timezone offset */ return $.plot.formatDate(date, this.timeformat, this.monthNames); } }, yaxis: { min: 0, max: null }, selection: { mode: 'x' }, crosshair: { mode: 'x' }, grid: { hoverable: true, autoHighlight: false } } vz.options.save = function() { for (var key in vz.options) { if (vz.options.hasOwnProperty(key) && typeof vz.options[key] != 'function' && typeof vz.options[key] != 'object' && typeof vz.options[key] != 'undefined' ) { $.setCookie('vz_' + key, vz.options[key]); } } }; vz.options.load = function() { for (var key in this) { var value = $.getCookie('vz_' + key); if (value !== undefined) { switch(typeof this[key]) { case 'string': this[key] = value; break; case 'number': this[key] = Number(value); break; case 'boolean': this[key] = (value == 'true'); break; } } } };