-
-
Notifications
You must be signed in to change notification settings - Fork 278
Sheffield | 26-ITP-Jan | Martha Ogunbiyi | Sprint 3| Alarm clock #1167
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 3 commits
ed3d3cc
0d11d74
44f98d7
8c9db65
2a0eef7
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,27 @@ | ||
| function setAlarm() {} | ||
| const title = document.querySelector('title') | ||
| title.textContent = "Alarm clock app"; | ||
| function time_convert(num) { | ||
| let minutes = Math.floor((num % 3600) / 60); | ||
| let seconds = num % 60; | ||
| return minutes.toString().padStart(2, '0') + ":" + seconds.toString().padStart(2, '0'); | ||
| } | ||
| function setAlarm() { | ||
|
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. What happens when a user clicks the set alarm button while the countdown is already running?
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. Thanks for the feedback. Function has now been updated to stop multiple timers |
||
| const alarmSetInputEl = document.getElementById("alarmSet"); | ||
| let timeEl = Number(alarmSetInputEl.value); | ||
|
||
| const timeRemainingCounterEl = document.getElementById("timeRemaining"); | ||
| const interval = setInterval(() => { | ||
| timeEl--; | ||
|
|
||
| timeRemainingCounterEl.textContent = `Time Remaining: ${time_convert(timeEl)}`; | ||
|
|
||
| if (timeEl <= 0) { | ||
| clearInterval(interval); | ||
| timeRemainingCounterEl.textContent = "Done!"; | ||
| playAlarm(); | ||
| } | ||
| }, 1000); | ||
| } | ||
|
|
||
|
|
||
| // DO NOT EDIT BELOW HERE | ||
|
|
||
|
|
@@ -23,3 +46,4 @@ function pauseAlarm() { | |
| } | ||
|
|
||
| window.onload = setup; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,3 +18,4 @@ <h1 id="timeRemaining">Time Remaining: 00:00</h1> | |
| <script src="alarmclock.js"></script> | ||
| </body> | ||
| </html> | ||
|
|
||
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.
Why did you undo the change where you changed the title in the HTML first?
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.
Thanks for the feedback. I originally changed the title via the DOM to practice DOM manipulation, but I’ve now updated it in the HTML file to match the requirements.