FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Javascript_implementation/journal.js at main · TheCodeCipher/Javascript_implementation · GitHub
TheCodeCipher
/
Javascript_implementation
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Javascript_implementation
/
journal.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
42 lines (36 loc) · 1009 Bytes
Breadcrumbs
Javascript_implementation
/
journal.js
Copy path
File metadata and controls
42 lines (36 loc) · 1009 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
window
.
onload
=
function
(
)
{
loadEntries
(
)
;
}
;
function
saveEntry
(
)
{
const
text
=
document
.
getElementById
(
"journalEntry"
)
.
value
.
trim
(
)
;
if
(
!
text
)
{
alert
(
"Please write something before saving."
)
;
return
;
}
const
entry
=
{
content
:
text
,
date
:
new
Date
(
)
.
toLocaleString
(
)
,
}
;
let
journal
=
JSON
.
parse
(
localStorage
.
getItem
(
"journal"
)
)
||
[
]
;
journal
.
unshift
(
entry
)
;
localStorage
.
setItem
(
"journal"
,
JSON
.
stringify
(
journal
)
)
;
document
.
getElementById
(
"journalEntry"
)
.
value
=
""
;
loadEntries
(
)
;
}
function
loadEntries
(
)
{
const
journal
=
JSON
.
parse
(
localStorage
.
getItem
(
"journal"
)
)
||
[
]
;
const
container
=
document
.
getElementById
(
"entries"
)
;
container
.
innerHTML
=
""
;
if
(
journal
.
length
===
0
)
{
container
.
innerHTML
=
"<p>No entries yet.</p>"
;
return
;
}
journal
.
forEach
(
(
entry
)
=>
{
container
.
innerHTML
+=
`
<div class="entry">
<time>
${
entry
.
date
}
</time>
<p>
${
entry
.
content
}
</p>
</div>
`
;
}
)
;
}
Back
|
FazBrowse Home
|
New Git URL