diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2014-06-08 19:24:59 +0200 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2016-08-15 20:02:40 +0200 |
| commit | ec2d11ad081925a699a833d1329f296440d87727 (patch) | |
| tree | 4aed4b9ba391e23ef6e2cbca99ac1c39dfd54846 | |
| parent | 3d3845d975c378b92d782d3bd0a74bbcf07f45ed (diff) | |
| download | wvs-vplan-ec2d11ad081925a699a833d1329f296440d87727.tar.gz wvs-vplan-ec2d11ad081925a699a833d1329f296440d87727.zip | |
benachrichtige optional über "nichts"
| -rw-r--r-- | index.html | 6 | ||||
| -rw-r--r-- | js/index.js | 23 |
2 files changed, 23 insertions, 6 deletions
@@ -41,6 +41,12 @@ <option value="0">Ja</option> </select> + <label for="notifynullflip">Über 'Keine Vertretungen' benachrichtigen:</label> + <select id="notifynullflip" data-role="slider" data-mini="true" > + <option value="false">Nein</option> + <option value="true">Ja</option> + </select> + <label for="addclass">Benachrichtigen auch für Klasse(n):</label> <textarea id="addclass" data-mini="true"></textarea> diff --git a/js/index.js b/js/index.js index 3e9e1b5..a22e96b 100644 --- a/js/index.js +++ b/js/index.js @@ -103,6 +103,7 @@ $('#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()); }); @@ -139,6 +140,7 @@ $('#mainpage').on('pagebeforeshow', function(){ 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'); @@ -159,6 +161,11 @@ $('#mainpage').on('pagebeforeshow', function(){ } $('#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'; } @@ -234,7 +241,7 @@ function fillForm(){ /* benachrichtigt den Benutzer an vdate mit msg */ function addNotification(vdate, msg, $div){ - var title = 'Vertretung für ' + vdate.format('dddd'); + 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)){ @@ -547,15 +554,19 @@ function benutzeVertretungen(pageText, $div){ var username = userdata[0]; var vertretungen = parseVertretungen(pageText, username); - if(vertretungen.length > 0){ - var vdate = moment($div.data('date'), 'YYYY-MM-DD').startOf('second'); - var time = $('#notifydate').val().split(':'); + var vdate = moment($div.data('date'), 'YYYY-MM-DD').startOf('second'); + var time = $('#notifydate').val().split(':'); - vdate.set('hour', time[0]); - vdate.set('minute', time[1]); + vdate.set('hour', time[0]); + vdate.set('minute', time[1]); + if(vertretungen.length > 0){ addSocialButton(vdate, vertretungen.join(', '), $div); addNotification(vdate, vertretungen.join('\n'), $div); + }else{ + if($('#notifynullflip').val() == 'true'){ + addNotification(vdate, 'Keine weiteren Vertretungen', $div); // TODO FIXME Problem bei mehreren Seiten! + } } } |
