forked from jatinAroraGit/note-down
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
79 lines (66 loc) · 2.75 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
<!doctype html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<head>
<link href="https://fonts.googleapis.com/css?family=Roboto+Slab&display=swap" rel="stylesheet">
<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="./main.css">
<meta charset="utf-8">
<title>Note Down</title>
</head>
<body>
<nav class="navbar navbar-light navbar-toggler bg-light">
<form class="form-inline">
<h1 id="title">NOTE DOWN</h1>
</form>
<form class="form-inline">
<button id="saveButton" class="btn btn-outline-success pull-right" type="button">Save All</button>
<a class="btn btn-info m-1 p-1" href="https://github.com/jatinAroraGit/note-down">Github</a>
</form>
</nav>
<p> Use Alt + S to Save the Note. Autosave enabled (Every 5 seconds)</p>
<div contenteditable="true" id="editor">
</div>
</body>
<script src="https://unpkg.com/hotkeys-js/dist/hotkeys.min.js"></script>
<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) {
if (err) {
document.querySelector('#editor').innerHTML = "Welocome To My Notepad"
}
else
if (data) {
document.querySelector('#editor').innerHTML = data;
}
})
var autosave = setInterval(setInterval(function () {
saveNote();
}, 5000));
function saveNote() {
console.log("Saving...");
fs.writeFile("/note", document.querySelector('#editor').innerHTML, function (err) {
if (err) {
return console.log(err);
}
else
console.log("SAVED !");
});
}
document.getElementById("saveButton").addEventListener("click",function(){ saveNote();
alert('Note Saved');} );
hotkeys.filter = function (event) {
var tagName = (event.target || event.srcElement).tagName;
return !(tagName.isContentEditable || tagName == 'INPUT' || tagName == 'SELECT' || tagName == 'TEXTAREA');
}
hotkeys('alt+s', function (event, handler) {
saveNote();
alert('Note Saved');
});
});
</script>
</html>