Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
126 lines (98 loc) · 3.13 KB
/
Copy pathscript.js
File metadata and controls
126 lines (98 loc) · 3.13 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
let allNotes = {
notesTitles: [],
notes: [],
archivNotesTitles: [],
archivNotes: [],
trashNotesTitle: [],
trashNotes: [],
};
function init() {
getFromLocalStorage();
renderNotes();
renderArchiveNotes();
renderTrashNotes();
}
function renderNotes() {
let contentRef = document.getElementById("content");
contentRef.innerHTML = "";
for (let i = 0; i < allNotes.notes.length; i++) {
contentRef.innerHTML += getNoteTemplate(i);
}
}
function renderArchiveNotes() {
let archiveContentRef = document.getElementById("archive_content");
archiveContentRef.innerHTML = "";
for (let i = 0; i < allNotes.archivNotes.length; i++) {
archiveContentRef.innerHTML += getArchiveNoteTemplate(i);
}
}
function renderTrashNotes() {
let trashContentRef = document.getElementById("trash_content");
trashContentRef.innerHTML = "";
for (let i = 0; i < allNotes.trashNotes.length; i++) {
trashContentRef.innerHTML += getTrashNoteTemplate(i);
}
}
function addNote() {
let titleInputRef = document.getElementById("title_input");
let noteInputRef = document.getElementById("note_input");
if (titleInputRef.value != "" && noteInputRef.value != "") {
allNotes.notesTitles.push(titleInputRef.value);
allNotes.notes.push(noteInputRef.value);
saveToLocalStorage();
renderNotes();
titleInputRef.value = "";
noteInputRef.value = "";
}
}
function noteToArchive(index) {
allNotes.archivNotes.push(allNotes.notes[index]);
allNotes.archivNotesTitles.push(allNotes.notesTitles[index]);
allNotes.notes.splice(index, 1);
allNotes.notesTitles.splice(index, 1);
saveToLocalStorage();
renderNotes();
renderArchiveNotes();
}
function restoreFromArchive(index) {
allNotes.notes.push(allNotes.archivNotes[index]);
allNotes.notesTitles.push(allNotes.archivNotesTitles[index]);
allNotes.archivNotes.splice(index, 1);
allNotes.archivNotesTitles.splice(index, 1);
saveToLocalStorage();
renderNotes();
renderArchiveNotes();
}
function archiveToTrash(index) {
allNotes.trashNotes.push(allNotes.archivNotes[index]);
allNotes.trashNotesTitle.push(allNotes.archivNotesTitles[index]);
allNotes.archivNotes.splice(index, 1);
allNotes.archivNotesTitles.splice(index, 1);
saveToLocalStorage();
renderArchiveNotes();
renderTrashNotes();
}
function noteToTrash(index) {
allNotes.trashNotes.push(allNotes.notes[index]);
allNotes.trashNotesTitle.push(allNotes.notesTitles[index]);
allNotes.notes.splice(index, 1);
allNotes.notesTitles.splice(index, 1);
saveToLocalStorage();
renderNotes();
renderTrashNotes();
}
function restoreFromTrash(index) {
allNotes.notes.push(allNotes.trashNotes[index]);
allNotes.notesTitles.push(allNotes.trashNotesTitle[index]);
allNotes.trashNotes.splice(index, 1);
allNotes.trashNotesTitle.splice(index, 1);
saveToLocalStorage();
renderNotes();
renderTrashNotes();
}
function deleteNote(index) {
allNotes.trashNotes.splice(index, 1);
allNotes.trashNotesTitle.splice(index, 1);
saveToLocalStorage();
renderTrashNotes();
}