-
-
Notifications
You must be signed in to change notification settings - Fork 278
Glasgow | 26-ITP-Jan| Martin McLean |Sprint 3|AlarmClock #1044
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
f8431ee
fd7a1c6
49bd8ef
31cd870
a6cd0fd
4bcc01a
1e600fa
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,20 @@ | ||
| <!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" onfocus="" /> | ||
|
|
||
| <button id="set" type="button">Set Alarm</button> | ||
| <button id="stop" type="button">Stop Alarm</button> | ||
| </div> | ||
| <script src="alarmclock.js"></script> | ||
| </body> | ||
| </html> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,38 @@ | ||
| function setAlarm() {} | ||
| botton = document.getElementById("set"); | ||
| //begins the count down | ||
| botton.addEventListener("click", setAlarm); | ||
|
|
||
| // document.getElementById("set").addEventListener("click", setAlarm); | ||
| const timeRemaining = document.getElementById("timeRemaining"); | ||
| function setAlarm() { | ||
| // gets the value of the input field and stores it in a variable | ||
| let timeInSeconds = document.getElementById("alarmSet").value; | ||
| botton.disabled = true; | ||
|
|
||
| let clock = setInterval(() => { | ||
| function pad(num) { | ||
| return num.toString().padStart(2, "0"); | ||
| } | ||
|
|
||
| function formatTimeDisplay(timeInSeconds) { | ||
| const remainingSeconds = timeInSeconds % 60; | ||
| const totalMinutes = (timeInSeconds - remainingSeconds) / 60; | ||
| const remainingMinutes = totalMinutes % 60; | ||
| const totalHours = (totalMinutes - remainingMinutes) / 60; | ||
|
|
||
| return `${pad(totalHours)}:${pad(remainingMinutes)}:${pad(remainingSeconds)}`; | ||
| } | ||
|
|
||
| timeInSecond = timeInSeconds--; | ||
|
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. timeInSecond is not used
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. with out this the clock wont tick down 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. botton , timeInSecond It is recommended to declare parameters using |
||
| if (timeInSeconds == 0) { | ||
| clearInterval(clock); | ||
| playAlarm(); | ||
| botton.disabled = false; | ||
| } | ||
| timeRemaining.innerHTML = | ||
| "time remaining " + formatTimeDisplay(timeInSeconds); | ||
| }, 1000); | ||
| } | ||
|
|
||
| // DO NOT EDIT BELOW HERE | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,24 @@ | ||
| body { | ||
| min-width: fit-content; | ||
| font-size: 20px; | ||
| background-color: darkorchid; | ||
| color: rgb(113, 48, 48); | ||
| } | ||
|
|
||
| .centre { | ||
| position: fixed; | ||
| top: 50%; | ||
| left: 50%; | ||
| -webkit-transform: translate(-50%, -50%); | ||
| transform: translate(-50%, -50%); | ||
| } | ||
|
|
||
| button { | ||
| border-radius: 30px; | ||
| } | ||
| #alarmSet { | ||
| margin: 20px; | ||
| margin: 0px; | ||
| } | ||
|
|
||
| h1 { | ||
| text-align: center; | ||
| text-align: right; | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.
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.
basic operate is fine, but second round would remain last round info, causing non-normal appearance
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.
i have set a lock out after the button is clicked till the alarm goes off
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.
Currently, the program gets stuck in the last second, and the end button is disabled.