summaryrefslogtreecommitdiff
path: root/js/index.js
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2014-05-02 12:45:07 +0200
committerschneefux <schneefux+commit@schneefux.xyz>2016-08-15 19:55:42 +0200
commitacb84b1a78d3dd201009def5d294c2975408a2ae (patch)
treec3fbd7dbce397f38bf2d3147448b67b378d3fc9a /js/index.js
parentb6d99a9196f90790bcf4cc147852bd4d36d47a5c (diff)
downloadwvs-vplan-acb84b1a78d3dd201009def5d294c2975408a2ae.tar.gz
wvs-vplan-acb84b1a78d3dd201009def5d294c2975408a2ae.zip
implementiere Button zum Löschen alter Pläne
Diffstat (limited to 'js/index.js')
-rw-r--r--js/index.js36
1 files changed, 35 insertions, 1 deletions
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);
+}