-
-
Notifications
You must be signed in to change notification settings - Fork 280
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 all commits
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? |
||
| const alarmSetInputEl = document.getElementById("alarmSet"); | ||
| let timeEl = Number(alarmSetInputEl.value); | ||
|
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 if the user enters a negative number or a non number string? |
||
| 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?