/* * Copyright (C) 2014 * This file is part of WvS VPlan. * * WvS VPlan is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program 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 Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ function setDNT(dnt){ _paq.push(['setDoNotTrack', dnt]) window.localStorage.setItem('dnt', dnt); $('#disclaimerpopup').popup('close'); } function track(what){ _paq.push(['setCustomUrl', what]); _paq.push(['trackPageView', what]); } function trackPlan(vdate){ track('ui/tab/plan'); track('plan/' + vdate.format('YYYY/MM/DD')); } document.addEventListener('pause', function(){ track('event/pause'); }); document.addEventListener('resume', function(){ track('event/resume'); }); // Login-Popup beim Start document.addEventListener('deviceready', function(){ _paq.push(['setCustomVariable', 1, 'Modell', device.model, 'visit']); _paq.push(['setCustomVariable', 2, 'Version', device.version, 'visit']); track('event/load'); var dnt = window.localStorage.getItem('dnt'); if(dnt == 'undefined' || dnt == null || dnt == ''){ setTimeout(function(){ $('#lnkdisclaimer').click(); }, 2000); }else{ fillform(); load(); trylogin(); } }, false); /* der Loader wird nur angezeigt, wenn das Popup zu ist */ $('#loginpopup').on('popupafteropen', function(){ $.mobile.loading('hide'); }); $('#disclaimerpopup').on('popupafterclose', function(){ fillform(); load(); trylogin(); }); /* füllt die Loginform mit gespeicherten Werten */ function fillform(){ var username = window.localStorage.getItem('username'); if(username !== 'undefined' && username != null && username != ''){ $('#username').val(username); } var password = window.localStorage.getItem('password'); if(password !== 'undefined' && password != null && password != ''){ $('#password').val(password); } } /* benachrichtigt den Benutzer an vdate mit msg */ var notifications = 0; function addNotification(vdate, msg){ vdate.subtract('days', 1); // Ein Tag vorher, 18 Uhr benachrichtigen var secondsUntilDate = moment.diff(vdate, 'seconds'); if(secondsUntilDate > 0){ localNotification.add(++notifications, { seconds: secondsUntilDate, message: msg, badge: 0}); console.log('Benachrichtigung hinzugefügt: ' + vdate.format('DD.MM. hh:mm') + '; ' + msg); } } /* zeigt einen Button an, mit dem die Vertretung geteilt werden kann */ function addSocialButton(vdate, msg, $div){ if(moment().isBefore(vdate)){ var datestr = vdate.format('dddd.'); var btn = $('