|
|
@ -35,7 +35,9 @@ function addListItem(task: Task) {
|
|
|
|
const item = document.createElement("li");
|
|
|
|
const item = document.createElement("li");
|
|
|
|
const label = document.createElement("label");
|
|
|
|
const label = document.createElement("label");
|
|
|
|
const deletebtn = document.createElement("button");
|
|
|
|
const deletebtn = document.createElement("button");
|
|
|
|
|
|
|
|
const editbtn = document.createElement("button");
|
|
|
|
deletebtn.classList.add("deletebtn");
|
|
|
|
deletebtn.classList.add("deletebtn");
|
|
|
|
|
|
|
|
editbtn.classList.add("editbtn");
|
|
|
|
const checkbox = document.createElement("input");
|
|
|
|
const checkbox = document.createElement("input");
|
|
|
|
checkbox.addEventListener("change", () => {
|
|
|
|
checkbox.addEventListener("change", () => {
|
|
|
|
task.completed = checkbox.checked; //with this, checkbox will be ticked
|
|
|
|
task.completed = checkbox.checked; //with this, checkbox will be ticked
|
|
|
@ -46,10 +48,14 @@ function addListItem(task: Task) {
|
|
|
|
label.append(checkbox, task.title);
|
|
|
|
label.append(checkbox, task.title);
|
|
|
|
item.append(label);
|
|
|
|
item.append(label);
|
|
|
|
item.append(deletebtn);
|
|
|
|
item.append(deletebtn);
|
|
|
|
|
|
|
|
item.append(editbtn);
|
|
|
|
list?.append(item);
|
|
|
|
list?.append(item);
|
|
|
|
deletebtn.addEventListener("click", function () {
|
|
|
|
deletebtn.addEventListener("click", function () {
|
|
|
|
item.parentNode?.removeChild(item);
|
|
|
|
item.parentNode?.removeChild(item);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
editbtn.addEventListener("click", function () {
|
|
|
|
|
|
|
|
label.blur();
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function saveTasks() {
|
|
|
|
function saveTasks() {
|
|
|
|