-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
36 lines (33 loc) · 1016 Bytes
/
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
<!DOCTYPE html>
<head>
<link rel="stylesheet" href="index.css">
<script src="index.js"></script>
<title>Note Taker App</title>
</head>
<body>
<div class="front-page">
<h2 class="header">Note Taker App</h2>
<textarea id="note" name="note-text" class="note-area"></textarea>
<br>
<button id="submit" onclick="saveNote()" class="bg">Save Note</button>
<div class="notes-link">
<button class="bg"><a style="text-decoration: none; color: white;" href="index2.html">View Notes</a></button>
</div>
</div>
</body>
<script>
var textElement = document.getElementById("note")
function saveNote() {
if(textElement.value == "") {
return alert('Text is empty!')
}
const id = getNoteId()
let noteObject = getExistingNotes()
if(!noteObject){
noteObject = {}
}
noteObject[id] = textElement.value
localStorage.setItem('notes', JSON.stringify(noteObject))
alert('Note Saved')
}
</script>