diff options
| -rw-r--r-- | index.html | 2 | ||||
| -rw-r--r-- | js/index.js | 36 |
2 files changed, 37 insertions, 1 deletions
@@ -49,6 +49,8 @@ <option value="false">Ja</option> </select> + <button id="purgebtn" data-mini="true" onclick="javascript:purge();">Speicher freigeben</button> + <a id="lnkdisclaimer" href="#disclaimerpopup" data-rel="popup" data-role="button" data-position-to="window" data-transition="pop" data-mini="true" onclick="javascript:track('ui/tab/login/disclaimerpopup');">Über</a> </div> <!-- settingspanel --> diff --git a/js/index.js b/js/index.js index 9ea46ce..50a9587 100644 --- a/js/index.js +++ b/js/index.js @@ -167,7 +167,7 @@ function addNotification(vdate, msg, $div){ 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); } @@ -730,3 +730,37 @@ function load(){ }, fail); }); } + +/* löscht alle Pläne im Speicher */ +function purge(){ + track('event/purge'); + + $('#purgebtn').hide('fast'); + + window.requestFileSystem( + LocalFileSystem.PERSISTENT, 0, + function(fileSystem){ + fileSystem.root.getDirectory('WvSVPlan', {create: true, exclusive: false}, + function(dirEntry){ + var dirReader = dirEntry.createReader(); + + dirReader.readEntries( + function(entries){ + var actual = getActual(entries); + + actual.forEach(function(entry){ // akuelle aus entries löschen + var index = entries.indexOf(entry); + if(index !== -1){ + entries.splice(index, 1); + } + }); + + console.log('Lösche ' + entries.length + ' alte Pläne'); + + entries.forEach(function(entry){ + entry.remove(null, fail); // Datei löschen + }); + }, fail); + }, fail); + }, fail); +} |
