Skip to content

Commit

Permalink
Merge pull request avinash201199#199 from nooras/deleteTodo
Browse files Browse the repository at this point in the history
Delete todo issue fixed avinash201199#187
  • Loading branch information
avinash201199 authored Oct 9, 2022
2 parents d40f083 + 07837b2 commit 1b0742e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,10 @@ function removeLocalTodos(todo) {
} else {
todos = JSON.parse(localStorage.getItem("todos"));
}
const todoIndex = todo.children[0].innerText;
todos.splice(todos.indexOf(todoIndex), 1);
if (!isNaN(todo.getAttribute("key"))) {
const todoKey = Number(todo.getAttribute("key"));
todos = todos.filter((todo) => todo.id !== todoKey);
}
localStorage.setItem("todos", JSON.stringify(todos));
}

Expand Down Expand Up @@ -425,7 +427,6 @@ function deleteAll() {

function openmodal(color, message, timer = 3000) {
//pass color as either 'red' (for error), 'blue' for info and 'green' for success
console.log("in");
document.getElementById("content").classList.add(color);
document.getElementById("modal-text").innerText = message;
document.getElementById("Modal").classList.add("true");
Expand Down

0 comments on commit 1b0742e

Please sign in to comment.