Repository navigation
Manchester | 26-ITP-Sep | Mathew Shaibu | Sprint 3 | Alarm clock #1525
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
8531191
c9f091e
28d2352
f0d0536
9fbe192
5846830
f80159c
e2e0bec
7a716f3
356e35d
1fe087c
6d66369
be1a8f6
339891a
8918624
ff16f79
39dfee9
b47b049
ef90582
2bdc42b
c66853d
0470353
8685d4c
ba27e60
bc549a7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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); | ||
| }); | ||
| document.getElementById("pause").addEventListener("click", () => { | ||
| clearInterval(timer); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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(() => { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How does a zero or blank duration reach the 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 | ||
|
|
||
|
|
||
There was a problem hiding this comment.
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