-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
64 lines (49 loc) · 2 KB
/
index.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
let counter = 0;
document.querySelector(".btn-large").addEventListener("click", () => {
if(counter<7){
const newLi = document.createElement("li");
newLi.setAttribute("class", "single-task");
const newInput = document.createElement("input");
newInput.setAttribute("type", "text");
newInput.setAttribute("placeholder", "Tytuł zadania...");
newInput.style.textDecoration = "none";
newLi.appendChild(newInput);
const newA1 = document.createElement("a");
newA1.setAttribute("class", "waves-effect waves-light btn-small completeBtn");
const newI1 = document.createElement("i");
newI1.setAttribute("class", "material-icons left strike");
newI1.textContent = "check";
newA1.appendChild(newI1);
newLi.appendChild(newA1);
const newA2 = document.createElement("a");
newA2.setAttribute("class", "waves-effect waves-light btn-small deleteBtn");
const newI2 = document.createElement("i");
newI2.setAttribute("class", "material-icons left del");
newI2.textContent = "clear";
newA2.appendChild(newI2);
newLi.appendChild(newA2);
const ul = document.querySelector("div.bottom-app-container > ul");
ul.appendChild(newLi);
counter++;
}
});
document.querySelector("div.bottom-app-container > ul").addEventListener('click', (e) => {
if (e.target.classList.contains('del')) {
const currentLi = e.target.parentNode.parentNode;
currentLi.parentNode.removeChild(currentLi);
counter--;
}
e.stopPropagation;
});
document.querySelector("div.bottom-app-container > ul").addEventListener("click", e => {
if (e.target.classList.contains("strike")) {
const currentLi = e.target.parentNode.parentNode;
if (currentLi.firstChild.style.textDecoration == "none") {
currentLi.firstChild.style.textDecoration = "line-through";
} else {
currentLi.firstChild.style.textDecoration = "none";
}
e.target.parentNode.classList.toggle("changeCompleteBtn");
}
e.stopPropagation;
});