Skip to content

Instantly share code, notes, and snippets.

@atleastimtrying
Created September 9, 2014 16:09
Show Gist options
  • Save atleastimtrying/ab1e74bc70aea4bb5d1f to your computer and use it in GitHub Desktop.
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.
(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
);
};
};
})();
<!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>
$(function(){
var img = new namespace.ImageDownload();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment