From dfc04f556eeb9fc89d8d860be4051c33b4cbd34e Mon Sep 17 00:00:00 2001 From: schneefux Date: Sun, 27 Apr 2014 13:16:04 +0200 Subject: benutze Moment.js für Daten MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/.index.js.swp | Bin 0 -> 45056 bytes js/index.js | 53 ++++++++++++++++++++------------------------ js/moment-with-langs.min.js | 9 ++++++++ 3 files changed, 33 insertions(+), 29 deletions(-) create mode 100644 js/.index.js.swp create mode 100644 js/moment-with-langs.min.js (limited to 'js') diff --git a/js/.index.js.swp b/js/.index.js.swp new file mode 100644 index 0000000..29d33a5 Binary files /dev/null and b/js/.index.js.swp differ diff --git a/js/index.js b/js/index.js index 88e891c..014d057 100644 --- a/js/index.js +++ b/js/index.js @@ -23,9 +23,15 @@ function setDNT(dnt){ } 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'); }); @@ -82,10 +88,9 @@ function fillform(){ /* benachrichtigt den Benutzer an vdate mit msg */ var notifications = 0; function addNotification(vdate, msg){ - var today = new Date(); - vdate.setDate(vdate.getDate() - 1); // Ein Tag vorher, 18 Uhr benachrichtigen + vdate.subtract('days', 1); // Ein Tag vorher, 18 Uhr benachrichtigen - var secondsUntilDate = (vdate.getTime() - today.getTime()) / 1000; + var secondsUntilDate = moment.diff(vdate, 'seconds'); if(secondsUntilDate > 0){ localNotification.add(++notifications, { @@ -93,16 +98,14 @@ function addNotification(vdate, msg){ message: msg, badge: 0}); - console.log('Benachrichtigung hinzugefügt: ' + vdate.toString() + '; ' + msg); + 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){ - var today = new Date(); - - if(vdate >= today){ - var datestr = vdate.getDate() + "." + vdate.getMonth() + "."; + if(moment().isBefore(vdate)){ + var datestr = vdate.format('dddd.'); var btn = $('