-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
80 lines (73 loc) · 2.24 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>My Web Note</title>
<link
rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T"
crossorigin="anonymous"
/>
<link
rel="stylesheet"
href="https://fonts.google.com/specimen/Josefin+Sans"
/>
<style>
body {
background-image: url("https://ak0.picdn.net/shutterstock/videos/935170/thumb/1.jpg");
}
</style>
</head>
<body>
<div class=" container">
<div class="raw" style="font-family: Josefin Sans, serif">
<h1 class="font-weight-bold text-center mt-5 mb-4">
Take Notes Here!!!
</h1>
<div
class="border rounded"
id="note"
style="overflow-y: scroll; height: 200px; background-color: white"
contenteditable
></div>
</div>
<div class="raw">
<div class="text-right my-3">
<button id="clear" class="btn btn-primary px-4">Clear</button>
<button id="save" class="btn btn-primary px-4">Save</button>
</div>
</div>
</div>
<script src="https://unpkg.com/filer/dist/filer.min.js"></script>
<script>
const fs = new Filer.FileSystem();
var note = document.querySelector("#note");
window.addEventListener("DOMContentLoaded", event => {
fs.readFile("/note", "utf8", function(err, data) {
if (err) {
throw err;
}
if (data) note.innerHTML = data;
else note.innerHTML = "Welcome to my notepad!";
});
document
.querySelector("#clear")
.addEventListener("click", clearContent);
document.querySelector("#save").addEventListener("click", saveContent);
});
function saveContent() {
fs.writeFile("/note", note.innerHTML, function(err) {
if (err) throw err;
if (note.innerHTML) alert("Contents saved!");
});
}
function clearContent() {
fs.writeFile("/note", "", function(err) {
if (err) throw err;
note.innerHTML = "";
});
}
</script>
</body>
</html>