From dad10c98033c610e74f43eff85c2c7f513cd86a7 Mon Sep 17 00:00:00 2001 From: zilinskyte Date: Mon, 1 Dec 2025 18:10:11 +0000 Subject: [PATCH 01/10] html updated --- Sprint-3/alarmclock/index.html | 39 +++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/Sprint-3/alarmclock/index.html b/Sprint-3/alarmclock/index.html index 48e2e80d9..972ff35b6 100644 --- a/Sprint-3/alarmclock/index.html +++ b/Sprint-3/alarmclock/index.html @@ -3,18 +3,41 @@ - - Title here + Alarm Clock App -
-

Time Remaining: 00:00

- - +
+ - - + + +
+ + +
+ + + +

Time Remaining:
00:00

+ +
+ From 264f3e10af36b9a20e522d3906a15df0dc84a920 Mon Sep 17 00:00:00 2001 From: zilinskyte Date: Mon, 1 Dec 2025 18:11:51 +0000 Subject: [PATCH 02/10] prettier --- Sprint-3/alarmclock/index.html | 101 +++++++++++++++++++++++++-------- 1 file changed, 77 insertions(+), 24 deletions(-) diff --git a/Sprint-3/alarmclock/index.html b/Sprint-3/alarmclock/index.html index 972ff35b6..83e20730c 100644 --- a/Sprint-3/alarmclock/index.html +++ b/Sprint-3/alarmclock/index.html @@ -6,36 +6,89 @@ Alarm Clock App -
- +
+ - + -
- - +
+ +
- + -

Time Remaining:
00:00

+

+ Time Remaining:
00:00 +

- +
From 2ae42afde95eaa0fbcbf16be4340237f9a5ee243 Mon Sep 17 00:00:00 2001 From: zilinskyte Date: Mon, 1 Dec 2025 18:13:14 +0000 Subject: [PATCH 03/10] alarm clock function --- Sprint-3/alarmclock/alarmclock.js | 77 ++++++++++++++++++++++++++----- 1 file changed, 66 insertions(+), 11 deletions(-) diff --git a/Sprint-3/alarmclock/alarmclock.js b/Sprint-3/alarmclock/alarmclock.js index 6ca81cd3b..018398291 100644 --- a/Sprint-3/alarmclock/alarmclock.js +++ b/Sprint-3/alarmclock/alarmclock.js @@ -1,19 +1,72 @@ -function setAlarm() {} +let timer = null; +let totalSeconds = 0; -// DO NOT EDIT BELOW HERE +function formatTime(seconds) { + const mins = Math.floor(seconds / 60); + const secs = seconds % 60; + return `${String(mins).padStart(2, "0")}:${String(secs).padStart(2, "0")}`; +} -var audio = new Audio("alarmsound.mp3"); +function parseInputTime(value) { + if (!/^\d{2}:\d{2}$/.test(value)) return null; + const [m, s] = value.split(":").map(Number); + if (s > 59) return null; + return m * 60 + s; +} -function setup() { - document.getElementById("set").addEventListener("click", () => { - setAlarm(); - }); +function updateDisplay() { + document.getElementById("alarmSet").value = formatTime(totalSeconds); + document.getElementById("timeRemaining").textContent = `Time Remaining: ${formatTime(totalSeconds)}`; +} - document.getElementById("stop").addEventListener("click", () => { - pauseAlarm(); - }); +function incrementTime(amount) { + totalSeconds += amount; + if (totalSeconds < 0) totalSeconds = 0; + updateDisplay(); } +function setAlarm() { + const input = document.getElementById("alarmSet"); + const parsed = parseInputTime(input.value); + if (parsed === null) { + alert("Use MM:SS format"); + return; + } + + totalSeconds = parsed; + updateDisplay(); + + if (timer) clearInterval(timer); + + timer = setInterval(() => { + totalSeconds--; + updateDisplay(); + if (totalSeconds <= 0) { + clearInterval(timer); + timer = null; + playAlarm(); + } + }, 1000); +} + +function stopTimer() { + if (timer) { + clearInterval(timer); + timer = null; + } + totalSeconds = 0; + updateDisplay(); + pauseAlarm(); +} + +// attach to window so HTML buttons can call them +window.incrementTime = incrementTime; +window.setAlarm = setAlarm; +window.stopTimer = stopTimer; + +// DO NOT EDIT BELOW HERE +var audio = new Audio("alarmsound.mp3"); + function playAlarm() { audio.play(); } @@ -22,4 +75,6 @@ function pauseAlarm() { audio.pause(); } -window.onload = setup; +window.playAlarm = playAlarm; +window.pauseAlarm = pauseAlarm; + From 9e52377d0e40a963ab7397b0577dabf310868513 Mon Sep 17 00:00:00 2001 From: zilinskyte Date: Tue, 2 Dec 2025 00:20:01 +0000 Subject: [PATCH 04/10] styled moved to css file --- Sprint-3/alarmclock/style.css | 66 ++++++++++++++++++++++++++++++----- 1 file changed, 57 insertions(+), 9 deletions(-) diff --git a/Sprint-3/alarmclock/style.css b/Sprint-3/alarmclock/style.css index 0c72de38b..0292a7fcc 100644 --- a/Sprint-3/alarmclock/style.css +++ b/Sprint-3/alarmclock/style.css @@ -1,15 +1,63 @@ -.centre { - position: fixed; - top: 50%; - left: 50%; - -webkit-transform: translate(-50%, -50%); - transform: translate(-50%, -50%); +.container { + font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + height: 100vh; + gap: 15px; } -#alarmSet { - margin: 20px; +.time-label { + font-size: 44px; + font-weight: bold; } -h1 { +.time-input { + font-size: 64px; text-align: center; + width: 200px; + padding: 15px; + border-radius: 10px; + border: 3px solid #0904b0; } + +.increment-buttons { + display: flex; + gap: 10px; +} + +.increment-buttons button { + font-size: 20px; + padding: 10px 15px; + border-radius: 6px; + border: 2px solid #444; +} + +.set-button { + font-size: 30px; + padding: 10px 20px; + border-radius: 8px; + border: 3px solid green; +} + +.time-remaining { + font-size: 36px; + font-weight: 900; + text-align: center; +} + +.stop-button { + font-size: 40px; + padding: 15px 30px; + border-radius: 10px; + border: 4px solid red; +} + +.stop-large-button { + font-size: 40px; + padding: 15px 30px; + border-radius: 10px; + border: 4px solid red; +} + From 1879d0eb2deb02aafbe9ff9ce9e30bd730483ee5 Mon Sep 17 00:00:00 2001 From: zilinskyte Date: Tue, 2 Dec 2025 00:21:02 +0000 Subject: [PATCH 05/10] mistake typing below the line removed --- Sprint-3/alarmclock/alarmclock.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Sprint-3/alarmclock/alarmclock.js b/Sprint-3/alarmclock/alarmclock.js index 018398291..c68b7389b 100644 --- a/Sprint-3/alarmclock/alarmclock.js +++ b/Sprint-3/alarmclock/alarmclock.js @@ -63,6 +63,8 @@ function stopTimer() { window.incrementTime = incrementTime; window.setAlarm = setAlarm; window.stopTimer = stopTimer; +window.playAlarm = playAlarm; +window.pauseAlarm = pauseAlarm; // DO NOT EDIT BELOW HERE var audio = new Audio("alarmsound.mp3"); @@ -75,6 +77,5 @@ function pauseAlarm() { audio.pause(); } -window.playAlarm = playAlarm; -window.pauseAlarm = pauseAlarm; + From 1e92123fd6703db1082495d4348159c028ff1bc3 Mon Sep 17 00:00:00 2001 From: zilinskyte Date: Wed, 3 Dec 2025 15:22:17 +0000 Subject: [PATCH 06/10] Refactor alarm clock functionality and improve HTML structure --- Sprint-3/alarmclock/alarmclock.js | 35 +++++++------- Sprint-3/alarmclock/index.html | 78 ++++--------------------------- Sprint-3/alarmclock/style.css | 2 +- 3 files changed, 30 insertions(+), 85 deletions(-) diff --git a/Sprint-3/alarmclock/alarmclock.js b/Sprint-3/alarmclock/alarmclock.js index c68b7389b..513cfe152 100644 --- a/Sprint-3/alarmclock/alarmclock.js +++ b/Sprint-3/alarmclock/alarmclock.js @@ -15,19 +15,27 @@ function parseInputTime(value) { } function updateDisplay() { - document.getElementById("alarmSet").value = formatTime(totalSeconds); - document.getElementById("timeRemaining").textContent = `Time Remaining: ${formatTime(totalSeconds)}`; + const heading = document.getElementById("timeRemaining"); + const input = document.getElementById("alarmSet"); + + // clamp BEFORE formatting + totalSeconds = Math.max(0, totalSeconds); + const formatted = formatTime(totalSeconds); + + input.value = formatted; + heading.innerHTML = `Time Remaining:

${formatted}`; } function incrementTime(amount) { - totalSeconds += amount; - if (totalSeconds < 0) totalSeconds = 0; + // correctly ADD or SUBTRACT 5 seconds + totalSeconds = Math.max(0, totalSeconds + amount); updateDisplay(); } function setAlarm() { const input = document.getElementById("alarmSet"); const parsed = parseInputTime(input.value); + if (parsed === null) { alert("Use MM:SS format"); return; @@ -40,8 +48,10 @@ function setAlarm() { timer = setInterval(() => { totalSeconds--; + totalSeconds = Math.max(0, totalSeconds); // clamp again for safety updateDisplay(); - if (totalSeconds <= 0) { + + if (totalSeconds === 0) { clearInterval(timer); timer = null; playAlarm(); @@ -50,21 +60,17 @@ function setAlarm() { } function stopTimer() { - if (timer) { - clearInterval(timer); - timer = null; - } + if (timer) clearInterval(timer); + timer = null; totalSeconds = 0; updateDisplay(); - pauseAlarm(); + audio.pause(); } -// attach to window so HTML buttons can call them +// expose to the browser window.incrementTime = incrementTime; window.setAlarm = setAlarm; window.stopTimer = stopTimer; -window.playAlarm = playAlarm; -window.pauseAlarm = pauseAlarm; // DO NOT EDIT BELOW HERE var audio = new Audio("alarmsound.mp3"); @@ -76,6 +82,3 @@ function playAlarm() { function pauseAlarm() { audio.pause(); } - - - diff --git a/Sprint-3/alarmclock/index.html b/Sprint-3/alarmclock/index.html index 83e20730c..6bfc9586c 100644 --- a/Sprint-3/alarmclock/index.html +++ b/Sprint-3/alarmclock/index.html @@ -3,92 +3,34 @@ + Alarm Clock App -
- +
+ -
- - +
+ +
- + -

+

Time Remaining:
00:00

- +
diff --git a/Sprint-3/alarmclock/style.css b/Sprint-3/alarmclock/style.css index 0292a7fcc..24fe71289 100644 --- a/Sprint-3/alarmclock/style.css +++ b/Sprint-3/alarmclock/style.css @@ -1,5 +1,5 @@ .container { - font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif; + font-family: "Franklin Gothic Medium", "Arial Narrow", Arial, sans-serif; display: flex; flex-direction: column; align-items: center; From d48ff256a13455d294992444508d8f7b9a3a321e Mon Sep 17 00:00:00 2001 From: zilinskyte Date: Fri, 5 Dec 2025 12:22:53 +0000 Subject: [PATCH 07/10] event handling callback function method changed --- Sprint-3/alarmclock/alarmclock.js | 12 +++++------- Sprint-3/alarmclock/index.html | 8 ++++---- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Sprint-3/alarmclock/alarmclock.js b/Sprint-3/alarmclock/alarmclock.js index 513cfe152..d4779642e 100644 --- a/Sprint-3/alarmclock/alarmclock.js +++ b/Sprint-3/alarmclock/alarmclock.js @@ -18,7 +18,6 @@ function updateDisplay() { const heading = document.getElementById("timeRemaining"); const input = document.getElementById("alarmSet"); - // clamp BEFORE formatting totalSeconds = Math.max(0, totalSeconds); const formatted = formatTime(totalSeconds); @@ -27,7 +26,6 @@ function updateDisplay() { } function incrementTime(amount) { - // correctly ADD or SUBTRACT 5 seconds totalSeconds = Math.max(0, totalSeconds + amount); updateDisplay(); } @@ -48,7 +46,7 @@ function setAlarm() { timer = setInterval(() => { totalSeconds--; - totalSeconds = Math.max(0, totalSeconds); // clamp again for safety + totalSeconds = Math.max(0, totalSeconds); updateDisplay(); if (totalSeconds === 0) { @@ -67,10 +65,10 @@ function stopTimer() { audio.pause(); } -// expose to the browser -window.incrementTime = incrementTime; -window.setAlarm = setAlarm; -window.stopTimer = stopTimer; +document.getElementById("up").addEventListener("click", () => incrementTime(5)); +document.getElementById("down").addEventListener("click", () => incrementTime(-5)); +document.getElementById("set").addEventListener("click", setAlarm); +document.getElementById("stop").addEventListener("click", stopTimer); // DO NOT EDIT BELOW HERE var audio = new Audio("alarmsound.mp3"); diff --git a/Sprint-3/alarmclock/index.html b/Sprint-3/alarmclock/index.html index 6bfc9586c..b0f7068a1 100644 --- a/Sprint-3/alarmclock/index.html +++ b/Sprint-3/alarmclock/index.html @@ -20,17 +20,17 @@ />
- - + +
- +

Time Remaining:
00:00

- +
From aa73c2b029eb8755a8c7284344e67efbe58de0ca Mon Sep 17 00:00:00 2001 From: zilinskyte Date: Fri, 5 Dec 2025 12:35:04 +0000 Subject: [PATCH 08/10] alarm sound resets --- Sprint-3/alarmclock/alarmclock.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Sprint-3/alarmclock/alarmclock.js b/Sprint-3/alarmclock/alarmclock.js index d4779642e..28ddd3449 100644 --- a/Sprint-3/alarmclock/alarmclock.js +++ b/Sprint-3/alarmclock/alarmclock.js @@ -30,7 +30,16 @@ function incrementTime(amount) { updateDisplay(); } +function resetAlarmState() { + if (timer) clearInterval(timer); + timer = null; + + audio.pause(); + audio.currentTime = 0; +} + function setAlarm() { + resetAlarmState(); const input = document.getElementById("alarmSet"); const parsed = parseInputTime(input.value); @@ -66,7 +75,9 @@ function stopTimer() { } document.getElementById("up").addEventListener("click", () => incrementTime(5)); -document.getElementById("down").addEventListener("click", () => incrementTime(-5)); +document + .getElementById("down") + .addEventListener("click", () => incrementTime(-5)); document.getElementById("set").addEventListener("click", setAlarm); document.getElementById("stop").addEventListener("click", stopTimer); From feb5c668f2604c674b374c4eb4cbf3c5e5266789 Mon Sep 17 00:00:00 2001 From: zilinskyte Date: Sat, 6 Dec 2025 12:14:03 +0000 Subject: [PATCH 09/10] redundant line removed --- Sprint-3/alarmclock/alarmclock.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/Sprint-3/alarmclock/alarmclock.js b/Sprint-3/alarmclock/alarmclock.js index 28ddd3449..00f1a3167 100644 --- a/Sprint-3/alarmclock/alarmclock.js +++ b/Sprint-3/alarmclock/alarmclock.js @@ -51,8 +51,6 @@ function setAlarm() { totalSeconds = parsed; updateDisplay(); - if (timer) clearInterval(timer); - timer = setInterval(() => { totalSeconds--; totalSeconds = Math.max(0, totalSeconds); From e57493fa6defd68f14fc1a1f46e8ca57ab82319b Mon Sep 17 00:00:00 2001 From: zilinskyte Date: Sat, 6 Dec 2025 12:45:47 +0000 Subject: [PATCH 10/10] inconsistencies addressed: math.max removed, and alarm sound edge case addressed --- Sprint-3/alarmclock/alarmclock.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Sprint-3/alarmclock/alarmclock.js b/Sprint-3/alarmclock/alarmclock.js index 00f1a3167..ece3df001 100644 --- a/Sprint-3/alarmclock/alarmclock.js +++ b/Sprint-3/alarmclock/alarmclock.js @@ -18,7 +18,6 @@ function updateDisplay() { const heading = document.getElementById("timeRemaining"); const input = document.getElementById("alarmSet"); - totalSeconds = Math.max(0, totalSeconds); const formatted = formatTime(totalSeconds); input.value = formatted; @@ -26,7 +25,8 @@ function updateDisplay() { } function incrementTime(amount) { - totalSeconds = Math.max(0, totalSeconds + amount); + totalSeconds += amount; + if (totalSeconds < 0) totalSeconds = 0; updateDisplay(); } @@ -51,16 +51,22 @@ function setAlarm() { totalSeconds = parsed; updateDisplay(); - timer = setInterval(() => { - totalSeconds--; - totalSeconds = Math.max(0, totalSeconds); - updateDisplay(); + if (totalSeconds === 0) { + playAlarm(); + return; + } //Alarm plays immediately if time is set to 00:00 - if (totalSeconds === 0) { + timer = setInterval(() => { + totalSeconds -= 1; + if (totalSeconds <= 0) { + totalSeconds = 0; + updateDisplay(); clearInterval(timer); timer = null; playAlarm(); + return; } + updateDisplay(); }, 1000); }