-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
95 lines (51 loc) · 1.76 KB
/
index.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
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
let SpanEkle = document.getElementById("liveToastBtn");
let GirilenYazi = document.getElementById("task");
let UlDom = document.querySelector("ul");
let itemsArray = localStorage.getItem('items') ? JSON.parse(localStorage.getItem('items')) : [];
localStorage.setItem('items', JSON.stringify(itemsArray));
const data = JSON.parse(localStorage.getItem('items'));
SpanEkle.addEventListener("click",function(){
if(GirilenYazi.value !=0){
let DivDom = document.createElement("div");
DivDom.setAttribute("onclick","allert(this);")
let LiDom = document.createElement("li");
let ADom = document.createElement("a");
ADom.setAttribute("onclick","event.stopPropagation(); alllert2(this);");
LiDom.innerHTML=`${GirilenYazi.value}`;
ADom.innerHTML=`×`
DivDom.append(LiDom,ADom);
UlDom.append(DivDom);
itemsArray.push(GirilenYazi.value);
localStorage.setItem('items', JSON.stringify(itemsArray));
GirilenYazi.value="";
$(document).ready(function(){
$('.toast.success').toast('show');
});
}
else{
$(document).ready(function(){
$('.toast.error.hide').toast('show');
});
}
});
data.forEach(item => {
divMaker(item);
});
function divMaker(text1){
let DivDom = document.createElement("div");
DivDom.setAttribute("onclick","allert(this);")
let LiDom = document.createElement("li");
let ADom = document.createElement("a");
ADom.setAttribute("onclick","event.stopPropagation(); alllert2(this);");
LiDom.innerHTML=text1;
ADom.innerHTML=`×`
DivDom.append(LiDom,ADom);
UlDom.append(DivDom);
}
function allert(a){
a.classList.add("checked");
}
function alllert2(a){
localStorage.clear();
a.parentElement.remove();
}