-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
92 lines (79 loc) · 2.12 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
var dt = new Date();
document.querySelector(".date").innerHTML = dt.toLocaleDateString();
loadevents();
function loadevents(){
document.addEventListener("keyup",submit);
document.getElementById("clear").addEventListener("click",refresh);
document.getElementById("list").addEventListener("click",tick_delete);
document.getElementById("clear_complete").addEventListener("click",delete_completetask);
}
function submit(e)
{
if(e.keyCode == 13)
{
let input = document.querySelector('input');
if(input.value!='')
{
addTask(input.value);
}
input.value = '';
}
}
function addTask(task)
{
let ul = document.querySelector('ul');
let li = document.createElement('li');
li.innerHTML = `<input type="checkbox"><label>${task}</label><i class="fa fa-trash" aria-hidden="true"></i>`;
ul.appendChild(li);
document.querySelector('.content').style.display = 'block';
}
function refresh()
{
let ul = document.querySelector('ul');
ul.innerHTML = '';
}
function tick_delete(e)
{
if(e.target.className == 'fa fa-trash')
deletetask(e);
else
completetask(e);
}
function deletetask(e)
{
let remove = e.target.parentNode;
let parent = remove.parentNode;
parent.removeChild(remove);
}
function completetask(e)
{
const text = e.target.nextSibling;
//console.log(e.target);
if(e.target.checked)
{
text.style.textDecoration = "line-through";
text.style.color = "black";
}
else
{
text.style.textDecoration = "none";
text.style.color = "black";
}
}
function delete_completetask(e)
{
const ul = document.querySelector('ul');
var i = 0;
//console.log(ul.childElementCount);
for(i = 0;i<=ul.childElementCount;i++)
{
// console.log(ul.childNodes[i],ul.childNodes[i].firstChild);
// console.log(ul.childNodes[i].firstChild.checked);
if(ul.childNodes[i].firstChild.checked == true)
{
ul.removeChild(ul.childNodes[i]);
i = i -1;
}
}
}
console.log(document.querySelector(".footer-container").width);