-
-
Notifications
You must be signed in to change notification settings - Fork 327
London | 26-ITP-May | Edina Kurdi | Sprint 3 | Alarm clock #1430
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 5 commits
13bf268
d22745d
e667709
1751d49
45dfc50
57d6de0
efd9c41
2e32afc
5893a8c
3fcc665
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,25 @@ | ||
| function setAlarm() {} | ||
| function setAlarm() { | ||
| const timeInput = document.getElementById("alarmSet"); | ||
| // console.log(timeInput.value); | ||
| let remainingSeconds = timeInput.value; | ||
|
|
||
| const timeRemaining = document.getElementById("timeRemaining"); | ||
| const minutes = String(Math.floor(remainingSeconds / 60)).padStart(2, "0"); | ||
| const seconds = String(remainingSeconds - minutes * 60).padStart(2, "0"); | ||
|
|
||
| timeRemaining.textContent = `Time Remaining: ${minutes}:${seconds}`; | ||
|
|
||
| const timer = setInterval(() => { | ||
| remainingSeconds--; | ||
| const minutes = String(Math.floor(remainingSeconds / 60)).padStart(2, "0"); | ||
| const seconds = String(remainingSeconds - minutes * 60).padStart(2, "0"); | ||
| timeRemaining.textContent = `Time Remaining: ${minutes}:${seconds}`; | ||
|
Contributor
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. Code on lines 7-10 is very similar to those on lines 14-16.
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. done. |
||
| if (remainingSeconds === 0) { | ||
| playAlarm(); | ||
| clearInterval(timer); | ||
| } | ||
| }, 1000); | ||
| } | ||
|
|
||
| // DO NOT EDIT BELOW HERE | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,23 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="utf-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <link rel="stylesheet" href="style.css" /> | ||
| <title>Title here</title> | ||
| </head> | ||
| <body> | ||
| <div class="centre"> | ||
| <h1 id="timeRemaining">Time Remaining: 00:00</h1> | ||
| <label for="alarmSet">Set time to:</label> | ||
| <input id="alarmSet" type="number" /> | ||
|
|
||
| <button id="set" type="button">Set Alarm</button> | ||
| <button id="stop" type="button">Stop Alarm</button> | ||
| </div> | ||
| <script src="alarmclock.js"></script> | ||
| </body> | ||
| </html> | ||
| <head> | ||
| <meta charset="utf-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <link rel="stylesheet" href="style.css" /> | ||
| <title>Alarm clock app</title> | ||
| </head> | ||
|
|
||
| <body> | ||
| <div class="centre"> | ||
| <h1 id="timeRemaining">Time Remaining: 00:00</h1> | ||
| <label for="alarmSet">Set time to:</label> | ||
| <input id="alarmSet" type="number" /> | ||
|
|
||
| <button id="set" type="button">Set Alarm</button> | ||
| <button id="stop" type="button">Stop Alarm</button> | ||
| </div> | ||
| <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.
Using raw input without proper validation is a dangerous practice. For number, we should consider
Unused code and comments should be removed to keep the code clean.
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.
Thank you for pointing this out.
Code is updated accordingly.