From 419218d0be2dbe1748eb02a99e950c9e72a51b2a Mon Sep 17 00:00:00 2001 From: Shuheda Date: Thu, 5 Mar 2026 21:14:43 +0000 Subject: [PATCH 01/11] Title updated --- Sprint-3/alarmclock/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/alarmclock/index.html b/Sprint-3/alarmclock/index.html index 48e2e80d9..ff2d3b453 100644 --- a/Sprint-3/alarmclock/index.html +++ b/Sprint-3/alarmclock/index.html @@ -4,7 +4,7 @@ - Title here + Alarm clock app
From b2d54f4daf7a1e5b687582d1caed33156320a14d Mon Sep 17 00:00:00 2001 From: Shuheda Date: Sat, 14 Mar 2026 13:23:06 +0000 Subject: [PATCH 02/11] Creating PR --- Sprint-3/alarmclock/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-3/alarmclock/index.html b/Sprint-3/alarmclock/index.html index ff2d3b453..392348aad 100644 --- a/Sprint-3/alarmclock/index.html +++ b/Sprint-3/alarmclock/index.html @@ -9,6 +9,7 @@

Time Remaining: 00:00

+

Testing

From ee3dc7d49ac5f0c605866f582af1cc271b066692 Mon Sep 17 00:00:00 2001 From: Shuheda Date: Sat, 14 Mar 2026 13:32:32 +0000 Subject: [PATCH 03/11] removed testing --- Sprint-3/alarmclock/index.html | 1 - 1 file changed, 1 deletion(-) diff --git a/Sprint-3/alarmclock/index.html b/Sprint-3/alarmclock/index.html index 392348aad..ff2d3b453 100644 --- a/Sprint-3/alarmclock/index.html +++ b/Sprint-3/alarmclock/index.html @@ -9,7 +9,6 @@

Time Remaining: 00:00

-

Testing

From 3c60cb069618b346e9ab4037fbf62f19645b6c88 Mon Sep 17 00:00:00 2001 From: Shuheda Date: Sat, 14 Mar 2026 13:53:26 +0000 Subject: [PATCH 04/11] Amended function --- Sprint-3/alarmclock/alarmclock.js | 52 ++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/Sprint-3/alarmclock/alarmclock.js b/Sprint-3/alarmclock/alarmclock.js index 6ca81cd3b..716025142 100644 --- a/Sprint-3/alarmclock/alarmclock.js +++ b/Sprint-3/alarmclock/alarmclock.js @@ -1,4 +1,54 @@ -function setAlarm() {} +let timerInterval = null; +let remainingSeconds = 0; + +function setAlarm() { + // Read the minutes value from the alarm input field + const minutesInput = document.getElementById("alarmSet"); + const minutes = parseInt(minutesInput.value, 10); + // Ignore invalid or non-positive input + if (isNaN(minutes) || minutes <= 0) { + return; + } + // Store the input as the remaining seconds to count down + remainingSeconds = minutes; + // Clear any existing timer before starting a new one + if (timerInterval !== null) { + clearInterval(timerInterval); + timerInterval = null; + } + // Immediately render the starting time on screen + updateTimeDisplay(); + + // Tick every second and decrement remainingSeconds + timerInterval = setInterval(() => { + remainingSeconds = remainingSeconds - 1; + + updateTimeDisplay(); + + if (remainingSeconds <= 0) { + // Countdown finished — stop the timer and trigger the alarm + clearInterval(timerInterval); + timerInterval = null; + remainingSeconds = 0; + // Ensure the display shows exactly 00:00 + updateTimeDisplay(); + playAlarm(); + } + }, 1000); +} + +// Converts remainingSeconds into MM:SS format and updates the display +function updateTimeDisplay() { + const minutes = Math.floor(remainingSeconds / 60); + const seconds = remainingSeconds % 60; + + const formattedMinutes = minutes.toString().padStart(2, "0"); + const formattedSeconds = seconds.toString().padStart(2, "0"); + + const timeDisplay = document.getElementById("timeRemaining"); + timeDisplay.textContent = `Time Remaining: ${formattedMinutes}:${formattedSeconds}`; +} + // DO NOT EDIT BELOW HERE From 90e99cf7042f4e767a8fd771f6e4283441aae132 Mon Sep 17 00:00:00 2001 From: Shuheda Date: Sat, 14 Mar 2026 13:57:43 +0000 Subject: [PATCH 05/11] doctype masde prettier --- Sprint-3/alarmclock/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/alarmclock/index.html b/Sprint-3/alarmclock/index.html index ff2d3b453..66748001e 100644 --- a/Sprint-3/alarmclock/index.html +++ b/Sprint-3/alarmclock/index.html @@ -1,4 +1,4 @@ - + From c6fcdd641a84517ae9fa11d4ff8560d1b982fde0 Mon Sep 17 00:00:00 2001 From: Shuheda Date: Sat, 21 Mar 2026 11:45:55 +0000 Subject: [PATCH 06/11] Fixed alarmclock.js --- Sprint-3/alarmclock/alarmclock.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/alarmclock/alarmclock.js b/Sprint-3/alarmclock/alarmclock.js index 716025142..f880b05ff 100644 --- a/Sprint-3/alarmclock/alarmclock.js +++ b/Sprint-3/alarmclock/alarmclock.js @@ -10,7 +10,7 @@ function setAlarm() { return; } // Store the input as the remaining seconds to count down - remainingSeconds = minutes; + remainingSeconds = minutes * 60; // Clear any existing timer before starting a new one if (timerInterval !== null) { clearInterval(timerInterval); From 1724a286c4467f3f4411311cb4d0b01b3b345416 Mon Sep 17 00:00:00 2001 From: Shuheda Date: Fri, 10 Apr 2026 20:50:00 +0100 Subject: [PATCH 07/11] input changed from minutes to seconds --- Sprint-3/alarmclock/alarmclock.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Sprint-3/alarmclock/alarmclock.js b/Sprint-3/alarmclock/alarmclock.js index f880b05ff..489da65ce 100644 --- a/Sprint-3/alarmclock/alarmclock.js +++ b/Sprint-3/alarmclock/alarmclock.js @@ -4,10 +4,11 @@ let remainingSeconds = 0; function setAlarm() { // Read the minutes value from the alarm input field const minutesInput = document.getElementById("alarmSet"); - const minutes = parseInt(minutesInput.value, 10); - // Ignore invalid or non-positive input - if (isNaN(minutes) || minutes <= 0) { - return; + const seconds = parseInt(minutesInput.value, 10); +// Ignore invalid or non-positive input +if (isNaN(seconds) || seconds <= 0) { + return; +} } // Store the input as the remaining seconds to count down remainingSeconds = minutes * 60; @@ -35,7 +36,7 @@ function setAlarm() { playAlarm(); } }, 1000); -} + // Converts remainingSeconds into MM:SS format and updates the display function updateTimeDisplay() { From f363ec08a07779ee26619ebfb974f86e920a4929 Mon Sep 17 00:00:00 2001 From: Shuheda Date: Fri, 10 Apr 2026 22:26:05 +0100 Subject: [PATCH 08/11] added reset function --- Sprint-3/alarmclock/alarmclock.js | 36 +++++++++++++++++-------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/Sprint-3/alarmclock/alarmclock.js b/Sprint-3/alarmclock/alarmclock.js index 489da65ce..5f1b89d12 100644 --- a/Sprint-3/alarmclock/alarmclock.js +++ b/Sprint-3/alarmclock/alarmclock.js @@ -1,42 +1,46 @@ let timerInterval = null; let remainingSeconds = 0; +// Resets timer state +function resetTimer() { + if (timerInterval !== null) { + clearInterval(timerInterval); + timerInterval = null; + } + remainingSeconds = 0; +} +//Starts the alarm counbtdown function setAlarm() { // Read the minutes value from the alarm input field const minutesInput = document.getElementById("alarmSet"); const seconds = parseInt(minutesInput.value, 10); // Ignore invalid or non-positive input + if (isNaN(seconds) || seconds <= 0) { return; } - } + // Reset any existing timer first + resetTimer(); + // Store the input as the remaining seconds to count down - remainingSeconds = minutes * 60; - // Clear any existing timer before starting a new one - if (timerInterval !== null) { - clearInterval(timerInterval); - timerInterval = null; - } - // Immediately render the starting time on screen + remainingSeconds = seconds; + + // Update display immediately updateTimeDisplay(); - // Tick every second and decrement remainingSeconds + // Start countdown timerInterval = setInterval(() => { - remainingSeconds = remainingSeconds - 1; + remainingSeconds--; updateTimeDisplay(); if (remainingSeconds <= 0) { - // Countdown finished — stop the timer and trigger the alarm - clearInterval(timerInterval); - timerInterval = null; - remainingSeconds = 0; - // Ensure the display shows exactly 00:00 + resetTimer(); updateTimeDisplay(); playAlarm(); } }, 1000); - +} // Converts remainingSeconds into MM:SS format and updates the display function updateTimeDisplay() { From 7ead5c365d90173d12b0c8317ab720ef21394083 Mon Sep 17 00:00:00 2001 From: Shuheda Date: Sat, 11 Apr 2026 12:11:29 +0100 Subject: [PATCH 09/11] prettier added to formatting --- Sprint-3/alarmclock/alarmclock.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Sprint-3/alarmclock/alarmclock.js b/Sprint-3/alarmclock/alarmclock.js index 5f1b89d12..f6dc80eaf 100644 --- a/Sprint-3/alarmclock/alarmclock.js +++ b/Sprint-3/alarmclock/alarmclock.js @@ -14,21 +14,21 @@ function setAlarm() { // Read the minutes value from the alarm input field const minutesInput = document.getElementById("alarmSet"); const seconds = parseInt(minutesInput.value, 10); -// Ignore invalid or non-positive input + // Ignore invalid or non-positive input -if (isNaN(seconds) || seconds <= 0) { - return; -} + if (isNaN(seconds) || seconds <= 0) { + return; + } // Reset any existing timer first resetTimer(); - + // Store the input as the remaining seconds to count down remainingSeconds = seconds; // Update display immediately updateTimeDisplay(); - // Start countdown + // Start countdown timerInterval = setInterval(() => { remainingSeconds--; @@ -54,7 +54,6 @@ function updateTimeDisplay() { timeDisplay.textContent = `Time Remaining: ${formattedMinutes}:${formattedSeconds}`; } - // DO NOT EDIT BELOW HERE var audio = new Audio("alarmsound.mp3"); From f691b299e361768a1ef142acd9db582faaefdb49 Mon Sep 17 00:00:00 2001 From: Shuheda Date: Sat, 11 Apr 2026 15:27:02 +0100 Subject: [PATCH 10/11] keep remainingSeconds local to setAlarm --- Sprint-3/alarmclock/alarmclock.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Sprint-3/alarmclock/alarmclock.js b/Sprint-3/alarmclock/alarmclock.js index f6dc80eaf..17f4b1e54 100644 --- a/Sprint-3/alarmclock/alarmclock.js +++ b/Sprint-3/alarmclock/alarmclock.js @@ -1,5 +1,4 @@ let timerInterval = null; -let remainingSeconds = 0; // Resets timer state function resetTimer() { @@ -7,13 +6,13 @@ function resetTimer() { clearInterval(timerInterval); timerInterval = null; } - remainingSeconds = 0; } //Starts the alarm counbtdown function setAlarm() { // Read the minutes value from the alarm input field const minutesInput = document.getElementById("alarmSet"); const seconds = parseInt(minutesInput.value, 10); + // Ignore invalid or non-positive input if (isNaN(seconds) || seconds <= 0) { @@ -22,28 +21,28 @@ function setAlarm() { // Reset any existing timer first resetTimer(); - // Store the input as the remaining seconds to count down - remainingSeconds = seconds; + //local variable (no global sharing) + let remainingSeconds = seconds; // Update display immediately - updateTimeDisplay(); + updateTimeDisplay(remainingSeconds); // Start countdown timerInterval = setInterval(() => { remainingSeconds--; - updateTimeDisplay(); + updateTimeDisplay(remainingSeconds); if (remainingSeconds <= 0) { resetTimer(); - updateTimeDisplay(); + updateTimeDisplay(0); playAlarm(); } }, 1000); } // Converts remainingSeconds into MM:SS format and updates the display -function updateTimeDisplay() { +function updateTimeDisplay(remainingSeconds) { const minutes = Math.floor(remainingSeconds / 60); const seconds = remainingSeconds % 60; From 3f63303b180f93a65cafd4aaafa9e72b01341e7d Mon Sep 17 00:00:00 2001 From: Shuheda Date: Sat, 11 Apr 2026 15:35:50 +0100 Subject: [PATCH 11/11] code inside resetTimer() amended --- Sprint-3/alarmclock/alarmclock.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sprint-3/alarmclock/alarmclock.js b/Sprint-3/alarmclock/alarmclock.js index 17f4b1e54..d1a4fd652 100644 --- a/Sprint-3/alarmclock/alarmclock.js +++ b/Sprint-3/alarmclock/alarmclock.js @@ -6,7 +6,14 @@ function resetTimer() { clearInterval(timerInterval); timerInterval = null; } + + // Stop any playing alarm sound + pauseAlarm(); + + // Reset display to 00:00 + updateTimeDisplay(0); } + //Starts the alarm counbtdown function setAlarm() { // Read the minutes value from the alarm input field