-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathread.html
61 lines (50 loc) · 1.24 KB
/
read.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<!DOCTYPE html>
<html>
<head>
<script src="architect://architect.js"></script>
</head>
<body>
<script>
function errorHandler(e){
var msg = '';
switch (e.code){
case FileError.QUOTA_EXCEEDED_ERR:
msg = 'QUOTA_EXCEEDED_ERR';
break;
case FileError.NOT_FOUND_ERR:
msg = 'NOT_FOUND_ERR';
break;
case FileError.SECURITY_ERR:
msg = 'SECURITY_ERR';
break;
case FileError.INVALID_MODIFICATION_ERR:
msg = 'INVALID_MODIFICATION_ERR';
break;
case FileError.INVALID_STATE_ERR:
msg = 'INVALID_STATE_ERR';
break;
default:
msg = 'Unknown Error';
break;
};
alert('Error: ' + msg);
}
function onReadInitFs(fs) {
fs.root.getFile('log.txt', {}, function(fileEntry) {
// Get a File object representing the file,
// then use FileReader to read its contents.
fileEntry.file(function(file) {
var reader = new FileReader();
reader.onloadend = function(e) {
alert("Text read: " + this.result);
};
reader.readAsText(file);
}, errorHandler);
}, errorHandler);
}
setTimeout(function readFromFile(){
window.webkitRequestFileSystem(window.TEMPORARY, 1024*1024, onReadInitFs, errorHandler);
}, 6000);
</script>
</body>
</html>