From 7cb456d495d4b4f0cf065600ee027fc1e78ee394 Mon Sep 17 00:00:00 2001 From: Daniel Aderibigbe Date: Tue, 31 Mar 2026 14:23:48 +0100 Subject: [PATCH] todo-list completed --- Sprint-3/todo-list/index.html | 74 ++++++++++++++++++------------- Sprint-3/todo-list/script.mjs | 40 ++++++++--------- Sprint-3/todo-list/style.css | 2 +- Sprint-3/todo-list/todos.mjs | 6 ++- Sprint-3/todo-list/todos.test.mjs | 27 ++++++----- 5 files changed, 85 insertions(+), 64 deletions(-) diff --git a/Sprint-3/todo-list/index.html b/Sprint-3/todo-list/index.html index 4d12c4654..799540bdb 100644 --- a/Sprint-3/todo-list/index.html +++ b/Sprint-3/todo-list/index.html @@ -1,40 +1,52 @@ - + - - - - ToDo List - - + + + + ToDo List + + - - - -
-

My ToDo List

+ + + +
+

My ToDo List

-
- - -
+
+ + +
+ + -
    -
+
    - - - -
    - + +
    + diff --git a/Sprint-3/todo-list/script.mjs b/Sprint-3/todo-list/script.mjs index ba0b2ceae..e783a2eb7 100644 --- a/Sprint-3/todo-list/script.mjs +++ b/Sprint-3/todo-list/script.mjs @@ -1,23 +1,27 @@ -// Store everything imported from './todos.mjs' module as properties of an object named Todos +// Store everything imported from './todos.mjs' module as properties of an object named Todos import * as Todos from "./todos.mjs"; // To store the todo tasks -const todos = []; +let 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").addEventListener("click", () => { + todos = Todos.deleteCompleted(todos); + render(); + }); + // Populate sample data - Todos.addTask(todos, "Wash the dishes", false); + Todos.addTask(todos, "Wash the dishes", false); Todos.addTask(todos, "Do the shopping", true); render(); }); - -// A callback that reads the task description from an input field and -// append a new task to the todo list. +// 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 task = taskInput.value.trim(); @@ -29,10 +33,7 @@ function addNewTodo() { taskInput.value = ""; } -// Note: -// - Store the reference to the