From acb84b1a78d3dd201009def5d294c2975408a2ae Mon Sep 17 00:00:00 2001 From: schneefux Date: Fri, 2 May 2014 12:45:07 +0200 Subject: implementiere Button zum Löschen alter Pläne MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 2 ++ js/index.js | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 3e1180c..cc084fb 100644 --- a/index.html +++ b/index.html @@ -49,6 +49,8 @@ + + Über 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); +} -- cgit v1.3.1