-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
57 lines (51 loc) · 2.04 KB
/
index.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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/paper.min.css"/>
<link rel="stylesheet" href="index.css">
<title>foreverNote</title>
</head>
<body>
<div id="header">
<h1>foreverNote</h1>
<p>Welcome to foreverNote. It saves every 10s.</p>
</div>
<div id="note" contenteditable="true" style="min-height:15px"></div>
<button onclick="saveNote()">Save</button>
<button onclick="clearNote()">Clear</button>
<script src="https://unpkg.com/filer/dist/filer.min.js"></script>
<script>
const fs = new Filer.FileSystem();
window.addEventListener('DOMContentLoaded', (event) => {
console.log('DOM fully loaded and parsed');
fs.readFile('/note', 'utf8', function(err, data) {
var contents = "Welcome to my notepad!";
if(err){
document.querySelector('#note').innerHTML = contents;
console.log('Error in this bitch');
throw err;
}
if(data){
document.querySelector('#note').innerHTML = data;
console.log(data);
}
})
});
window.setInterval(callback10Secs, 10000);
function callback10Secs(){
fs.writeFile('/note', document.querySelector('#note').innerHTML, 'utf8', function (err) {
if (err) throw err;
});
}
function saveNote() {
fs.writeFile('/note', document.querySelector('#note').innerHTML, 'utf8', function (err) {
if (err) throw err;
});
}
function clearNote() {
document.querySelector('#note').innerHTML = ""
}
</script>
</body>
</html>