-
-
Notifications
You must be signed in to change notification settings - Fork 283
London | 26-ITP-Jan | Miriam Jorna | Sprint 3 | Alarmclock #1192
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 9 commits
bc46214
724f78e
b5531bb
fa5b440
3fb860f
055596b
57ab5ca
3453a0c
459b265
0a1c10e
0df1cfb
16a4347
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,30 @@ | ||
| function setAlarm() {} | ||
| function setAlarm() { | ||
| let seconds = parseInt(document.getElementById("alarmSet").value); | ||
|
|
||
| if (seconds <= 0) { | ||
| alert("The number of seconds must be more than 0 please"); | ||
| return; | ||
| } | ||
|
Contributor
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. Indentation is off. Have you installed the prettier VSCode extension and enabled "Format on save/paste" on VSCode, If you have enabled "Format on save" but it is not working, it is likely that you haven't assign a formatter for JS file. This could happen if you have zero or multiple extensions that can format .js file. If you have installed "Prettier" extension. To assign it as the formatter of JS code, you can try:
See: https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode
Author
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. Oh, my apologies, I inserted that and did not prettify it after doing so. Tbh I would normally have done that by hand quickly. Just forgot. |
||
| function updateDisplay() { | ||
| const minutes = Math.floor(seconds / 60); | ||
| const remainingSeconds = seconds % 60; | ||
| document.getElementById("timeRemaining").textContent = | ||
| `Time Remaining: ${String(minutes).padStart(2, "0")}:${String(remainingSeconds).padStart(2, "0")}`; | ||
| } | ||
|
|
||
| updateDisplay(); // update immediately on click | ||
|
|
||
| const countdown = setInterval(() => { | ||
| seconds--; | ||
| updateDisplay(); | ||
|
|
||
| if (seconds <= 0) { | ||
| clearInterval(countdown); | ||
| playAlarm(); | ||
| document.body.style.backgroundColor = "darkorange"; | ||
|
cjyuan marked this conversation as resolved.
Outdated
|
||
| } | ||
| }, 1000); | ||
| } | ||
|
|
||
| // DO NOT EDIT BELOW HERE | ||
|
cjyuan marked this conversation as resolved.
|
||
|
|
||
|
|
@@ -20,6 +46,7 @@ function playAlarm() { | |
|
|
||
| function pauseAlarm() { | ||
| audio.pause(); | ||
| document.body.style.backgroundColor = "cornflowerblue"; | ||
| } | ||
|
|
||
|
Comment on lines
-54
to
-24
Contributor
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. Why delete
Author
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. Oh no! Have I been careless cleaning up the pause button issue? Not the first time I've confused the script term "pause alarm" vs. the human term "stop alarm", apologies!
Contributor
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. |
||
| window.onload = setup; | ||

Uh oh!
There was an error while loading. Please reload this page.