Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • ost/we1/testat-rockpaperscissoirs
1 result
Show changes
Commits on Source (3)
......@@ -31,7 +31,7 @@
<div id="game">
<label id="username-display"></label>
<div class="options">
<div id="options">
<button class="option" id="rock">Rock</button>
<button class="option" id="paper">Paper</button>
<button class="option" id="scissors">Scissors</button>
......
......@@ -7,12 +7,7 @@ import {getRankings, evaluateHand, createUserIfNotExists} from './game-service.j
const loginScreen = document.querySelector('#login');
const gameScreen = document.querySelector('#game');
const rockButton = document.querySelector('#rock');
const paperButton = document.querySelector('#paper');
const scissorsButton = document.querySelector('#scissors');
const wellButton = document.querySelector('#well');
const matchstickButton = document.querySelector('#matchstick');
const optionsButtons = [rockButton, paperButton, scissorsButton, wellButton, matchstickButton];
const options = document.querySelector('#options');
const loginForm = document.querySelector('#login-form');
const usernameInput = document.querySelector('#username-input');
......@@ -66,8 +61,8 @@ function showRankings(rankings) {
rankingTable.innerHTML = rankingsHtml;
}
function onOptionClick() {
const userHand = this.innerText;
function onOptionClick(event) {
const userHand = event.target.innerText;
playerHandLabel.innerText = userHand;
opponentHandLabel.innerText = '\n';
......@@ -148,7 +143,7 @@ function onMainMenuClick() {
getRankings(showRankings);
}
optionsButtons.forEach((button) => button.addEventListener('click', onOptionClick));
options.addEventListener('click', (event) => onOptionClick(event));
loginForm.addEventListener('submit', onLoginClick);
mainMenuButton.addEventListener('click', onMainMenuClick);
......
.options {
#options {
display: flex;
width: 50vw;
justify-content: space-evenly;
......