-
Notifications
You must be signed in to change notification settings - Fork 0
/
content.js
39 lines (34 loc) · 1.09 KB
/
content.js
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
function loadMyDodo() {
function store() {
window.localStorage.myItems = document.querySelector("#list").innerHTML;
}
function addItems() {
document.addEventListener("DOMContentLoaded", createList);
function createList() {
document.querySelector("form").addEventListener("submit", saveItem);
function saveItem(e) {
e.preventDefault();
document.querySelector("#list").innerHTML +=
"<li>" + document.querySelector("#item").value + "</li>";
store();
document.querySelector("#item").value = "";
}
false;
document.querySelector("#list").addEventListener("click", clickItem);
function clickItem(e) {
e.target.classList.contains("checked")
? e.target.parentNode.removeChild(e.target)
: e.target.classList.add("checked");
store();
}
false;
}
}
addItems();
function getValues() {
if (window.localStorage.myItems)
document.querySelector("#list").innerHTML = window.localStorage.myItems;
}
getValues();
}
loadMyDodo();