diff options
| -rw-r--r-- | js/index.js | 63 |
1 files changed, 33 insertions, 30 deletions
diff --git a/js/index.js b/js/index.js index bd399ff..ab3ac6e 100644 --- a/js/index.js +++ b/js/index.js @@ -97,41 +97,44 @@ function download_pdf(link, id){ window.requestFileSystem( LocalFileSystem.PERSISTENT, 0, function onFileSystemSuccess(fileSystem){ - fileSystem.root.getFile( - filename, {create: true, exclusive: false}, - function gotFileEntry(fileEntry){ - var sPath; + fileSystem.root.getDirectory('WvSVPlan', {create: true, exclusive: false}, + function(dirEntry){ + dirEntry.getFile( + filename, {create: true, exclusive: false}, + function gotFileEntry(fileEntry){ + var sPath; - if(device.platform == "Android"){ - sPath = "/storage/sdcard0" + fileEntry.fullPath; - }else{ - sPath = fileEntry.fullPath; - } + if(device.platform == "Android"){ + sPath = "/storage/sdcard0" + fileEntry.fullPath; + }else{ + sPath = fileEntry.fullPath; + } - console.log('Pfad: ' + sPath); - var fileTransfer = new FileTransfer(); - fileEntry.remove(); + console.log('Pfad: ' + sPath); + var fileTransfer = new FileTransfer(); + fileEntry.remove(); - fileTransfer.download( - link, - sPath, - function(theFile){ - console.log('Download fertig: ' + theFile.toURL()); - $('#pdf-' + id).attr('data-plan-url', theFile.toURL()); + fileTransfer.download( + link, + sPath, + function(theFile){ + console.log('Download fertig: ' + theFile.toURL()); + $('#pdf-' + id).attr('data-plan-url', theFile.toURL()); - if(location.href.indexOf('page-') == -1){ - $.mobile.changePage('#page-vplan-' + id); + if(location.href.indexOf('page-') == -1){ + $.mobile.changePage('#page-vplan-' + id); + } + }, + function(error){ + console.log('Fehler: ' + error.source + ' - '+ error.target + ' - ' + error.code); + fail(); } - }, - function(error){ - console.log('Fehler: ' + error.source + ' - '+ error.target + ' - ' + error.code); - fail(); - } - ); - }, - fail); - }, - fail); + ); + }, + fail); + }, + fail); + }); } function get_plan(link, id){ |
