Created
September 9, 2014 16:09
-
-
Save atleastimtrying/ab1e74bc70aea4bb5d1f to your computer and use it in GitHub Desktop.
attempt at accesing a directory in phonegap 3.5 using phonegap developer app on a nexus 5.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
window.onerror = function(err,fn,ln) { | |
alert("ERROR:" + err + ", " + fn + ":" + ln); | |
}; | |
window.namespace.ImageDownload = function(){ | |
$('#test').click(function(event){ | |
event.preventDefault(); | |
get_fs(function(fs){ | |
var directory = 'sample'; | |
fs.root.getDirectory(directory, { | |
create: false | |
}, function(){ | |
console.log('directory fetched'); | |
}, function(){ | |
console.log('directory failed'); | |
}); | |
}); | |
}) | |
var fail = function(error) { | |
console.log('ERROR', error.code); | |
}; | |
var get_fs = function(return_fs){ | |
window.requestFileSystem( | |
LocalFileSystem.PERSISTENT, | |
5 * 1024 * 1024, | |
function(fs){ | |
return_fs(fs); | |
}, | |
fail | |
); | |
}; | |
}; | |
})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<title>Phonegap test</title> | |
<link href="css/style.css" rel="stylesheet" > | |
</head> | |
<body> | |
<h2><a href="#" id="test">TEST</a></h2> | |
<script src="cordova.js" onload="javascript:window.isPhonegap = true;"></script> | |
<script>window.namespace = {};</script> | |
<script src="image_download.js"></script> | |
<script src="init.js"></script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function(){ | |
var img = new namespace.ImageDownload(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment