From df6a0cfff03334199747a8d176d2ba64e8406c79 Mon Sep 17 00:00:00 2001 From: Maryam Janjua Date: Fri, 21 Aug 2026 09:08:52 +0100 Subject: [PATCH] Complete todo list app --- Sprint-3/todo-list/index.html | 3 ++- Sprint-3/todo-list/script.mjs | 27 +++++++++++++++++------- Sprint-3/todo-list/style.css | 39 ++++++++++++++++++++++++++++++++--- Sprint-3/todo-list/todos.mjs | 21 ++++++++++++++----- 4 files changed, 73 insertions(+), 17 deletions(-) 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