From d59889401cc6dffc08eb0ede8dfb813ff6a657d6 Mon Sep 17 00:00:00 2001 From: Mona-Eltantawy Date: Wed, 1 Apr 2026 18:34:16 +0100 Subject: [PATCH 1/5] created a new brach and renamed the index html file to Alarmclockapp --- Sprint-3/alarmclock/{index.html => Alarmclockapp .html} | 0 Sprint-3/todo-list/index.html | 8 ++++++++ Sprint-3/todo-list/script.mjs | 9 ++++++++- 3 files changed, 16 insertions(+), 1 deletion(-) rename Sprint-3/alarmclock/{index.html => Alarmclockapp .html} (100%) diff --git a/Sprint-3/alarmclock/index.html b/Sprint-3/alarmclock/Alarmclockapp .html similarity index 100% rename from Sprint-3/alarmclock/index.html rename to Sprint-3/alarmclock/Alarmclockapp .html diff --git a/Sprint-3/todo-list/index.html b/Sprint-3/todo-list/index.html index 4d12c4654..d778d1d55 100644 --- a/Sprint-3/todo-list/index.html +++ b/Sprint-3/todo-list/index.html @@ -34,6 +34,14 @@

My ToDo List

+
+
+
+

Completed Tasks

+ + +
diff --git a/Sprint-3/todo-list/script.mjs b/Sprint-3/todo-list/script.mjs index ba0b2ceae..176b04410 100644 --- a/Sprint-3/todo-list/script.mjs +++ b/Sprint-3/todo-list/script.mjs @@ -73,4 +73,11 @@ function createListItem(todo, index) { }); return li; -} \ No newline at end of file +} + +const completedList= document.querySelector("#completed-list"); +const deleteCompletedTasks= document.querySelector("#delete-completed-btn"); +deleteCompletedTasks.addEventListener("click", ()=> { + todos.deleteCompletedTasks(); + render(); +}); \ No newline at end of file From 3eaa8c06fddf155ad580a062c36b429d5ec1853e Mon Sep 17 00:00:00 2001 From: Mona-Eltantawy Date: Wed, 1 Apr 2026 22:08:27 +0100 Subject: [PATCH 2/5] in the html file I changed the input type for the alarmSet to minutes instead of number - in the js file i implemented functions to set the alarm to count the remaining time and play the alarm sound when it counts to 0 . --- ...Alarmclockapp .html => Alarmclockapp.html} | 2 +- Sprint-3/alarmclock/alarmclock.js | 68 ++++++++++++++++--- 2 files changed, 58 insertions(+), 12 deletions(-) rename Sprint-3/alarmclock/{Alarmclockapp .html => Alarmclockapp.html} (92%) diff --git a/Sprint-3/alarmclock/Alarmclockapp .html b/Sprint-3/alarmclock/Alarmclockapp.html similarity index 92% rename from Sprint-3/alarmclock/Alarmclockapp .html rename to Sprint-3/alarmclock/Alarmclockapp.html index 48e2e80d9..bd5fa987f 100644 --- a/Sprint-3/alarmclock/Alarmclockapp .html +++ b/Sprint-3/alarmclock/Alarmclockapp.html @@ -10,7 +10,7 @@

Time Remaining: 00:00

- + diff --git a/Sprint-3/alarmclock/alarmclock.js b/Sprint-3/alarmclock/alarmclock.js index 6ca81cd3b..1dc35e292 100644 --- a/Sprint-3/alarmclock/alarmclock.js +++ b/Sprint-3/alarmclock/alarmclock.js @@ -1,17 +1,58 @@ -function setAlarm() {} +var audio = new Audio("alarmsound.mp3"); -// DO NOT EDIT BELOW HERE +let timeRemaining = 0; +let countdownInterval = null; +let hasPlayed = false; -var audio = new Audio("alarmsound.mp3"); +function setAlarm() { + const input = document.getElementById("alarmSet").value; -function setup() { - document.getElementById("set").addEventListener("click", () => { - setAlarm(); - }); + timeRemaining = parseInt(input, 10); + + if (isNaN(timeRemaining) || timeRemaining <= 0) { + alert("Please enter a valid number greater than 0"); + return; + } + + hasPlayed = false; + updateDisplay(); + + if (countdownInterval) { + clearInterval(countdownInterval); + } + + countdownInterval = setInterval(() => { + timeRemaining--; + + // Play alarm at 10 seconds remaining (or immediately if less than 10) + if (!hasPlayed && (timeRemaining === 10 || timeRemaining < 10)) { + playAlarm(); + hasPlayed = true; + } - document.getElementById("stop").addEventListener("click", () => { - pauseAlarm(); - }); + if (timeRemaining <= 0) { + timeRemaining = 0; + updateDisplay(); + clearInterval(countdownInterval); + return; + } + + updateDisplay(); + }, 1000); +} // ✅ properly closed function + +function updateDisplay() { + const display = document.getElementById("timeRemaining"); + + const minutes = String(Math.floor(timeRemaining / 60)).padStart(2, "0"); + const seconds = String(timeRemaining % 60).padStart(2, "0"); + + display.textContent = `Time Remaining: ${minutes}:${seconds}`; +} + +function setup() { + document.getElementById("set").addEventListener("click", setAlarm); + document.getElementById("stop").addEventListener("click", pauseAlarm); } function playAlarm() { @@ -20,6 +61,11 @@ function playAlarm() { function pauseAlarm() { audio.pause(); + audio.currentTime = 0; + + if (countdownInterval) { + clearInterval(countdownInterval); + } } -window.onload = setup; +window.onload = setup; \ No newline at end of file From a204333026fbcda2ae5bc149c90551f8cdb865bf Mon Sep 17 00:00:00 2001 From: Mona-Eltantawy Date: Wed, 1 Apr 2026 22:24:24 +0100 Subject: [PATCH 3/5] edited js file --- Sprint-3/alarmclock/alarmclock.js | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/Sprint-3/alarmclock/alarmclock.js b/Sprint-3/alarmclock/alarmclock.js index 1dc35e292..8e453be28 100644 --- a/Sprint-3/alarmclock/alarmclock.js +++ b/Sprint-3/alarmclock/alarmclock.js @@ -1,8 +1,7 @@ var audio = new Audio("alarmsound.mp3"); -let timeRemaining = 0; +let timeRemaining = 0; let countdownInterval = null; -let hasPlayed = false; function setAlarm() { const input = document.getElementById("alarmSet").value; @@ -14,7 +13,6 @@ function setAlarm() { return; } - hasPlayed = false; updateDisplay(); if (countdownInterval) { @@ -24,22 +22,14 @@ function setAlarm() { countdownInterval = setInterval(() => { timeRemaining--; - // Play alarm at 10 seconds remaining (or immediately if less than 10) - if (!hasPlayed && (timeRemaining === 10 || timeRemaining < 10)) { - playAlarm(); - hasPlayed = true; - } + updateDisplay(); if (timeRemaining <= 0) { - timeRemaining = 0; - updateDisplay(); clearInterval(countdownInterval); - return; + playAlarm(); } - - updateDisplay(); }, 1000); -} // ✅ properly closed function +} function updateDisplay() { const display = document.getElementById("timeRemaining"); @@ -68,4 +58,4 @@ function pauseAlarm() { } } -window.onload = setup; \ No newline at end of file +window.onload = setup; From 384a4dd2e9a94b0dd40981ef139f416b6e886be3 Mon Sep 17 00:00:00 2001 From: Mona-Eltantawy Date: Wed, 1 Apr 2026 22:35:42 +0100 Subject: [PATCH 4/5] re- editeed the HTMl to the berivuse version to match the PR requirements --- Sprint-3/alarmclock/Alarmclockapp.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-3/alarmclock/Alarmclockapp.html b/Sprint-3/alarmclock/Alarmclockapp.html index bd5fa987f..182d04947 100644 --- a/Sprint-3/alarmclock/Alarmclockapp.html +++ b/Sprint-3/alarmclock/Alarmclockapp.html @@ -10,11 +10,11 @@

Time Remaining: 00:00

- +
- + \ No newline at end of file From 7210f431a313c5f7d311e8fa9d6888ad45381cf9 Mon Sep 17 00:00:00 2001 From: Mona-Eltantawy Date: Fri, 3 Apr 2026 21:10:12 +0100 Subject: [PATCH 5/5] restore the todolist filles to the original status --- Sprint-3/todo-list/index.html | 8 -------- Sprint-3/todo-list/script.mjs | 9 +-------- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/Sprint-3/todo-list/index.html b/Sprint-3/todo-list/index.html index d778d1d55..4d12c4654 100644 --- a/Sprint-3/todo-list/index.html +++ b/Sprint-3/todo-list/index.html @@ -34,14 +34,6 @@

My ToDo List

-
-
-
-

Completed Tasks

-
- -
diff --git a/Sprint-3/todo-list/script.mjs b/Sprint-3/todo-list/script.mjs index 176b04410..ba0b2ceae 100644 --- a/Sprint-3/todo-list/script.mjs +++ b/Sprint-3/todo-list/script.mjs @@ -73,11 +73,4 @@ function createListItem(todo, index) { }); return li; -} - -const completedList= document.querySelector("#completed-list"); -const deleteCompletedTasks= document.querySelector("#delete-completed-btn"); -deleteCompletedTasks.addEventListener("click", ()=> { - todos.deleteCompletedTasks(); - render(); -}); \ No newline at end of file +} \ No newline at end of file