diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2014-04-24 15:20:02 +0200 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2016-08-15 19:46:56 +0200 |
| commit | 130250ae735fe500d313d9cf51a9c6e00b93dc9f (patch) | |
| tree | 031fea6b78d38ffa18403efedb97d870c5a850d9 /js/index.js | |
| parent | ff2e8e3e190848e45200a0f4d283f8793efebbfc (diff) | |
| download | wvs-vplan-130250ae735fe500d313d9cf51a9c6e00b93dc9f.tar.gz wvs-vplan-130250ae735fe500d313d9cf51a9c6e00b93dc9f.zip | |
füge Benachrichtigungen hinzu
Diffstat (limited to 'js/index.js')
| -rw-r--r-- | js/index.js | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/js/index.js b/js/index.js index 557d789..f82289b 100644 --- a/js/index.js +++ b/js/index.js @@ -16,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - // Login-Popup beim Start $(document).bind('pageinit', function(){ setTimeout(function(){ @@ -49,6 +48,24 @@ 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 + + var secondsUntilDate = (vdate.getTime() - today.getTime()) / 1000; + + if(secondsUntilDate > 0){ + localNotification.add(++notifications, { + seconds: secondsUntilDate, + message: msg, + badge: 0}); + + console.log('Benachrichtigung hinzugefügt: ' + vdate.toString() + '; ' + msg); + } +} + function parseVertretungen(str){ var vertretungen_re = new RegExp('(\\w+)\\s+(\\d(?:\\s+-\\s+\\d)?)\\s+((?:x\\s+)?)(\\+|\\w+|---)\\s+(\\w+|---)\\s+(\\w+|---)\\s+(.*?)\\s+(\\w+)(?:\\s+)?(.*?)'); var res; @@ -105,6 +122,10 @@ function parseVertretungen(str){ vertretungen.push(klasse + " " + stunde + ". Stunde " + art + fach + nlehrer + " in Raum " + raum + info); } + }else{ + if(vertretungsstr.indexOf('Unterrichtsschluss') > -1){ + vertretungen.push(vertretungsstr); + } } }); @@ -169,15 +190,21 @@ function renderPage($div, pdf, pageNumber, callback){ if(klasse !== null){ vertretungen.forEach(function(vertretung){ - if(vertretung.indexOf(klasse[1]) > -1){ - hightlights.push(vertretung); + if(vertretung.indexOf(klasse[1]) > -1 || vertretung.indexOf('Unterrichtsschluss') > -1){ + highlights.push(vertretung); console.log('Wichtige Vertretung: ' + vertretung); } }); } } - // TODO mach etwas mit den Vertretungen + if(highlights.length > 0){ + var vdate = new Date($div.data('date')); + vdate.setHours(18); + vdate.setMinutes(17); // TODO DEBUG + + addNotification(vdate, highlights.join('\n')); + } }); callback(pdf); @@ -251,8 +278,6 @@ function addplanattr(fileEntry, wasdownloaded){ name = results[3] + '_' + results[2] + '_' + results[1] + results[4]; name = replaceUmlauts(name); // TODO - console.log(name); - if(!$(name).length){ $('#vplannavbar').find('*').andSelf().each(function(){ $(this).removeClass(function(i, cn){ @@ -276,6 +301,8 @@ function addplanattr(fileEntry, wasdownloaded){ } } + var vdate = new Date(parseInt(results[1]), parseInt(results[2]) - 1, parseInt(results[3])); + $('#' + name).data('date', vdate.toString()); render_pdf(sPath, name); } |
