-
-
Notifications
You must be signed in to change notification settings - Fork 96
ITP JAN 2025/ELFREDAH KEVIN-ALERECHI/DAT GROUP/ALARM CLOCK #494
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?
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.
The alarm sound cannot play but the code is working (to certain extent); the "Stop Button" is behaving mysteriously.
The branch should only only modified files that belong to the Alarm Clock project. Since you commit ALL changes in one commit instead of committing one file at a time, you can consider fixing the branch in the following way:
- Replace all files (in the current branch) that do not belong to the Alarm Clock project by the same files in the
main
branch. You can download yourmain
branch as a ZIP file from your Github repo.
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.
It is a better practice to separate JS code from HTML code. Can you transfer the JS code to alarmclock.js
?
<input type="text" id="alarm-time" placeholder="Enter time in seconds"> | ||
<button onclick="setAlarm()">Set Alarm</button> | ||
<button id="stop-alarm" onclick="stopAlarm()" style="display: none;">Stop Alarm</button> | ||
<audio id="alarm-sound" src="https://www.soundjay.com/button/beep-07.wav" loop></audio> |
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.
This audio cannot be loaded. Why not use the one in the project folder?
function formatTime(seconds) { | ||
let minutes = Math.floor(seconds / 60); | ||
let remainingSeconds = seconds % 60; | ||
return `${minutes < 10 ? '0' + minutes : minutes}:${remainingSeconds < 10 ? '0' + remainingSeconds : remainingSeconds}`; |
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 using .padStart()
.
|
||
timeRemaining = alarmTime; | ||
timeRemainingTitle.innerText = formatTime(timeRemaining); | ||
stopButton.style.display = 'inline'; |
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 can also consider using visibility: visible
and visibility: hidden
to show/hide an element.
Using display : inline
and display : none
to show/hide an element can cause the elements in the UI rearranged.
function stopAlarm() { | ||
alarmSound.pause(); | ||
alarmSound.currentTime = 0; | ||
document.body.style.backgroundColor = ''; // Reset background color | ||
stopButton.style.display = 'none'; // Hide stop button | ||
} |
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 a user clicks the "Stop Button" while the clock is still counting down, the "Stop Button" will "disappear" (and reappear when the clock reaches 0). Is this a bug of feature?
I don't see anything changed since I last reviewed this PR. Have you pushed your changes to Github? |
Done all requirmeents
<!
Changelist
Briefly explain your PR.
Questions
Ask any questions you have for your reviewer.