generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 277
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
Open
mjm-git185
wants to merge
7
commits into
CodeYourFuture:main
Choose a base branch
from
mjm-git185:clock
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f8431ee
tic tock
mjm-git185 fd7a1c6
happy with my clock
mjm-git185 49bd8ef
set button is locked out till thje alame goes
mjm-git185 31cd870
tic tock
mjm-git185 a6cd0fd
happy with my clock
mjm-git185 4bcc01a
set button is locked out till thje alame goes
mjm-git185 1e600fa
Merge branch 'clock' of https://github.com/mjm-git185/Module-Data-Gro…
mjm-git185 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
||
| if (timeInSeconds == 0) { | ||
| clearInterval(clock); | ||
| playAlarm(); | ||
| botton.disabled = false; | ||
| } | ||
| timeRemaining.innerHTML = | ||
| "time remaining " + formatTimeDisplay(timeInSeconds); | ||
| }, 1000); | ||
| } | ||
|
|
||
| // DO NOT EDIT BELOW HERE | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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