-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathnote_it.html
93 lines (88 loc) · 2.28 KB
/
note_it.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
81
82
83
84
85
86
87
88
89
90
91
92
93
<!doctype html>
<html>
<head>
<title>Note It!</title>
<script>
function saveNote(){
var currentDateAndTime = new Date()
var aNoteDescription = document.getElementById("description_input").value
var aNoteText = document.getElementById("note_editor").value
var aCompleteNote = currentDateAndTime.toLocaleString() + "--" + aNoteDescription
aCompleteNote += "<p>" + aNoteText + "</p>"
var storedNotesString = localStorage.getItem("all_notes")
var allNotes = JSON.parse(storedNotesString)
if(allNotes == null){
allNotes = []
}
allNotes.push(aCompleteNote)
var allNotesString = JSON.stringify(allNotes)
localStorage.setItem("all_notes",allNotesString)
showAllNotes()
document.getElementById("description_input").value = null
document.getElementById("note_editor").value = null
}
function showAllNotes(){
var storedNotesString = localStorage.getItem("all_notes")
allNotes = JSON.parse(storedNotesString)
if (allNotes != null){
var noteDisplayer = document.getElementById("all_notes_display")
noteDisplayer.innerHTML = null
var numberOfNotes = allNotes.length
for (var i = 0; i < allNotes.length; i++) {
var aNote = allNotes[i]
noteDisplayer.innerHTML += "<hr><p>"+ aNote +"</p>"
}
}
}
</script>
<style>
h1{
text-align: center;
}
body{
background-color: LightGrey;
}
input{
margin-top: 5px;
border:none;
border-radius:5px;
box-shadow:0px 0px 5px #666666 inset;
height:25px;
width:200px;
text-indent:5px;
}
input:focus {
outline:none;
}
textarea{
margin-top: 10px;
border:none;
border-radius:5px;
box-shadow:0px 0px 5px #666666 inset;
width:90%;
height: 150px;
text-indent:5px;
resize:none;
overflow: scroll;
}
#note_entry_area{
width: 500px;
padding-left: 5px;
border:none;
border-radius:5px;
box-shadow:0px 0px 5px #666666 inset;
text-indent:5px;
}
</style>
</head>
<body onload="showAllNotes()">
<section id="note_entry_area">
<h1>Note It!</h1>
Description: <input id="description_input"></input>
<textarea id="note_editor" placeholder="Note it down. Don't forget."></textarea>
<br>
<button onclick="saveNote()">Save</button>
</section>
<section id="all_notes_display"></section>
</body>
</html>