Skip to content
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

Autocompletion off + button "Play" #38

Merged
merged 2 commits into from
Jan 15, 2021
Merged

Autocompletion off + button "Play" #38

merged 2 commits into from
Jan 15, 2021

Conversation

AgataLudwiczynska
Copy link
Collaborator

No description provided.

index.html Outdated
@@ -47,7 +47,7 @@
</div>

<div id='startGame' class="secondColumn spanInPortrait disableWithPopUpScreen">
<input type='button' id='startGameButton' class="buttonWithText" value='PLAY'>
<input type='button' id='startGameButton' class="buttonWithText" value='PLAY' autocomplete='off'>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool and easy 😌

src/app/App.js Outdated
Comment on lines 44 to 49
document.querySelector('#enterYourNameInput').addEventListener("change", () =>{
document.querySelector("#startGameButton").addEventListener("click", () => {
const userName = document.querySelector('#enterYourNameInput').value;
renderQuizPage(SELECTED_MODE, userName, options.quizMaxTime)
});
})
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is a good approach. By this way you will be adding new event listener to #startGameButton every time you change something on name input. If somebody will write 1000 letters there -> then there will be 1000 listeners that will render quiz page. Not good :)

Better approach is look at this:
https://stackoverflow.com/questions/7067005/disable-button-whenever-a-text-field-is-empty-dynamically

  • make "PLAY" button disabled by default.
  • add "onkeyup" (not sure about exact name) event listener to the "name input" that will execute something like this:
function stoppedTyping(){
        if(this.value.length > 0) { 
            document.getElementById('start_button').disabled = false; 
        } else { 
            document.getElementById('start_button').disabled = true;
        }
    }

Copy link
Owner

@lukaszdutka lukaszdutka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

@lukaszdutka lukaszdutka merged commit 46d82da into dev Jan 15, 2021
@lukaszdutka lukaszdutka deleted the MNG-53-Button-Play- branch January 15, 2021 18:46
@lukaszdutka lukaszdutka restored the MNG-53-Button-Play- branch January 15, 2021 18:47
@lukaszdutka lukaszdutka deleted the MNG-53-Button-Play- branch January 15, 2021 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants