-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtodo.js
More file actions
51 lines (42 loc) · 1.2 KB
/
Copy pathtodo.js
File metadata and controls
51 lines (42 loc) · 1.2 KB
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
let Count = 0;
function displayList(){
let xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if(xhr.readyState == 4 && xhr.status == 200) {
let myobj = JSON.parse(this.responseText);
setTable(myobj);
}
};
xhr.open("GET","https://jsonplaceholder.typicode.com/todos");
xhr.send();
$(".todolist").css("visibility", "visible");
}
function setTable(obj) {
let row = "";
for(let i = 0; i < obj.length; i++) {
let status = obj[i].completed;
if(status == true) {
row += `<input type = "checkbox" id = "c${i}" disabled checked>`;
}
else
{
row += `<input type = "checkbox" id = "c${i}" onchange = "popUp(this)">`;
}
row += `<label for = "c${i}">${obj[i].title}</label><br><hr>`;
}
document.querySelector(".todolist").innerHTML += row;
}
function popUp(checkBox) {
if(checkBox.checked == true){
Count++;
}
else {
Count--;
}
if(Count == 5) {
$(".popup").css("visibility", "visible");
}
$("#popbtn").on("click", () => {
$(".popup").css("visibility", "hidden");
});
}