-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
147 lines (73 loc) · 2.86 KB
/
main.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
document.getElementById("cancel-btn").addEventListener("click", function(){
document.getElementById("input-box").value = "";
})
var count=0;
var count2 = 0;
var count3 = 0;
function doit(){
if(document.getElementById("input-box").value==""){
alert("Empty field not allowed");
}
else{
const parentDiv = document.createElement("div");
const textDiv = document.createElement("div");
const btnDiv = document.createElement("div");
const deleteBtn = document.createElement("button");
const doneBtn = document.createElement("button");
const timeDiv = document.createElement("div");
const editBtn = document.createElement("button");
const timeDiv2 = document.createElement("div");
parentDiv.className = "parent";
textDiv.className = "list";
btnDiv.className = "btn-div";
deleteBtn.className = "delete-btn";
doneBtn.className = "done-btn";
timeDiv.className = "details-div";
timeDiv2.className = "time-div"
btnDiv.append(deleteBtn);
btnDiv.append(doneBtn);
parentDiv.append(textDiv);
parentDiv.append(timeDiv);
timeDiv.append(timeDiv2);
timeDiv.append(btnDiv);
// timeDiv.append(btnDiv);
// parentDiv.append(btnDiv);
document.getElementById("list-items").appendChild(parentDiv);
const deleteBtnText = document.createTextNode("Delete");
deleteBtn.append(deleteBtnText);
const editBtnText = document.createTextNode("Edit");
editBtn.append(editBtnText);
const doneBtnText = document.createTextNode("Done");
doneBtn.append(doneBtnText);
const titleText = document.getElementById('input-box').value;
const msgText = document.createTextNode(titleText);
textDiv.appendChild(msgText);
deleteBtn.id = count;
parentDiv.id = "p"+count;
deleteBtn.addEventListener("click",function(){
document.getElementById("p"+this.id).remove();
})
doneBtn.id = count2;
textDiv.id = "tp"+count2;
doneBtn.addEventListener("click", function(){
document.getElementById("tp"+this.id).style.textDecoration = "line-through";
document.getElementById("tp"+this.id).style.color = "grey";
})
var d = new Date();
var date = d.getDate();
var month = d.getMonth();
var year = d.getFullYear();
var hrs = d.getHours();
var min = d.getMinutes();
var sec = d.getSeconds();
if(month==0){
month ="Jan";
}
const dateDetails = document.createTextNode(date+" "+month+", "+year+" | "+hrs+" : "+min+" : "+sec);
timeDiv2.append(dateDetails);
editBtn.id = count2;
document.getElementById("input-box").value = "";
count++;
count2++;
}
}