-
-
Notifications
You must be signed in to change notification settings - Fork 153
Sheffield | May-2025 | Hassan Osman | Alarm Clock App #602
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?
Sheffield | May-2025 | Hassan Osman | Alarm Clock App #602
Conversation
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.
-
Could consider resetting the background color and the clock display when the "stop" button is clicked.
-
Some unusual input values can disrupt the clock display momentarily. Can you add code to reject this kind of input?
Otherwise code is good.
The background now resets to white after click "stop alarm". The issue is the text area does not clear for some reason. Aslo positive numbers over zero are now only is not accepted as a valid input. |
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.
What do you mean by "The issue is the text area does not clear for some reason."?
text area usually refers to a UI control that supports multiline text input.
In HTML, it usually refers to the <textarea>
element.
UI that accepts only a single line of text input is normally called a text field.
Sprint-3/alarmclock/alarmclock.js
Outdated
@@ -14,6 +14,12 @@ function setAlarm() { | |||
const input = document.getElementById("alarmSet"); | |||
let seconds = parseInt(input.value, 10); | |||
|
|||
if (isNaN(seconds) || seconds <= 0 || input.value.trim() === "") { |
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.
parseInt(" ")
or parseInt("")
return NaN
, so input.value.trim() === ""
is redundant.
Sprint-3/alarmclock/alarmclock.js
Outdated
pauseAlarm(); | ||
document.body.style.backgroundColor = "white"; | ||
document.getElementById("timeRemaining").textContent = ""; |
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.
When the page is first loaded, the clock shows "Time Remaining: 00:00".
You could also consider resetting the content to its "initial value" instead of clearing it.
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.
All this time I thought you were referring to the input bos next to "set time to" LOL Anyway, this has now been sorted
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.
Changes look good! Well done.
Sprint-3/alarmclock/alarmclock.js
Outdated
@@ -58,7 +58,7 @@ function setup() { | |||
clearInterval(countdownInterval); | |||
pauseAlarm(); | |||
document.body.style.backgroundColor = "white"; | |||
document.getElementById("timeRemaining").textContent = ""; | |||
document.getElementById("timeRemaining").textContent = "Time Remaining: 00:00"; |
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.
You could also just call updateDisplay(0)
.
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.
how silly i am!! done it. and code now clears input too :)
Learners, PR Template
Self checklist
Changelist
Implemented alarm functionality with time display update, countdown, continuous sound on zero, stop button control, and background colour change to red on timer end.
Questions
Ask any questions you have for your reviewer.