Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8531191
object prep
MattCarolus10 Nov 5, 2026
c9f091e
Implement setAlarm function to display remaining time
MattCarolus10 Nov 13, 2026
28d2352
Fix typo in Math function for calculating minutes in setAlarm
MattCarolus10 Nov 13, 2026
f0d0536
Fix typo in Math function for calculating minutes in setAlarm
MattCarolus10 Nov 13, 2026
9fbe192
Add calculation for remaining seconds in setAlarm function
MattCarolus10 Nov 13, 2026
5846830
Format time remaining display in setAlarm function
MattCarolus10 Nov 13, 2026
f80159c
Remove unnecessary leading zeros in time remaining display in setAlar…
MattCarolus10 Nov 13, 2026
e2e0bec
Fix formatting of time remaining display in setAlarm function
MattCarolus10 Nov 13, 2026
7a716f3
Change seconds variable declaration from const to let in setAlarm fun…
MattCarolus10 Nov 13, 2026
356e35d
Change minutes variable declaration from const to let in setAlarm fun…
MattCarolus10 Nov 13, 2026
1fe087c
Change remainingSeconds variable declaration from const to let in set…
MattCarolus10 Nov 13, 2026
6d66369
Add timer functionality to update remaining time in setAlarm function
MattCarolus10 Nov 13, 2026
be1a8f6
Fix alarm timer logic to clear interval and play alarm when seconds r…
MattCarolus10 Nov 13, 2026
339891a
Refactor setAlarm function to improve code readability by formatting …
MattCarolus10 Nov 13, 2026
8918624
Add background color change to red when alarm plays
MattCarolus10 Nov 13, 2026
ff16f79
Add flashing background color effect when alarm plays
MattCarolus10 Nov 13, 2026
39dfee9
Add flashTimer variable to manage alarm flashing effect
MattCarolus10 Nov 13, 2026
b47b049
Remove unnecessary whitespace in setAlarm function
MattCarolus10 Nov 13, 2026
ef90582
Assign flashTimer to the interval for background color flashing effec…
MattCarolus10 Nov 13, 2026
2bdc42b
Add event listener to clear flashTimer when stop button is clicked
MattCarolus10 Nov 13, 2026
c66853d
Fix timer variable scope in setAlarm function and update HTML to incl…
MattCarolus10 Nov 13, 2026
0470353
Add pause button functionality to clear timer in alarm clock
MattCarolus10 Nov 13, 2026
8685d4c
Fix formatting of event listener for pause button in alarm clock
MattCarolus10 Nov 13, 2026
ba27e60
Update title in HTML to reflect the alarm clock app
MattCarolus10 Nov 13, 2026
bc549a7
Remove unrelated prep file from branch
MattCarolus10 Nov 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion Sprint-3/alarmclock/alarmclock.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,41 @@
function setAlarm() {}
let flashTimer;
let timer;
window.addEventListener("load", () => {
document.getElementById("stop").addEventListener("click", () => {
clearInterval(flashTimer);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If Stop Alarm is clicked while the page is red, what changes its background back after this interval is cleared?

To "like" or "dislike" this comment, please follow this link

});
document.getElementById("pause").addEventListener("click", () => {
clearInterval(timer);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After this clears the countdown interval, what lets the user resume that same countdown?

To "like" or "dislike" this comment, please follow this link

});
});
function setAlarm() {
let seconds = document.getElementById("alarmSet").value;
let minutes = Math.floor(seconds / 60);
let remainingSeconds = seconds % 60;
document.getElementById("timeRemaining").textContent =
"Time Remaining: " +
String(minutes).padStart(2, "0") +
":" +
String(remainingSeconds).padStart(2, "0");
timer = setInterval(() => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If Set Alarm is clicked twice before the first countdown ends, what interval does the first callback clear when it reaches zero?

To "like" or "dislike" this comment, please follow this link

seconds--;
Comment on lines +20 to +21

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does a zero or blank duration reach the seconds === 0 check after the first tick?

To "like" or "dislike" this comment, please follow this link

minutes = Math.floor(seconds / 60);
remainingSeconds = seconds % 60;
document.getElementById("timeRemaining").textContent =
"Time Remaining: " +
String(minutes).padStart(2, "0") +
":" +
String(remainingSeconds).padStart(2, "0");
if (seconds === 0) {
clearInterval(timer);
playAlarm();
flashTimer = setInterval(() => {
document.body.style.backgroundColor =
document.body.style.backgroundColor === "red" ? "white" : "red";
}, 500);
}
}, 1000);
}

// DO NOT EDIT BELOW HERE

Expand Down
5 changes: 3 additions & 2 deletions Sprint-3/alarmclock/index.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="style.css" />
<title>Title here</title>
<title>Alarm clock app</title>
</head>
<body>
<div class="centre">
Expand All @@ -14,6 +14,7 @@ <h1 id="timeRemaining">Time Remaining: 00:00</h1>

<button id="set" type="button">Set Alarm</button>
<button id="stop" type="button">Stop Alarm</button>
<button id="pause" type="button">Pause</button>
</div>
<script src="alarmclock.js"></script>
</body>
Expand Down
Loading