-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
76 lines (66 loc) · 2.15 KB
/
app.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
const addItem=document.getElementById("listBlank");
const dateInfo=document.getElementById("dateTime");
const addButton=document.getElementById("submitButton");
let done=0;
let removed=0;
let yDone=0;
let yRemove=0;
const toDoList = document.getElementsByTagName("LI");
const remove = document.getElementsByClassName("remove");
function newElement() {
const li = document.createElement("li");
const inputValue = document.getElementById("listBlank").value;
const t = document.createTextNode(inputValue);
const dated = document.createTextNode(dateInfo.value+" " );
li.appendChild(dated);
li.appendChild(t);
if (inputValue === '' && dateInfo.value=== '') {
alert("You cannot pass without writing some To Do Item and date time!");
} else {
document.getElementById("lists").appendChild(li);
}
document.getElementById("listBlank").value = "";
document.getElementById("dateTime").value="";
const span = document.createElement("SPAN");
const txt = document.createTextNode("Remove");
span.className = "remove";
span.appendChild(txt);
li.appendChild(span);
for (i = 0; i < remove.length; i++) {
remove[i].onclick = function() {
const div = this.parentElement;
div.style.display = "none";
done--;
removed++;
removeRate.innerHTML=removed;
yRemove=removed;
}
}
}
//remove
for (i = 0; i < toDoList.length; i++) {
const span = document.createElement("SPAN");
const txt = document.createTextNode("Remove");
span.className = "remove";
span.appendChild(txt);
toDoList[i].appendChild(span);
}
//check
const list = document.querySelector('ul');
list.addEventListener('click', function(ev) {
if (ev.target.tagName === 'LI') {
ev.target.classList.toggle('checked');
done++;
doneRate.innerHTML=done;
yDone=done;
}
}, false);
//reting panel
const doneRate=document.getElementById("doneRate");
const removeRate=document.getElementById("removed");
function alerting() {
var x;
if (confirm("Are you Sure? Because you will clear all items if you push OK button") == true) {
window.location.reload();
}
}