From aadf0adff7a4565f6cc89d0e2aeb17bd3b85b60f Mon Sep 17 00:00:00 2001 From: Eugenie Ahangama Date: Mon, 2 Mar 2026 02:43:04 +0000 Subject: [PATCH 1/6] Changed the title to Alarm Clock App --- Sprint-3/alarmclock/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-3/alarmclock/index.html b/Sprint-3/alarmclock/index.html index 48e2e80d9..18a51fc66 100644 --- a/Sprint-3/alarmclock/index.html +++ b/Sprint-3/alarmclock/index.html @@ -1,10 +1,10 @@ - + - Title here + Alarm Clock App
From d8b6542a8f14d7d2b3eef505f6f052dec0e1f0e1 Mon Sep 17 00:00:00 2001 From: Eugenie Ahangama Date: Mon, 2 Mar 2026 21:09:17 +0000 Subject: [PATCH 2/6] Implemented intial alarm set and time display update --- Sprint-3/alarmclock/alarmclock.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Sprint-3/alarmclock/alarmclock.js b/Sprint-3/alarmclock/alarmclock.js index 6ca81cd3b..9034ac635 100644 --- a/Sprint-3/alarmclock/alarmclock.js +++ b/Sprint-3/alarmclock/alarmclock.js @@ -1,4 +1,20 @@ -function setAlarm() {} +function setAlarm() { + // Find the input box by its id + const input = document.getElementById("alarmSet"); + // Get whatever number the user typed, + // and convert it to a real number + const minutes = parseInt(input.value, 10); + // If nothing useful was entered, do nothing + if (isNaN(minutes) || minutes <= 0) { + return; + } + // Turn minutes to mm:ss format + const displayMinutes = minutes.toString().padStart(2, "0"); + const display = `Time Remaining: ${displayMinutes}:00`; + // Find the

and update it + const heading = document.getElementById("timeRemaining"); + heading.textContent = display; +} // DO NOT EDIT BELOW HERE From f19fa019745ec5c983d5b7fee5589a3819507abb Mon Sep 17 00:00:00 2001 From: Eugenie Ahangama Date: Mon, 2 Mar 2026 21:51:33 +0000 Subject: [PATCH 3/6] Completed alarm clock with countdown, sound trigger, and stop functionality --- Sprint-3/alarmclock/alarmclock.js | 49 ++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 8 deletions(-) diff --git a/Sprint-3/alarmclock/alarmclock.js b/Sprint-3/alarmclock/alarmclock.js index 9034ac635..9a58a10b5 100644 --- a/Sprint-3/alarmclock/alarmclock.js +++ b/Sprint-3/alarmclock/alarmclock.js @@ -1,19 +1,52 @@ +let countdownInterval = null; +let secondsLeft = 0; + function setAlarm() { - // Find the input box by its id + // Read the minutes from the input const input = document.getElementById("alarmSet"); - // Get whatever number the user typed, - // and convert it to a real number const minutes = parseInt(input.value, 10); // If nothing useful was entered, do nothing if (isNaN(minutes) || minutes <= 0) { return; } - // Turn minutes to mm:ss format - const displayMinutes = minutes.toString().padStart(2, "0"); - const display = `Time Remaining: ${displayMinutes}:00`; - // Find the

and update it + // Convert to total seconds + secondsLeft = minutes * 60; + // Stop any existing countdown + if (countdownInterval !== null) { + clearInterval(countdownInterval); + countdownInterval = null; + } + // Show starting time right away + updateTimeDisplay(); + + // Start the countdown + countdownInterval = setInterval(() => { + secondsLeft = secondsLeft - 1; + + updateTimeDisplay(); + + if (secondsLeft <= 0) { + // Time's up + clearInterval(countdownInterval); + countdownInterval = null; + secondsLeft = 0; + // Makes sure to show exactly 00:00 + updateTimeDisplay(); + playAlarm(); + } + }, 1000); +} + +// Helper function +function updateTimeDisplay() { + const minutes = Math.floor(secondsLeft / 60); + const seconds = secondsLeft % 60; + + const displayMin = minutes.toString().padStart(2, "0"); + const displaySec = seconds.toString().padStart(2, "0"); + const heading = document.getElementById("timeRemaining"); - heading.textContent = display; + heading.textContent = `Time Remaining: ${displayMin}:${displaySec}`; } // DO NOT EDIT BELOW HERE From 99c98a86a89bf87c055685892fc621a558c53f83 Mon Sep 17 00:00:00 2001 From: Eugenie Ahangama Date: Mon, 2 Mar 2026 23:20:36 +0000 Subject: [PATCH 4/6] fix: updated alarm logic to treat input as seconds and fixed display formatting --- 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 9a58a10b5..255987cbd 100644 --- a/Sprint-3/alarmclock/alarmclock.js +++ b/Sprint-3/alarmclock/alarmclock.js @@ -10,7 +10,7 @@ function setAlarm() { return; } // Convert to total seconds - secondsLeft = minutes * 60; + secondsLeft = minutes; // Stop any existing countdown if (countdownInterval !== null) { clearInterval(countdownInterval); From 69c4dc254323a15ab4d0444916a32f70c8bcc1b3 Mon Sep 17 00:00:00 2001 From: Eugenie Ahangama Date: Tue, 3 Mar 2026 23:31:00 +0000 Subject: [PATCH 5/6] Fix: Multiplied alarm input by 60 to convert minutes to seconds --- 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 255987cbd..9a58a10b5 100644 --- a/Sprint-3/alarmclock/alarmclock.js +++ b/Sprint-3/alarmclock/alarmclock.js @@ -10,7 +10,7 @@ function setAlarm() { return; } // Convert to total seconds - secondsLeft = minutes; + secondsLeft = minutes * 60; // Stop any existing countdown if (countdownInterval !== null) { clearInterval(countdownInterval); From 3f89cf2c8533fa980f3bc5cec83b8371564587cd Mon Sep 17 00:00:00 2001 From: Eugenie Ahangama Date: Tue, 3 Mar 2026 23:37:38 +0000 Subject: [PATCH 6/6] fix: update alarm input logic to treat value as seconds --- 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 9a58a10b5..255987cbd 100644 --- a/Sprint-3/alarmclock/alarmclock.js +++ b/Sprint-3/alarmclock/alarmclock.js @@ -10,7 +10,7 @@ function setAlarm() { return; } // Convert to total seconds - secondsLeft = minutes * 60; + secondsLeft = minutes; // Stop any existing countdown if (countdownInterval !== null) { clearInterval(countdownInterval);