-
Notifications
You must be signed in to change notification settings - Fork 75
PTBC-1 zaver tan feng timer bootcamp #22
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
tanfeng95
wants to merge
2
commits into
rocketacademy:main
Choose a base branch
from
tanfeng95:main
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
2 commits
Select commit
Hold shift + click to select a range
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
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,12 +1,61 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <!-- Required meta tags --> | ||
| <meta charset="utf-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1"> | ||
|
|
||
| <!-- Bootstrap CSS --> | ||
| <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" | ||
| integrity="sha384-KyZXEAg3QhqLMpG8r+8fhAXLRk2vvoC2f3B09zVXn8CA5QIVfZOJ3BCsw2P0p/We" crossorigin="anonymous"> | ||
| <title>Timer</title> | ||
| <link rel="stylesheet" href="styles.css" /> | ||
| </head> | ||
|
|
||
| <body> | ||
| <h1 id="header">Timer!</h1> | ||
| <div class="container"> | ||
| <div class="row"> | ||
| <div class="col-3"> | ||
| <div class = 'row align-text-center'> | ||
| <h5>Lap data</h5> | ||
| </div> | ||
| <div class = 'row align-text-center'> | ||
| <div id = 'lap_data' class = 'text-center'> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| <div class="col"> | ||
| <div class="row text-center"> | ||
| <h5>Elapsed time</h3> | ||
| </div> | ||
| <div class="row align-text-center" > | ||
| <div id ='Elapsed_time' class="text-center"> | ||
| <label id="minutes">00</label> | ||
| <label id="colon">:</label> | ||
| <label id="seconds">00</label> | ||
| </div> | ||
| </div> | ||
| <div class="row"> | ||
| <div class='col text-center'> | ||
| <button class="btn btn-primary" onClick='start()'>start</button> | ||
| </div> | ||
| <div class='col text-center'> | ||
| <button class="btn btn-danger" onclick='stop()'>stop</button> | ||
| </div> | ||
| </div> | ||
| <div class="row"> | ||
| <div class='col text-center'> | ||
| <button class="btn btn-primary" onclick = 'reset()'>reset</button> | ||
| </div> | ||
| <div class='col text-center'> | ||
| <button class="btn btn-primary" onclick='lap()'>lap </button> | ||
| </div> | ||
| </div> | ||
|
|
||
| </div> | ||
| </div> | ||
| </div> | ||
| <!-- Import program logic --> | ||
| <script src="script.js"></script> | ||
| </body> | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 +1,51 @@ | ||
| // Please implement exercise logic here | ||
|
|
||
| const minutesLabel = document.getElementById('minutes'); | ||
| const secondsLabel = document.getElementById('seconds'); | ||
| let totalSeconds = 0; | ||
|
|
||
| let stopCount; | ||
|
|
||
| const start = () => { | ||
| stopCount = setInterval(setTime, 1000); | ||
| }; | ||
|
|
||
| const stop = () => { | ||
| clearInterval(stopCount); | ||
| }; | ||
| let lapArray = []; | ||
| const reset = () => { | ||
| clearInterval(stopCount); | ||
| minutesLabel.innerHTML = '00'; | ||
| secondsLabel.innerHTML = '00'; | ||
| lapArray = []; | ||
| const lapData = document.getElementById('lap_data'); | ||
| lapData.innerHTML = ''; | ||
| totalSeconds = 0; | ||
| }; | ||
|
|
||
| const lap = () => { | ||
| const minutesLabelCurrent = document.getElementById('minutes'); | ||
| const secondsLabelCurrent = document.getElementById('seconds'); | ||
| lapArray.push(`${minutesLabelCurrent.innerHTML} : ${secondsLabelCurrent.innerHTML}`); | ||
| console.log(lapArray); | ||
| const lapData = document.getElementById('lap_data'); | ||
| const lapDiv = document.createElement('div'); | ||
| lapDiv.innerHTML = lapArray[lapArray.length - 1]; | ||
| lapData.appendChild(lapDiv); | ||
| }; | ||
|
|
||
| function setTime() { | ||
| ++totalSeconds; | ||
| secondsLabel.innerHTML = pad(totalSeconds % 60); | ||
| minutesLabel.innerHTML = pad(parseInt(totalSeconds / 60)); | ||
| } | ||
|
|
||
| function pad(val) { | ||
| const valString = `${val}`; | ||
| if (valString.length < 2) { | ||
| return `0${valString}`; | ||
| } | ||
|
|
||
| return valString; | ||
| } |
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,140 @@ | ||
| <!doctype html> | ||
| <html lang="en"> | ||
|
|
||
| <head> | ||
| <!-- Required meta tags --> | ||
| <meta charset="utf-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1"> | ||
|
|
||
| <!-- Bootstrap CSS --> | ||
| <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" | ||
| integrity="sha384-KyZXEAg3QhqLMpG8r+8fhAXLRk2vvoC2f3B09zVXn8CA5QIVfZOJ3BCsw2P0p/We" crossorigin="anonymous"> | ||
|
|
||
| <title>timer boot camp</title> | ||
| </head> | ||
|
|
||
| <body> | ||
| <div class="container"> | ||
| <div class="row"> | ||
| <div class="col-3"> | ||
| <div class = 'row align-text-center'> | ||
| <h5>Lap data</h5> | ||
| </div> | ||
| <div class = 'row align-text-center'> | ||
| <div id = 'lap_data' class = 'text-center'> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| <div class="col"> | ||
| <div class="row text-center"> | ||
| <h5>Elapsed time</h3> | ||
| </div> | ||
| <div class="row align-text-center" > | ||
| <div id ='Elapsed_time' class="text-center"> | ||
| <label id="minutes">00</label> | ||
| <label id="colon">:</label> | ||
| <label id="seconds">00</label> | ||
| </div> | ||
| </div> | ||
| <div class="row"> | ||
| <div class='col text-center'> | ||
| <button class="btn btn-primary" onClick='start()'>start</button> | ||
| </div> | ||
| <div class='col text-center'> | ||
| <button class="btn btn-danger" onclick='stop()'>stop</button> | ||
| </div> | ||
| </div> | ||
| <div class="row"> | ||
| <div class='col text-center'> | ||
| <button class="btn btn-primary" onclick = 'reset()'>reset</button> | ||
| </div> | ||
| <div class='col text-center'> | ||
| <button class="btn btn-primary" onclick='lap()'>lap </button> | ||
| </div> | ||
| </div> | ||
|
|
||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
|
|
||
| <!-- Optional JavaScript; choose one of the two! --> | ||
|
|
||
| <!-- Option 1: Bootstrap Bundle with Popper --> | ||
| <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" | ||
| integrity="sha384-U1DAWAznBHeqEIlVSCgzq+c9gqGAJn5c/t99JyeKa9xxaYpSvHU5awsuZVVFIhvj" | ||
| crossorigin="anonymous"></script> | ||
|
|
||
| <!-- Option 2: Separate Popper and Bootstrap JS --> | ||
| <!-- | ||
| <script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-eMNCOe7tC1doHpGoWe/6oMVemdAVTMs2xqW4mwXrXsW0L84Iytr2wi5v2QjrP/xp" crossorigin="anonymous"></script> | ||
| <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-cn7l7gDp0eyniUwwAZgrzD06kc/tftFf19TOAs2zVinnD/C7E91j9yyk5//jjpt/" crossorigin="anonymous"></script> | ||
| --> | ||
| </body> | ||
| <style> | ||
|
|
||
| .row{ | ||
| padding: 10px; | ||
| } | ||
| </style> | ||
|
|
||
| <script> | ||
| // const display1 = document.createElement('div'); | ||
| // document.body.appendChild(display1) | ||
|
|
||
| var minutesLabel = document.getElementById("minutes"); | ||
| var secondsLabel = document.getElementById("seconds"); | ||
| var totalSeconds = 0; | ||
|
|
||
| let stopCount ; | ||
|
|
||
| const start = () =>{ | ||
| stopCount = setInterval(setTime, 1000); | ||
| } | ||
|
|
||
| const stop = () =>{ | ||
| clearInterval(stopCount); | ||
| } | ||
| let lapArray = [] | ||
| const reset = () =>{ | ||
| clearInterval(stopCount); | ||
| minutesLabel.innerHTML = '00' | ||
| secondsLabel.innerHTML = '00' | ||
| lapArray = [] | ||
| let lapData = document.getElementById("lap_data") | ||
| lapData.innerHTML = '' | ||
| totalSeconds = 0 | ||
| } | ||
|
|
||
|
|
||
| const lap = ()=>{ | ||
| let minutesLabelCurrent = document.getElementById("minutes"); | ||
| var secondsLabelCurrent = document.getElementById("seconds"); | ||
| lapArray.push(`${minutesLabelCurrent.innerHTML} : ${secondsLabelCurrent.innerHTML}`) | ||
| console.log(lapArray) | ||
| let lapData = document.getElementById("lap_data") | ||
| const lapDiv = document.createElement("div") | ||
| lapDiv.innerHTML = lapArray[lapArray.length-1] | ||
| lapData.appendChild(lapDiv) | ||
|
|
||
| } | ||
|
|
||
|
|
||
|
|
||
| function setTime() { | ||
| ++totalSeconds; | ||
| secondsLabel.innerHTML = pad(totalSeconds % 60); | ||
| minutesLabel.innerHTML = pad(parseInt(totalSeconds / 60)); | ||
| } | ||
|
|
||
| function pad(val) { | ||
| var valString = val + ""; | ||
| if (valString.length < 2) { | ||
| return "0" + valString; | ||
| } | ||
| else { | ||
| return valString; | ||
| } | ||
| } | ||
| </script> | ||
| </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,3 +1,7 @@ | ||
| body { | ||
| background-color: pink; | ||
| } | ||
|
|
||
| .row { | ||
| padding: 10px; | ||
| } |
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.
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.
all these should be created in script js using DOM