Merged
Conversation
Closed
2 tasks
Nefariusek
requested changes
Dec 6, 2021
src/main.js
Outdated
| `; | ||
| document.querySelector('#app').appendChild(createTimer()); | ||
| startTimer(); | ||
| //setTimeout(stopTimer, 1000 * 35); |
src/components/timer/quiz-timer.js
Outdated
| @@ -0,0 +1,57 @@ | |||
| var timer; | |||
src/components/timer/quiz-timer.js
Outdated
Comment on lines
+4
to
+20
| const clock = document.createElement('div'); | ||
| clock.setAttribute('id', 'clock'); | ||
|
|
||
| const image = document.createElement('img'); | ||
| image.setAttribute('id', 'clk_img'); | ||
| image.src = '/timer.png'; | ||
|
|
||
| const minutes = document.createElement('span'); | ||
| minutes.setAttribute('id', 'min'); | ||
| minutes.innerText = '00'; | ||
|
|
||
| const colon = document.createElement('span'); | ||
| colon.innerText = ':'; | ||
|
|
||
| const seconds = document.createElement('span'); | ||
| seconds.setAttribute('id', 'sec'); | ||
| seconds.innerText = '00'; |
Owner
There was a problem hiding this comment.
To improve readability, replace abbreviations in ids with full names eg. min-> minutes or even timer-minutes
Comment on lines
+7
to
+10
| const image = document.createElement('img'); | ||
| image.setAttribute('id', 'clk_img'); | ||
| image.src = '/timer.png'; | ||
|
|
Owner
There was a problem hiding this comment.
Instead of clk_img, we can use selector #clock img
src/components/timer/quiz-timer.js
Outdated
Comment on lines
+31
to
+32
| let minutes = 0, | ||
| seconds = 0; |
Owner
There was a problem hiding this comment.
this approach is harder to extend/modify
use:
let minutes = 0;
let seconds = 0;
Comment on lines
+36
to
+37
| min.innerText = '00'; | ||
| sec.innerText = '00'; |
Owner
There was a problem hiding this comment.
It is duplicated in createTimer function;
Keep it just here
src/components/timer/quiz-timer.js
Outdated
Comment on lines
+47
to
+49
| min.innerText = minutes < 10 ? '0' + minutes : minutes; | ||
| } | ||
| sec.innerText = seconds < 10 ? '0' + seconds : seconds; |
Owner
There was a problem hiding this comment.
Use a separate function to check this condition. Pass minutes/seconds, return what should be assigned to innerText
Owner
|
@MariaBanaszkiewicz please resolve conflits and merge this pull request |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Quiz timer, that counts time up in real-time.