diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2014-05-01 17:18:39 +0200 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2016-08-15 19:55:41 +0200 |
| commit | fdf8325d8dbca9bfa2a65a73f3c5bf8f9867564d (patch) | |
| tree | 64a9a4b21e8064a0afe822f0c2ef2e6a4bf3f385 /js/index.js | |
| parent | 7cae002c61ef199f0aee7db4a65ca03ee0552e9b (diff) | |
| download | wvs-vplan-fdf8325d8dbca9bfa2a65a73f3c5bf8f9867564d.tar.gz wvs-vplan-fdf8325d8dbca9bfa2a65a73f3c5bf8f9867564d.zip | |
ersetze LocalNotification-Plugin
Diffstat (limited to 'js/index.js')
| -rw-r--r-- | js/index.js | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/js/index.js b/js/index.js index 4c97132..8fe8240 100644 --- a/js/index.js +++ b/js/index.js @@ -116,6 +116,7 @@ document.addEventListener('deviceready', function(){ }, 2000); }else{ fillForm(); + window.plugin.notification.local.cancelAll(); // alle Benachrichtigungen canceln, werden während des Renderings neu gesetzt load(); tryLogin(); } @@ -128,6 +129,7 @@ $('#loginpopup').on('popupafteropen', function(){ $('#disclaimerpopup').on('popupafterclose', function(){ fillForm(); + window.plugin.notification.local.cancelAll(); load(); tryLogin(); }); @@ -148,17 +150,24 @@ function fillForm(){ } /* benachrichtigt den Benutzer an vdate mit msg */ -var notifications = 0; -function addNotification(vdate, msg){ +function addNotification(vdate, msg, $div){ + var title = 'Vertretung für ' + vdate.format('dddd'); vdate = vdate.subtract('days', 1).add('days', $('#notifydayflip').val()); // Bei Bedarf einen Tag vorher - var secondsUntilDate = vdate.diff(moment(), 'seconds'); - - if(secondsUntilDate > 0){ - localNotification.add(++notifications, { - seconds: secondsUntilDate, + if(moment().isBefore(vdate)){ + window.plugin.notification.local.add({ + date: vdate.toDate(), message: msg, - badge: 0}); + title: title, + autoCancel: true, + json: JSON.stringify({id: $div.attr('id')}), + //badge: 0 //TODO + }); + + 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: ' + vdate.format('DD.MM. hh:mm') + '; ' + msg); } @@ -360,7 +369,7 @@ function renderPage($div, pdf, pageNumber, callback){ vdate.set('hour', time[0]); vdate.set('minute', time[1]); - addNotification(vdate, vertretungen.join('\n')); + addNotification(vdate, vertretungen.join('\n'), $div); addSocialButton(vdate, vertretungen.join(', '), $div); } }); |
