-
-
Notifications
You must be signed in to change notification settings - Fork 280
London | ITP-Jan-26 | Maryanne Mosonik | Sprint 3 | Alarm Clock #1091
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 |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| { | ||
| "folders": [ | ||
| { | ||
| "path": "../.." | ||
| }, | ||
| { | ||
| "name": "Sprint-1", | ||
| "path": "../../Sprint-1" | ||
| }, | ||
| { | ||
| "name": "Sprint-2", | ||
| "path": "../../Sprint-2" | ||
| }, | ||
| { | ||
| "name": "Sprint-3", | ||
| "path": ".." | ||
| }, | ||
| { | ||
| "name": "slideshow", | ||
| "path": "../slideshow" | ||
| }, | ||
| { | ||
| "name": "reading-list", | ||
| "path": "../reading-list" | ||
| }, | ||
| { | ||
| "name": "alarmclock", | ||
| "path": "." | ||
| }, | ||
| { | ||
| "name": "todo-list", | ||
| "path": "../todo-list" | ||
| }, | ||
| { | ||
| "name": "quote-generator", | ||
| "path": "../quote-generator" | ||
| } | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,35 @@ | ||
| function setAlarm() {} | ||
| let countdown; | ||
| let remainingTime = 0; | ||
|
|
||
| function setAlarm() { | ||
| const input = document.getElementById("alarmSet"); | ||
| const seconds = parseInt(input.value, 10); | ||
| if (isNaN(seconds) || seconds <= 0) return; | ||
|
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. Nice validation of the user input. Its important to always validate the user data. How could you inform the user about that the input is invalid? |
||
|
|
||
| clearInterval(countdown); | ||
| remainingTime = seconds; | ||
|
|
||
| const display = document.getElementById("timeRemaining"); | ||
| display.textContent = `Time Remaining: ${formatTime(remainingTime)}`; | ||
|
|
||
| countdown = setInterval(() => { | ||
| remainingTime--; | ||
| display.textContent = `Time Remaining: ${formatTime(remainingTime)}`; | ||
|
|
||
| if (remainingTime <= 0) { | ||
| clearInterval(countdown); | ||
| if (typeof playAlarm === "function") { | ||
|
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 do you need to check if playAlarm is a function? |
||
| window.playAlarm(); | ||
| } | ||
| } | ||
| }, 1000); | ||
| } | ||
|
|
||
| function formatTime(seconds) { | ||
| const mins = String(Math.floor(seconds / 60)).padStart(2, "0"); | ||
| const secs = String(seconds % 60).padStart(2, "0"); | ||
| return `${mins}:${secs}`; | ||
| } | ||
|
|
||
| // DO NOT EDIT BELOW HERE | ||
|
|
||
|
|
||
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 intentadion of the code seems incorrect. How can you ensure that the format is always consistent based on agreed rules?