From 8f25d6d8830a3b5d069ad49ba1608635d42c6384 Mon Sep 17 00:00:00 2001 From: Alina Sofragiu Date: Sun, 19 Jul 2026 22:07:26 +0100 Subject: [PATCH 1/2] to-do list --- Sprint-3/todo-list/index.html | 74 ++++++++++++++++++------------- Sprint-3/todo-list/script.mjs | 26 ++++++----- Sprint-3/todo-list/todos.mjs | 10 ++++- Sprint-3/todo-list/todos.test.mjs | 28 +++++++----- 4 files changed, 86 insertions(+), 52 deletions(-) diff --git a/Sprint-3/todo-list/index.html b/Sprint-3/todo-list/index.html index 4d12c4654..bcf049a58 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..f95072952 100644 --- a/Sprint-3/todo-list/script.mjs +++ b/Sprint-3/todo-list/script.mjs @@ -1,4 +1,4 @@ -// 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 @@ -8,15 +8,18 @@ const todos = []; 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, "Wash the dishes", false); Todos.addTask(todos, "Do the shopping", true); render(); }); - -// A callback that reads the task description from an input field and +// 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"); @@ -29,6 +32,10 @@ function addNewTodo() { taskInput.value = ""; } +function deleteCompletedTodos() { + Todos.deleteCompleted(todos); + render(); +} // Note: // - Store the reference to the