Skip to content

Commit

Permalink
add button to show Welcome screen again #21
Browse files Browse the repository at this point in the history
  • Loading branch information
blahosyl committed Apr 1, 2024
1 parent 524d0db commit e0812b6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
5 changes: 5 additions & 0 deletions assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@ a {
margin-left: 2px;
}

#welcome-screen-button {
margin-top: 1rem;
display: none;
}

/* Media Queries */

/* narrow screens */
Expand Down
22 changes: 19 additions & 3 deletions assets/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ const scoreRulesSection = document.getElementById('score-rules-section');
const gameplayRulesButton = document.getElementById('gameplay-rules-button');

// Gameplay
// the button for showing the welcome screen again
const welcomeScreenButton = document.getElementById('welcome-screen-button');
// the `div` where the solution/congratulation text is displayed
const solutionDiv = document.getElementById('solution');
// the Check Answer/Submit button
Expand Down Expand Up @@ -65,6 +67,9 @@ newGameButton.addEventListener('click',newGame);
// add event listener to Submit button to check the user asnwer
submitButton.addEventListener('click',checkAnswer);

// show the Welcome screen
welcomeScreenButton.addEventListener('click',showWelcomeScreen);

// when the operand selector is changed, add the correcponding number of operand+operator pairs
let operandSelector = document.getElementById('number-selector');
operandSelector.addEventListener('change',setOperandOperatorCount);
Expand Down Expand Up @@ -97,10 +102,19 @@ function showGameplayRulesDiv() {
}

/**
* Hide the `welcomeSection`
* Hide the `welcomeSection` and show the `welcomeScreenButton`
*/
function startGame() {
welcomeSection.style.display = 'none';
welcomeScreenButton.style.display = 'inline';
}

/**
* Show the `welcomeSection` and hide the `welcomeScreenButton`
*/
function showWelcomeScreen() {
welcomeSection.style.display = 'flex';
welcomeScreenButton.style.display = 'none';
}

// generating and displaying operands (numbers)
Expand Down Expand Up @@ -355,17 +369,19 @@ function refreshStreakCounter() {
}

/**
* Show the `milestoneSection`
* Show the `milestoneSection` and hide the `welcomeScreenButton`
*/
function showMilestone() {
milestoneSection.style.display = 'flex';
welcomeScreenButton.style.display = 'none';
}

/**
* Hide the `milestoneSection`
* Hide the `milestoneSection` and show the `welcomeScreenButton`
*/
function continueGame() {
milestoneSection.style.display = 'none';
welcomeScreenButton.style.display = 'inline';
}

/**
Expand Down
3 changes: 3 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ <h1 class="heading">Operator Game</h1>
</form>
</div>

<!-- button to show the Welcome screen again -->
<button data-type="submit" id="welcome-screen-button" class="small-button" aria-label="Click to show the rules again">Show the rules again</button>

<!-- load JavaScrip file -->
<script src="assets/js/script.js"></script>

Expand Down

0 comments on commit e0812b6

Please sign in to comment.