aboutsummaryrefslogtreecommitdiffstats
path: root/www/js/files.js
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2013-07-12 09:47:56 +0100
committerStruan Donald <struan@exo.org.uk>2013-07-12 11:00:11 +0100
commit25e3a0c94551b0faac3f16e0598e6f4bdffcf7d8 (patch)
treef78f68ba8ed39e5b5004e41435aac3e9bbe9c044 /www/js/files.js
parent4c2206c97250b7f72eb04d13ae886a7fb4f4086a (diff)
instead of using js to inject the correct cordova js file in to
index.html restructure things so that the common files are a level down and the platofrm specific ones are directly placed in the relevant project. This both makes for less fuss and also avoids the error with Android < v3 instantiating cordova twice. Note that the iOS common assets are included by a build script rather than a symlink as symlinking doesn't seem to agree with Xcode
Diffstat (limited to 'www/js/files.js')
-rw-r--r--www/js/files.js127
1 files changed, 0 insertions, 127 deletions
diff --git a/www/js/files.js b/www/js/files.js
deleted file mode 100644
index b8aed05..0000000
--- a/www/js/files.js
+++ /dev/null
@@ -1,127 +0,0 @@
-/**
- * Things to do with Phonegap files
- * Mainly wrappers around their async functions to return Promises
- */
-
- (function (FMS, Backbone, _, $) {
- _.extend(FMS, {
- files: {
- // move a file at from a uri to a desination directory. maintains file name
- moveURI: function (srcURI, dest ) {
-
- var fileEntry;
- return getFileFromURI(srcURI)
- .pipe( function (file) {
- fileEntry = file;
-
- return getFileSystem();
- })
- .pipe( function (filesystem) {
- console.log('Filesystem returned: ' + filesystem);
-
- return getDirectory(filesystem.root, CONFIG.FILES_DIR, {create: true});
- })
- .pipe( function(directory) {
- return moveFile( fileEntry, directory );
- });
- },
-
- deleteURI: function (uri) {
- console.log('Deleting URI: ' + uri);
-
- return getFileFromURI(uri)
- .pipe( function (file) {
- var deletingFile = $.Deferred();
- file.remove(deletingFile.resolve, deletingFile.reject);
- return deletingFile;
- });
-
- },
-
- // Delete a file from the filesystem
- deleteFile: function (path) {
-
- console.log('Deleting file: ' + path);
-
- // Turn path into a filename
- var filename = path.split('/').pop();
-
- return getFileSystem()
- .pipe(function (filesystem) {
- return getDirectory(filesystem.root, CONFIG.FILES_DIR);
- })
- .pipe(function (directory) {
- return getFile(directory, filename, {});
- })
- .pipe(function (file) {
- var deletingFile = $.Deferred();
- file.remove(deletingFile.resolve, deletingFile.reject);
- return deletingFile;
- });
-
- }
- }
- });
-
- // Wrap the async Phonegap way of getting a filesystem in a promise
- function getFileSystem() {
-
- console.log('Getting the file system');
-
- var filesystem = $.Deferred();
-
- window.requestFileSystem(
- LocalFileSystem.PERSISTENT,
- 0,
- filesystem.resolve,
- filesystem.reject );
-
- return filesystem.promise();
- }
-
- // Wrap the async Phonegap way of getting a directory in a promise
- function getDirectory (rootDirectory, path, options) {
-
- console.log('Getting a directory: ' + path);
-
- var directory = $.Deferred();
-
- rootDirectory.getDirectory(path, options, directory.resolve, directory.reject);
-
- return directory.promise();
- }
-
- // Wrap the async Phonegap way of getting a file in a promise
- function getFile (directory, path, options) {
-
- console.log('Getting a file with path: ' + path + ' in directory: ' + directory.fullPath);
-
- var file = $.Deferred();
-
- directory.getFile(path, options, file.resolve, file.reject);
-
- return file.promise();
- }
-
- function moveFile (src, dest, options) {
-
- console.log( 'moveing file ' + src.fullPath + ' to ' + dest.fullPath );
-
- var move = $.Deferred();
-
- src.moveTo( dest, null, move.resolve, move.reject);
-
- return move.promise();
- }
-
- function getFileFromURI(uri) {
-
- console.log( 'getting file from uri ' + uri );
-
- var file = $.Deferred();
-
- window.resolveLocalFileSystemURI( uri, file.resolve, file.reject);
-
- return file.promise();
- }
-})(FMS, Backbone, _, $);