diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2014-03-30 18:00:30 +0200 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2016-08-15 19:46:49 +0200 |
| commit | a8e1682ec729d8c7134224549760315289d34fe2 (patch) | |
| tree | 948f49f5163af69041cde1463bf8bd6a109aa8a6 /js | |
| parent | 127abe711515ccdce26f9267c30c62e492f846bb (diff) | |
| download | wvs-vplan-a8e1682ec729d8c7134224549760315289d34fe2.tar.gz wvs-vplan-a8e1682ec729d8c7134224549760315289d34fe2.zip | |
lade bereits vorhandene Pläne nicht erneut herunter
Diffstat (limited to 'js')
| -rw-r--r-- | js/index.js | 54 |
1 files changed, 37 insertions, 17 deletions
diff --git a/js/index.js b/js/index.js index ab3ac6e..f28e144 100644 --- a/js/index.js +++ b/js/index.js @@ -90,6 +90,9 @@ function fail(text){ $('#error_noconn').show('fast'); console.log('Fehler: ' + text.toString()); } +/* + * + */ function download_pdf(link, id){ var filename = link.substring(link.lastIndexOf("/") + 1); @@ -111,27 +114,44 @@ function download_pdf(link, id){ } 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()); + if(fileEntry.file.size == 0){ + var fileTransfer = new FileTransfer(); + + 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(); + ); + }else{ + // Datei ist schon heruntergeladen + var sPath; + + if(device.platform == "Android"){ + sPath = "/storage/sdcard0" + fileEntry.fullPath; + }else{ + sPath = fileEntry.fullPath; } - ); - }, - fail); + + console.log('Datei vorhanden: ' + sPath); + $('#pdf-' + id).attr('data-plan-url', sPath); + + if(location.href.indexOf('page-') == -1){ + $.mobile.changePage('#page-vplan-' + id); + } + } + }, fail); }, fail); }); |
