change todo list but not saved in localstorage yet

master
joak 2 years ago
parent e8da8e9dea
commit aeb794cc85

@ -62,6 +62,7 @@ function addListItem(task: Task) {
}); });
editbtn.addEventListener("click", function () { editbtn.addEventListener("click", function () {
label?.focus(); label?.focus();
changeTask(item);
}); });
} }
@ -74,3 +75,20 @@ function loadTasks(): Task[] {
if (taskJSON == null) return []; //if taskJSON is null, return to an empty array if (taskJSON == null) return []; //if taskJSON is null, return to an empty array
return JSON.parse(taskJSON); // if it's not null, return to the taskJSON. As : Task[] is written after func loadTasks(), it will specifically parse the array. Without it, it will parse anything return JSON.parse(taskJSON); // if it's not null, return to the taskJSON. As : Task[] is written after func loadTasks(), it will specifically parse the array. Without it, it will parse anything
} }
function changeTask(item) {
var changer = document.createElement("input");
changer.className = "changer";
var text = item.firstChild.innerHTML;
changer.value = text.replace('<input type="checkbox">',"");
item.append(changer);
var button = document.createElement("button");
button.innerHTML = "X"
item.append(button);
button.addEventListener("click", function (){
item.firstChild.innerHTML = '<input type="checkbox">'+ changer.value;
changer.remove();
button.remove();
});
}

Loading…
Cancel
Save