diff --git a/Sprint-3/todo-list/index.html b/Sprint-3/todo-list/index.html index 4d12c4654..e372757ba 100644 --- a/Sprint-3/todo-list/index.html +++ b/Sprint-3/todo-list/index.html @@ -15,9 +15,10 @@

My ToDo List

+
- + diff --git a/Sprint-3/todo-list/script.mjs b/Sprint-3/todo-list/script.mjs index ba0b2ceae..efddc4ce8 100644 --- a/Sprint-3/todo-list/script.mjs +++ b/Sprint-3/todo-list/script.mjs @@ -7,7 +7,9 @@ const todos = []; // Set up tasks to be performed once on page load window.addEventListener("load", () => { document.getElementById("add-task-btn").addEventListener("click", addNewTodo); - + document + .getElementById("delete-completed-btn") + .addEventListener("click", deleteCompletedTodos); // Populate sample data Todos.addTask(todos, "Wash the dishes", false); Todos.addTask(todos, "Do the shopping", true); @@ -15,20 +17,25 @@ window.addEventListener("load", () => { render(); }); - +function deleteCompletedTodos() { + Todos.deleteCompleted(todos); + render(); +} // A callback that reads the task description from an input field and // append a new task to the todo list. function addNewTodo() { const taskInput = document.getElementById("new-task-input"); + const deadlineInput = document.getElementById("deadline-input"); const task = taskInput.value.trim(); + const deadline = deadlineInput.value; if (task) { - Todos.addTask(todos, task, false); + Todos.addTask(todos, task, false, deadline); + console.log(todos); render(); } - taskInput.value = ""; + deadlineInput.value = ""; } - // Note: // - Store the reference to the