Skip to content

Instantly share code, notes, and snippets.

@brianleroux
Created December 8, 2011 07:28
Show Gist options
  • Save brianleroux/1446383 to your computer and use it in GitHub Desktop.
Save brianleroux/1446383 to your computer and use it in GitHub Desktop.
trying to reproduce cb-107 issue
<!DOCTYPE HTML>
<html>
<head><meta name=viewport content=width=device-width,user-scalable=no></head>
<body>
<h1>testing cb-107</h1>
<script src=phonegap-1.3.0rc1.js></script>
<script>
// async bootup mumbo jumbo
function fail(error) {
console.log(JSON.stringify(error))
}
function ready() {
console.log('requesting file access')
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail)
}
function gotFS(fileSystem) {
console.log('attempting to read app.log or create it')
fileSystem.root.getFile('app.log', {create: true, exclusive: false}, gotFile, fail)
}
function gotFile(fileEntry) {
console.log('create a writer obj for the file handle')
fileEntry.createWriter(gotFileWriter, fail)
}
function gotFileWriter(writer) {
console.log('write a line to app.log file on sd card ten times a second')
var id = setInterval(writeOnce, 100, writer), count = 0
function writeOnce(writer) {
writer.onwrite = function(evt) { console.log("write success") }
writer.seek(writer.length)
writer.write(count+" appended one line of text\n")
++count
if (count === 900) clearInterval(id)
}
}
document.addEventListener('deviceready', ready, false)
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment