<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0" />
<title>Sample</title>
<script src="cordova-2.7.0.js" type="text/javascript"></script>
<script src="tts.js" type="text/javascript"></script>
<style type="text/css">
.auto-style1 {
text-align: center;
}
</style>
</head>
<body onload="onLoaded()">
<div class="info" style="font-size:12px">TTS TEST</div>
<script>
function onLoaded() {
alert('onLoaded');
document.addEventListener("deviceready", onDeviceReady, false);
}
function onDeviceReady(){
alert('onDeviceReady');
window.requestFileSystem(LocalFileSystem.PERSISTENT,0, gotFS, fail);
}
function gotFS(fileSystem){
alert('gotFS');
fileSystem.root.getDirectory("Android/data/com.example.tts/app_new_file",{create:true}, gotDir,fail);
}
function gotDir(dirEntry){
alert('gotDir');
dirEntry.getFile("GodIsGood2.txt",{create:true, exclusive:true}, gotFile,fail);
}
function gotFile(fileEntry){
alert('成功建立檔');
fileEntry.createWriter(onGetFileWriterSuccess, onGetFileWriterError);
}
function onGetFileWriterSuccess(writer){
writer.onwrite=onWriteSuccess;
writer.onerror=onWriteError;
writer.write("Some text to the file");
}
function onGetFileWriterError(err){
alert('onGetFileWriterError...'+err.code);
}
function onWriteSuccess(evt){
alert('YES!! DONE!');
}
function onWriteError(evt){
alert('onWriteError...'+evt.target.error.code);
}
function fail(evt){
alert(evt.error.code);
}
</script>
</body>
</html>