From 924fde04c3d4a9d704e0ae4cc5ad90b5fa4ddebe Mon Sep 17 00:00:00 2001 From: Tobias Date: Tue, 28 Jul 2026 15:58:50 +0100 Subject: [PATCH 01/15] Added a button id for deletedcompleted job in the index .html file --- Sprint-3/todo-list/index.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sprint-3/todo-list/index.html b/Sprint-3/todo-list/index.html index 4d12c4654..0c7960cee 100644 --- a/Sprint-3/todo-list/index.html +++ b/Sprint-3/todo-list/index.html @@ -20,6 +20,8 @@

My ToDo List

+ + Task description -
+ +
From 251083e9f5ae0ab1a1238374996078d973846791 Mon Sep 17 00:00:00 2001 From: Tobias Date: Tue, 28 Jul 2026 17:14:54 +0100 Subject: [PATCH 12/15] set deadline text in the script.mjs file --- Sprint-3/todo-list/script.mjs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sprint-3/todo-list/script.mjs b/Sprint-3/todo-list/script.mjs index e32877c9b..7b5eff1ea 100644 --- a/Sprint-3/todo-list/script.mjs +++ b/Sprint-3/todo-list/script.mjs @@ -81,6 +81,12 @@ function createListItem(todo, index) { if (todo.completed) { li.classList.add("completed"); } + const deadlineEl = li.querySelector(".deadline"); + if (todo.deadline) { + deadlineEl.textContent = `Deadline: ${todo.deadline}`; + } else { + deadlineEl.textContent = ""; + } li.querySelector('.complete-btn').addEventListener("click", () => { Todos.toggleCompletedOnTask(todos, index); From fd329c5f28e6c408ff05c6cba9b88ec472c85f34 Mon Sep 17 00:00:00 2001 From: Tobias Date: Tue, 28 Jul 2026 17:23:46 +0100 Subject: [PATCH 13/15] Add helper function to show the remaining days --- Sprint-3/todo-list/script.mjs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Sprint-3/todo-list/script.mjs b/Sprint-3/todo-list/script.mjs index 7b5eff1ea..713e9a8d8 100644 --- a/Sprint-3/todo-list/script.mjs +++ b/Sprint-3/todo-list/script.mjs @@ -72,6 +72,28 @@ function render() { // - This variable is declared here to be close to the only function that uses it. const todoListItemTemplate = document.getElementById("todo-item-template").content.firstElementChild; + function getDaysRemainingText(deadline) { + if (!deadline) return ""; + + const today = new Date(); + today.setHours(0, 0, 0, 0); + + const deadlineDate = new Date(deadline); + deadlineDate.setHours(0, 0, 0, 0); + + const msPerDay = 1000 * 60 * 60 * 24; + const diffDays = Math.round((deadlineDate - today) / msPerDay); + + if (diffDays === 0) { + return "Due today"; + } else if (diffDays > 0) { + return `${diffDays} day${diffDays === 1 ? "" : "s"} left`; + } else { + const overdueDays = Math.abs(diffDays); + return `Overdue by ${overdueDays} day${overdueDays === 1 ? "" : "s"}`; + } + } + // Create a
  • element for the given todo task function createListItem(todo, index) { From 85a63c83b6da6ecc78a9623eb411cb51b47f6b1d Mon Sep 17 00:00:00 2001 From: Tobias Date: Tue, 28 Jul 2026 17:25:50 +0100 Subject: [PATCH 14/15] Updated list item of deadline to handle remaing days --- Sprint-3/todo-list/script.mjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sprint-3/todo-list/script.mjs b/Sprint-3/todo-list/script.mjs index 713e9a8d8..bd28dabe5 100644 --- a/Sprint-3/todo-list/script.mjs +++ b/Sprint-3/todo-list/script.mjs @@ -105,11 +105,12 @@ function createListItem(todo, index) { } const deadlineEl = li.querySelector(".deadline"); if (todo.deadline) { - deadlineEl.textContent = `Deadline: ${todo.deadline}`; + deadlineEl.textContent = getDaysRemainingText(todo.deadline); } else { deadlineEl.textContent = ""; } + li.querySelector('.complete-btn').addEventListener("click", () => { Todos.toggleCompletedOnTask(todos, index); render(); From 71aac32e20a6e0409267fbaf5a1823687fd611ba Mon Sep 17 00:00:00 2001 From: Tobias Date: Tue, 28 Jul 2026 18:15:42 +0100 Subject: [PATCH 15/15] Wrote a test to pass Deadline feature --- Sprint-3/todo-list/todos.test.mjs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Sprint-3/todo-list/todos.test.mjs b/Sprint-3/todo-list/todos.test.mjs index dd8ee1fd0..d09e3446b 100644 --- a/Sprint-3/todo-list/todos.test.mjs +++ b/Sprint-3/todo-list/todos.test.mjs @@ -18,14 +18,13 @@ function createMockTodos() { } // A mock task to simulate user input -const theTask = { task: "The Task", completed: false }; +const theTask = { task: "The Task", completed: false, deadline: null }; describe("addTask()", () => { test("Add a task to an empty ToDo list", () => { let todos = []; - Todos.addTask(todos, theTask.task, theTask.completed); - expect(todos).toHaveLength(1); - expect(todos[0]).toEqual(theTask); + Todos.addTask(todos, theTask.task, theTask.completed); + expect(todos[todos.length - 1]).toEqual(theTask); }); test("Should append a new task to the end of a ToDo list", () => {