-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
119 lines (96 loc) · 3.21 KB
/
script.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
window.onload = function () {
document.getElementById("txt").focus();
}
$(document).keypress(function (e) {
if (e.which == 13) {
$("#btn").click();
}
});
function popUp() {
var popup = document.getElementById("myPopup");
popup.classList.toggle("show");
}
function addItem() {
if (document.querySelector('#txt').value != "") {
document.querySelector('.lii').innerHTML +=
`<div class='list' >
<input type="checkbox" name="checkBoxx" onclick="checkBoxClick()" class="checkBox myCheckbox"/>
<span class="todo-description">
<span class="title"> ${document.querySelector('#txt').value}</span>
<span id="displayDate">${new Date().toLocaleString()}</span>
</span>
<i id="del" class="fa-solid fa-trash-can fa-xs close"></i> `;
document.querySelector('#txt').value = "";
}
else {
// alert("Enter something to Add!");
popUp()
setTimeout(() => {
popUp()
}, 3000);
document.getElementById('#txt').focus();
}
var current_tasks = document.querySelectorAll(".close");
for (var i = 0; i < current_tasks.length; i++) {
current_tasks[i].onclick = function () {
this.parentNode.remove();
}
}
}
function checkBoxClick(){
//create an array of all the checkboxes
var checkboxes = document.querySelectorAll('.checkBox');
var done = document.getElementById("lii-done");
var todo = document.getElementById("todo");
//loop through the array and add an event listener to each checkbox
for (var i = 0; i < checkboxes.length; i++) {
checkboxes[i].addEventListener('change', function() {
//if the checkbox is checked
if (this.checked) {
//add the checked class to the parent label
this.parentNode.classList.add('checked');
this.parentNode.style.display = "none";
//append the parent label to the done list
done.appendChild(this.parentNode);
this.parentNode.style.display = "inline-flex";
} else {
//remove the checked class from the parent label
this.parentNode.classList.remove('checked');
this.parentNode.style.display = "none";
//append the parent label to the todo list
todo.appendChild(this.parentNode);
this.parentNode.style.display = "inline-flex";
}
});
}
}
$(document).ready(function() {
$("button").click(function() {
$("#container").append($("#submit"));
})
});
var acc = document.getElementsByClassName("container");
var accd = document.getElementById("done");
var i;
for (i = 0; i < acc.length; i++) {
acc[i].addEventListener("click", function() {
this.classList.toggle("active");
var panel = this.nextElementSibling;
if (panel.style.maxHeight) {
panel.style.maxHeight = null;
} else {
panel.style.maxHeight = panel.scrollHeight + "px";
}
});
}
for (i = 0; i < accd.length; i++) {
accd[i].addEventListener("click", function() {
this.classList.toggle("active");
var panel = this.nextElementSibling;
if (panel.style.maxHeight) {
panel.style.maxHeight = null;
} else {
panel.style.maxHeight = panel.scrollHeight + "px";
}
});
}