From 74c5e46910fa66da0e8f11ed9ec1f8e0df3b63d7 Mon Sep 17 00:00:00 2001 From: schneefux Date: Wed, 11 Jun 2014 16:02:42 +0200 Subject: verschiebe Dateien --- www/js/SocialSharing.js | 591 + www/js/compatibility.js | 505 + www/js/index.js | 1016 + www/js/jqm-themehack.js | 26 + www/js/jquery-2.1.0.min.js | 4 + www/js/jquery.mobile-1.4.2.min.js | 10 + www/js/kuerzel.js | 111 + www/js/moment-with-langs.min.js | 9 + www/js/pdf.js | 6926 ++++++ www/js/pdf.worker.js | 42765 ++++++++++++++++++++++++++++++++++++ www/js/piwik.js | 31 + 11 files changed, 51994 insertions(+) create mode 100644 www/js/SocialSharing.js create mode 100644 www/js/compatibility.js create mode 100644 www/js/index.js create mode 100644 www/js/jqm-themehack.js create mode 100644 www/js/jquery-2.1.0.min.js create mode 100644 www/js/jquery.mobile-1.4.2.min.js create mode 100644 www/js/kuerzel.js create mode 100644 www/js/moment-with-langs.min.js create mode 100644 www/js/pdf.js create mode 100644 www/js/pdf.worker.js create mode 100644 www/js/piwik.js (limited to 'www/js') diff --git a/www/js/SocialSharing.js b/www/js/SocialSharing.js new file mode 100644 index 0000000..71005d6 --- /dev/null +++ b/www/js/SocialSharing.js @@ -0,0 +1,591 @@ + + + + + + + + + + + + + SocialSharing-PhoneGap-Plugin/www/SocialSharing.js at master · EddyVerbruggen/SocialSharing-PhoneGap-Plugin · GitHub + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Skip to content +
+ + + + + + + +
+
+ + + + + + + +
+ + +
+ +
+ + + +
+ + + +
+ + This repository + + + +
+ + + + + + + + +
+
+ +
+
+ + + +
+
+
+ +
+
+
+ + + + +

+ public + + /SocialSharing-PhoneGap-Plugin + + + Octocat-spinner-32 + + +

+
+
+ +
+
+
+ + + + +
+ + + + +
+

HTTPS clone URL

+
+ + + +
+
+ + + +
+

Subversion checkout URL

+
+ + + +
+
+ + +

You can clone with + HTTPS + or Subversion. + + + + + +

+ + + + + + Download ZIP + +
+
+ +
+ + + + + + + + + +
+ + +
+ + + branch: + master + + + +
+ + +
+ + +
+ Eddy Verbruggen + + + + + + +
+ +
+
+
+
+ + executable file + + 47 lines (36 sloc) + + 2.018 kb +
+ +
+
+ + + + + +
+ 1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 + +
function SocialSharing() {
}

SocialSharing.prototype.available = function (callback) {
  cordova.exec(function (avail) {
    callback(avail ? true : false);
  }, null, "SocialSharing", "available", []);
};

SocialSharing.prototype.share = function (message, subject, file, url, successCallback, errorCallback) {
  cordova.exec(successCallback, errorCallback, "SocialSharing", "share", [message, subject, file, url]);
};

SocialSharing.prototype.shareViaTwitter = function (message, image, url, successCallback, errorCallback) {
  cordova.exec(successCallback, errorCallback, "SocialSharing", "shareViaTwitter", [message, null, image, url]);
};

SocialSharing.prototype.shareViaFacebook = function (message, image, url, successCallback, errorCallback) {
  cordova.exec(successCallback, errorCallback, "SocialSharing", "shareViaFacebook", [message, null, image, url]);
};

SocialSharing.prototype.shareViaWhatsApp = function (message, image, url, successCallback, errorCallback) {
  cordova.exec(successCallback, errorCallback, "SocialSharing", "shareViaWhatsApp", [message, null, image, url]);
};

SocialSharing.prototype.shareViaSMS = function (message, phonenumbers, successCallback, errorCallback) {
  cordova.exec(successCallback, errorCallback, "SocialSharing", "shareViaSMS", [message, phonenumbers]);
};

SocialSharing.prototype.canShareVia = function (via, message, subject, image, url, successCallback, errorCallback) {
  cordova.exec(successCallback, errorCallback, "SocialSharing", "canShareVia", [message, subject, image, url, via]);
};

SocialSharing.prototype.shareVia = function (via, message, subject, image, url, successCallback, errorCallback) {
  cordova.exec(successCallback, errorCallback, "SocialSharing", "shareVia", [message, subject, image, url, via]);
};

SocialSharing.install = function () {
  if (!window.plugins) {
    window.plugins = {};
  }

  window.plugins.socialsharing = new SocialSharing();
  return window.plugins.socialsharing;
};

cordova.addConstructor(SocialSharing.install);
+
+ +
+
+ + + + +
+ +
+ +
+
+ + +
+ +
+ +
+ + +
+
+
+ +
+
+ +
+ + + +
+ + + Something went wrong with that request. Please try again. +
+ + + + diff --git a/www/js/compatibility.js b/www/js/compatibility.js new file mode 100644 index 0000000..07d26d3 --- /dev/null +++ b/www/js/compatibility.js @@ -0,0 +1,505 @@ +/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ +/* Copyright 2012 Mozilla Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* globals VBArray, PDFJS */ + +'use strict'; + +// Initializing PDFJS global object here, it case if we need to change/disable +// some PDF.js features, e.g. range requests +if (typeof PDFJS === 'undefined') { + (typeof window !== 'undefined' ? window : this).PDFJS = {}; +} + +// Checking if the typed arrays are supported +// Support: iOS<6.0 (subarray), IE<10, Android<4.0 +(function checkTypedArrayCompatibility() { + if (typeof Uint8Array !== 'undefined') { + // Support: iOS<6.0 + if (typeof Uint8Array.prototype.subarray === 'undefined') { + Uint8Array.prototype.subarray = function subarray(start, end) { + return new Uint8Array(this.slice(start, end)); + }; + Float32Array.prototype.subarray = function subarray(start, end) { + return new Float32Array(this.slice(start, end)); + }; + } + + // Support: Android<4.1 + if (typeof Float64Array === 'undefined') { + window.Float64Array = Float32Array; + } + return; + } + + function subarray(start, end) { + return new TypedArray(this.slice(start, end)); + } + + function setArrayOffset(array, offset) { + if (arguments.length < 2) { + offset = 0; + } + for (var i = 0, n = array.length; i < n; ++i, ++offset) { + this[offset] = array[i] & 0xFF; + } + } + + function TypedArray(arg1) { + var result, i, n; + if (typeof arg1 === 'number') { + result = []; + for (i = 0; i < arg1; ++i) { + result[i] = 0; + } + } else if ('slice' in arg1) { + result = arg1.slice(0); + } else { + result = []; + for (i = 0, n = arg1.length; i < n; ++i) { + result[i] = arg1[i]; + } + } + + result.subarray = subarray; + result.buffer = result; + result.byteLength = result.length; + result.set = setArrayOffset; + + if (typeof arg1 === 'object' && arg1.buffer) { + result.buffer = arg1.buffer; + } + return result; + } + + window.Uint8Array = TypedArray; + window.Int8Array = TypedArray; + + // we don't need support for set, byteLength for 32-bit array + // so we can use the TypedArray as well + window.Uint32Array = TypedArray; + window.Int32Array = TypedArray; + window.Uint16Array = TypedArray; + window.Float32Array = TypedArray; + window.Float64Array = TypedArray; +})(); + +// URL = URL || webkitURL +// Support: Safari<7, Android 4.2+ +(function normalizeURLObject() { + if (!window.URL) { + window.URL = window.webkitURL; + } +})(); + +// Object.defineProperty()? +// Support: Android<4.0, Safari<5.1 +(function checkObjectDefinePropertyCompatibility() { + if (typeof Object.defineProperty !== 'undefined') { + var definePropertyPossible = true; + try { + // some browsers (e.g. safari) cannot use defineProperty() on DOM objects + // and thus the native version is not sufficient + Object.defineProperty(new Image(), 'id', { value: 'test' }); + // ... another test for android gb browser for non-DOM objects + var Test = function Test() {}; + Test.prototype = { get id() { } }; + Object.defineProperty(new Test(), 'id', + { value: '', configurable: true, enumerable: true, writable: false }); + } catch (e) { + definePropertyPossible = false; + } + if (definePropertyPossible) { + return; + } + } + + Object.defineProperty = function objectDefineProperty(obj, name, def) { + delete obj[name]; + if ('get' in def) { + obj.__defineGetter__(name, def['get']); + } + if ('set' in def) { + obj.__defineSetter__(name, def['set']); + } + if ('value' in def) { + obj.__defineSetter__(name, function objectDefinePropertySetter(value) { + this.__defineGetter__(name, function objectDefinePropertyGetter() { + return value; + }); + return value; + }); + obj[name] = def.value; + } + }; +})(); + + +// No XMLHttpRequest#response? +// Support: IE<11, Android <4.0 +(function checkXMLHttpRequestResponseCompatibility() { + var xhrPrototype = XMLHttpRequest.prototype; + var xhr = new XMLHttpRequest(); + if (!('overrideMimeType' in xhr)) { + // IE10 might have response, but not overrideMimeType + // Support: IE10 + Object.defineProperty(xhrPrototype, 'overrideMimeType', { + value: function xmlHttpRequestOverrideMimeType(mimeType) {} + }); + } + if ('response' in xhr || 'responseArrayBuffer' in xhr) { + return; + } + // Support: IE9 + if (typeof VBArray !== 'undefined') { + Object.defineProperty(xhrPrototype, 'response', { + get: function xmlHttpRequestResponseGet() { + return new Uint8Array(new VBArray(this.responseBody).toArray()); + } + }); + return; + } + + // other browsers + function responseTypeSetter() { + // will be only called to set "arraybuffer" + this.overrideMimeType('text/plain; charset=x-user-defined'); + } + if (typeof xhr.overrideMimeType === 'function') { + Object.defineProperty(xhrPrototype, 'responseType', + { set: responseTypeSetter }); + } + function responseGetter() { + var text = this.responseText; + var i, n = text.length; + var result = new Uint8Array(n); + for (i = 0; i < n; ++i) { + result[i] = text.charCodeAt(i) & 0xFF; + } + return result; + } + Object.defineProperty(xhrPrototype, 'response', { get: responseGetter }); +})(); + +// window.btoa (base64 encode function) ? +// Support: IE<10 +(function checkWindowBtoaCompatibility() { + if ('btoa' in window) { + return; + } + + var digits = + 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; + + window.btoa = function windowBtoa(chars) { + var buffer = ''; + var i, n; + for (i = 0, n = chars.length; i < n; i += 3) { + var b1 = chars.charCodeAt(i) & 0xFF; + var b2 = chars.charCodeAt(i + 1) & 0xFF; + var b3 = chars.charCodeAt(i + 2) & 0xFF; + var d1 = b1 >> 2, d2 = ((b1 & 3) << 4) | (b2 >> 4); + var d3 = i + 1 < n ? ((b2 & 0xF) << 2) | (b3 >> 6) : 64; + var d4 = i + 2 < n ? (b3 & 0x3F) : 64; + buffer += (digits.charAt(d1) + digits.charAt(d2) + + digits.charAt(d3) + digits.charAt(d4)); + } + return buffer; + }; +})(); + +// window.atob (base64 encode function)? +// Support: IE<10 +(function checkWindowAtobCompatibility() { + if ('atob' in window) { + return; + } + + // https://github.com/davidchambers/Base64.js + var digits = + 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; + window.atob = function (input) { + input = input.replace(/=+$/, ''); + if (input.length % 4 == 1) { + throw new Error('bad atob input'); + } + for ( + // initialize result and counters + var bc = 0, bs, buffer, idx = 0, output = ''; + // get next character + buffer = input.charAt(idx++); + // character found in table? + // initialize bit storage and add its ascii value + ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer, + // and if not first of each 4 characters, + // convert the first 8 bits to one ascii character + bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0 + ) { + // try to find character in table (0-63, not found => -1) + buffer = digits.indexOf(buffer); + } + return output; + }; +})(); + +// Function.prototype.bind? +// Support: Android<4.0, iOS<6.0 +(function checkFunctionPrototypeBindCompatibility() { + if (typeof Function.prototype.bind !== 'undefined') { + return; + } + + Function.prototype.bind = function functionPrototypeBind(obj) { + var fn = this, headArgs = Array.prototype.slice.call(arguments, 1); + var bound = function functionPrototypeBindBound() { + var args = headArgs.concat(Array.prototype.slice.call(arguments)); + return fn.apply(obj, args); + }; + return bound; + }; +})(); + +// HTMLElement dataset property +// Support: IE<11, Safari<5.1, Android<4.0 +(function checkDatasetProperty() { + var div = document.createElement('div'); + if ('dataset' in div) { + return; // dataset property exists + } + + Object.defineProperty(HTMLElement.prototype, 'dataset', { + get: function() { + if (this._dataset) { + return this._dataset; + } + + var dataset = {}; + for (var j = 0, jj = this.attributes.length; j < jj; j++) { + var attribute = this.attributes[j]; + if (attribute.name.substring(0, 5) != 'data-') { + continue; + } + var key = attribute.name.substring(5).replace(/\-([a-z])/g, + function(all, ch) { + return ch.toUpperCase(); + }); + dataset[key] = attribute.value; + } + + Object.defineProperty(this, '_dataset', { + value: dataset, + writable: false, + enumerable: false + }); + return dataset; + }, + enumerable: true + }); +})(); + +// HTMLElement classList property +// Support: IE<10, Android<4.0, iOS<5.0 +(function checkClassListProperty() { + var div = document.createElement('div'); + if ('classList' in div) { + return; // classList property exists + } + + function changeList(element, itemName, add, remove) { + var s = element.className || ''; + var list = s.split(/\s+/g); + if (list[0] === '') { + list.shift(); + } + var index = list.indexOf(itemName); + if (index < 0 && add) { + list.push(itemName); + } + if (index >= 0 && remove) { + list.splice(index, 1); + } + element.className = list.join(' '); + return (index >= 0); + } + + var classListPrototype = { + add: function(name) { + changeList(this.element, name, true, false); + }, + contains: function(name) { + return changeList(this.element, name, false, false); + }, + remove: function(name) { + changeList(this.element, name, false, true); + }, + toggle: function(name) { + changeList(this.element, name, true, true); + } + }; + + Object.defineProperty(HTMLElement.prototype, 'classList', { + get: function() { + if (this._classList) { + return this._classList; + } + + var classList = Object.create(classListPrototype, { + element: { + value: this, + writable: false, + enumerable: true + } + }); + Object.defineProperty(this, '_classList', { + value: classList, + writable: false, + enumerable: false + }); + return classList; + }, + enumerable: true + }); +})(); + +// Check console compatibility +// In older IE versions the console object is not available +// unless console is open. +// Support: IE<10 +(function checkConsoleCompatibility() { + if (!('console' in window)) { + window.console = { + log: function() {}, + error: function() {}, + warn: function() {} + }; + } else if (!('bind' in console.log)) { + // native functions in IE9 might not have bind + console.log = (function(fn) { + return function(msg) { return fn(msg); }; + })(console.log); + console.error = (function(fn) { + return function(msg) { return fn(msg); }; + })(console.error); + console.warn = (function(fn) { + return function(msg) { return fn(msg); }; + })(console.warn); + } +})(); + +// Check onclick compatibility in Opera +// Support: Opera<15 +(function checkOnClickCompatibility() { + // workaround for reported Opera bug DSK-354448: + // onclick fires on disabled buttons with opaque content + function ignoreIfTargetDisabled(event) { + if (isDisabled(event.target)) { + event.stopPropagation(); + } + } + function isDisabled(node) { + return node.disabled || (node.parentNode && isDisabled(node.parentNode)); + } + if (navigator.userAgent.indexOf('Opera') != -1) { + // use browser detection since we cannot feature-check this bug + document.addEventListener('click', ignoreIfTargetDisabled, true); + } +})(); + +// Checks if possible to use URL.createObjectURL() +// Support: IE +(function checkOnBlobSupport() { + // sometimes IE loosing the data created with createObjectURL(), see #3977 + if (navigator.userAgent.indexOf('Trident') >= 0) { + PDFJS.disableCreateObjectURL = true; + } +})(); + +// Checks if navigator.language is supported +(function checkNavigatorLanguage() { + if ('language' in navigator && + /^[a-z]+(-[A-Z]+)?$/.test(navigator.language)) { + return; + } + function formatLocale(locale) { + var split = locale.split(/[-_]/); + split[0] = split[0].toLowerCase(); + if (split.length > 1) { + split[1] = split[1].toUpperCase(); + } + return split.join('-'); + } + var language = navigator.language || navigator.userLanguage || 'en-US'; + PDFJS.locale = formatLocale(language); +})(); + +(function checkRangeRequests() { + // Safari has issues with cached range requests see: + // https://github.com/mozilla/pdf.js/issues/3260 + // Last tested with version 6.0.4. + // Support: Safari 6.0+ + var isSafari = Object.prototype.toString.call( + window.HTMLElement).indexOf('Constructor') > 0; + + // Older versions of Android (pre 3.0) has issues with range requests, see: + // https://github.com/mozilla/pdf.js/issues/3381. + // Make sure that we only match webkit-based Android browsers, + // since Firefox/Fennec works as expected. + // Support: Android<3.0 + var regex = /Android\s[0-2][^\d]/; + var isOldAndroid = regex.test(navigator.userAgent); + + if (isSafari || isOldAndroid) { + PDFJS.disableRange = true; + } +})(); + +// Check if the browser supports manipulation of the history. +// Support: IE<10, Android<4.2 +(function checkHistoryManipulation() { + // Android 2.x has so buggy pushState support that it was removed in + // Android 3.0 and restored as late as in Android 4.2. + // Support: Android 2.x + if (!history.pushState || navigator.userAgent.indexOf('Android 2.') >= 0) { + PDFJS.disableHistory = true; + } +})(); + +// TODO CanvasPixelArray is deprecated; use Uint8ClampedArray +// once it's supported. +(function checkSetPresenceInImageData() { + if (window.CanvasPixelArray) { + if (typeof window.CanvasPixelArray.prototype.set !== 'function') { + window.CanvasPixelArray.prototype.set = function(arr) { + for (var i = 0, ii = this.length; i < ii; i++) { + this[i] = arr[i]; + } + }; + } + } +})(); + +// Support: IE<10, Android<4.0, iOS<5.0 +(function checkRequestAnimationFrame() { + if ('requestAnimationFrame' in window) { + return; + } + window.requestAnimationFrame = + window.mozRequestAnimationFrame || + window.webkitRequestAnimationFrame || + (function fakeRequestAnimationFrame(callback) { + window.setTimeout(callback, 20); + }); +})(); diff --git a/www/js/index.js b/www/js/index.js new file mode 100644 index 0000000..ddedc8f --- /dev/null +++ b/www/js/index.js @@ -0,0 +1,1016 @@ +/* + * 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 . +*/ + +version = '0.9.5_rc4'; + +function istPremium(benutzer, key){ // Supersicherer Keygenerator :P Inspiriert von kryptochef.de + sollKey = ''; + + switch(benutzer.length % 10){ // Anzahl Zeichen ausschreiben + case 0: sollKey = 'NULL'; break; + case 1: sollKey = 'EINS'; break; + case 2: sollKey = 'ZWEI'; break; + case 3: sollKey = 'DREI'; break; + case 4: sollKey = 'VIER'; break; + case 5: sollKey = 'FUNF'; break; + case 6: sollKey = 'SECHS'; break; + case 7: sollKey = 'SIEBEN'; break; + case 8: sollKey = 'ACHT'; break; + case 9: sollKey = 'NEUN'; break; + } + + sollKey = sollKey.replace(/[A-Z]/g, function(s){ + return String.fromCharCode(s.charCodeAt(0) + (s < 'N' ? 13 : -13)); // ROT13 + }); + + sollKey = sollKey + Math.round(benutzer.length * 3.14); // Eine Zahl anfügen + + if(sollKey === key){ + return true; + }else{ + return false; + } +} + +function updateCheck(){ + var request = $.ajax({ + url: 'http://klimaag.***REMOVED***/app/www/knockout.html', + cache: false + }); + + request.done(function(resultHtml){ + var appStatus = $('li[id="' + version + '"]', resultHtml).text().trim(); + var loginOk = true; + + console.log('Appstatus: ' + appStatus); + + switch(appStatus){ + case 'ok': + break; + case 'hangon': + $('#versioninfo').text('Es besteht ein Problem mit der aktuellen Version. Ein Update ist in Arbeit.'); + break; + case 'info': + $('#versioninfo').text('Ein Update ist im Appstore verfügbar.').show(); + break; + case 'warn': + $('#versioninfo').text('Ein wichtiges Update ist im Appstore verfügbar.').show(); + break; + case 'force': + $('#versioninfo').text('Ein wichtiges Update ist im Appstore verfügbar. Du musst es installieren, um dich weiterhin einloggen zu können.').show(); + $('#loginsubmit').prop('disabled', true); + loginOk = false; + break; + default: + $('#versioninfo').text('Diese Appversion wird nicht mehr unterstützt, bitte aktualisiere auf die neueste Version aus dem Appstore.').show(); + $('#loginsubmit').prop('disabled', true); + loginOk = false; + } + + if(loginOk === true){ + tryLogin(); // nur wenn alles in Ordnung ist, einloggen lassen + } + }); + + request.fail(fail); +} + +function track(what){ + _paq.push(['setCustomUrl', what]); + _paq.push(['trackPageView', what]); +} + +function trackPlan(vdate){ + track('plan/' + vdate.format('YYYY/MM/DD')); +} + +$('#settingspanel').change(function(){ + localStorage.setItem('dntrack', $('#dntflip').val()); + localStorage.setItem('classes', $('#addclass').val().toUpperCase()); + localStorage.setItem('notifyday', $('#notifydayflip').val()); + localStorage.setItem('notifynull', $('#notifynullflip').val()); + localStorage.setItem('notifydate', $('#notifydate').val()); + localStorage.setItem('apptheme', $('#themeselect').val()); +}); + +document.addEventListener('offline', function(){ + $('#loginsubmit').prop('disabled', true); + $('#error_noconn').show('fast'); +}, false); + +document.addEventListener('online', function(){ + $('#loginsubmit').prop('disabled', false); + $('#error_noconn').hide('fast'); +}, false); + +$('#mainpage').on('swiperight', function(){ + $('#settingspanel').panel('open'); +}); + +var _paq = _paq || []; +$('#mainpage').on('pagebeforeshow', function(){ + /* Versionsnummer zeigen */ + $('.version').text(version); + + /* Sprache setzen */ + moment.lang('de'); + + /* Nutzungsstatistiken */ + _paq.push(['setTrackerUrl', 'http://klimaag.***REMOVED***/piwik/piwik.php']); // TODO Https wäre schön. + _paq.push(['setSiteId', 5]); + + console.log('Piwik initialisiert'); + + /* gespeicherte Daten laden */ + var dntrack = localStorage.getItem('dntrack'); + var additionalClasses = localStorage.getItem('classes'); + var notifyDay = localStorage.getItem('notifyday'); + var notifyNull = localStorage.getItem('notifynull'); + var notifyDate = localStorage.getItem('notifydate'); + var premium = localStorage.getItem('premium'); + var easteregg = localStorage.getItem('easteregg'); + var apptheme = localStorage.getItem('apptheme'); + + if(dntrack === null || dntrack.length === 0){ + dntrack = 'false'; + } + $('#dntflip').val(dntrack).slider('refresh'); + + if(additionalClasses === null || additionalClasses.length === 0){ + additionalClasses = ''; + } + $('#addclass').val(additionalClasses).textinput('refresh'); + + if(notifyDay === null || notifyDay.length === 0){ + notifyDay = 0; + } + $('#notifydayflip').val(notifyDay).slider('refresh'); + + if(notifyNull === null || notifyNull.length === 0){ + notifyNull = 0; + } + $('#notifynullflip').val(notifyNull).slider('refresh'); + + if(notifyDate === null || notifyDate.length === 0){ + notifyDate = '18:00'; + } + $('#notifydate').val(notifyDate).textinput('refresh'); + + if(premium === null || premium.length === 0){ + premium = 'false'; + } + if(premium === 'true'){ + $('#themeselect').append('').selectmenu('refresh'); + console.log('Premium geladen'); + } + + if(easteregg === null || easteregg.length === 0){ + easteregg = 'false'; + } + if(easteregg === 'true'){ + $('#themeselect').append('').selectmenu('refresh'); + console.log('Easteregg geladen'); + } + + if(apptheme === null || apptheme.length === 0){ + apptheme = 'a'; + } + $('#themeselect').val(apptheme).selectmenu('refresh'); + + /* Piwik initialisieren */ + _paq.push(['setDoNotTrack', dntrack]); +}); + +// Login-Popup beim Start +document.addEventListener('deviceready', function(){ + /* iOS fix */ + if(window.device && parseFloat(window.device.version) >= 7.0) { + $('body').addClass('iOS7'); + } + + /* los geht's */ + _paq.push(['setCustomVariable', 1, 'Modell', device.model, 'visit']); + _paq.push(['setCustomVariable', 2, 'Version', device.version, 'visit']); + _paq.push(['setCustomVariable', 3, 'Appversion', version, 'visit']); + track('load'); + + fillForm(); + + if(navigator.connection.type !== Connection.NONE){ // falls Netz da ist + updateCheck(); // checkt ob aktuellste Version und loggt ein + } + + window.plugin.notification.local.cancelAll(); // alle Benachrichtigungen canceln, werden während des Renderings neu gesetzt + load(); +}, false); + +/* der Loader wird nur angezeigt, wenn das Popup zu ist */ +$('#loginpopup').on('popupafteropen', function(){ + $.mobile.loading('hide'); +}); + +/* füllt die Loginform mit gespeicherten Werten */ +function fillForm(){ + var username = localStorage.getItem('username'); + + if(username !== null && username.length !== 0){ + $('#username').val(username); + } + + var password = localStorage.getItem('password'); + + if(password !== null && password.length !== 0){ + $('#password').val(password); + } +} + +/* benachrichtigt den Benutzer an vdate mit msg */ +function addNotification(vdate, msg, $div){ + var title = 'Vertretungen für ' + vdate.format('dddd'); + var ndate = vdate.subtract('days', 1).add('days', $('#notifydayflip').val()); // Bei Bedarf einen Tag vorher + + if(moment().isBefore(ndate)){ + window.plugin.notification.local.add({ + date: ndate.toDate(), + message: msg, + title: title, + autoCancel: true, + json: JSON.stringify({id: $div.attr('id')}) + }); + + window.plugin.notification.local.onclick = function(id, state, json){ + var div = JSON.parse(json).id; + location.href = '#' + div; // TODO hoffentlich funktioniert das auch immer... + }; + + console.log('Benachrichtigung hinzugefügt: ' + ndate.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 sharebtns = $('button', $div); + + if(sharebtns.length === 0){ + var btn = $('