From acc3172b4589ce06d3b97b8294a83a3ad57e143b Mon Sep 17 00:00:00 2001 From: Marwen Date: Sun, 14 Oct 2018 12:03:33 +0200 Subject: [PATCH] Change document.querySelectorAll(query)[0] to document.querySelectorquery) --- client/clientDisplay.js | 18 +++++++++--------- client/clientSocket.js | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/client/clientDisplay.js b/client/clientDisplay.js index 6d9d7d6..b07e8c4 100644 --- a/client/clientDisplay.js +++ b/client/clientDisplay.js @@ -5,15 +5,15 @@ export class clientDisplay { //Methods from this class are called from clientGame.js upon game-state changes. constructor(gameState) { //These DOM calls are temporary, as we will be switching to data-targets! - this.gameMessage = document.querySelectorAll('*[data-game-message]')[0]; // These indexes mean there's no flexibility for now, as we need to wrap - this.secretWord = document.querySelectorAll('*[data-secret-word-container]')[0]; // Used by the code to calculate, may as well be a variable. - this.testt = document.querySelectorAll('[data-secret-word-display]')[0]; // Visible to user - this.userGuesses = document.querySelectorAll('*[data-user-guesses]')[0]; - this.onlinePlayers = document.querySelectorAll('*[data-online-players]')[0]; - this.guessInput = document.querySelectorAll('*[data-guess-input]')[0]; - this.usernameInput = document.querySelectorAll('*[data-username-input]')[0]; - this.guessSubmit = document.querySelectorAll('*[data-guess-submit]')[0]; - this.usernameSubmit = document.querySelectorAll('*[data-username-submit]')[0]; + this.gameMessage = document.querySelector('*[data-game-message]'); // These indexes mean there's no flexibility for now, as we need to wrap + this.secretWord = document.querySelector('*[data-secret-word-container]'); // Used by the code to calculate, may as well be a variable. + this.testt = document.querySelector('[data-secret-word-display]'); // Visible to user + this.userGuesses = document.querySelector('*[data-user-guesses]'); + this.onlinePlayers = document.querySelector('*[data-online-players]'); + this.guessInput = document.querySelector('*[data-guess-input]'); + this.usernameInput = document.querySelector('*[data-username-input]'); + this.guessSubmit = document.querySelector('*[data-guess-submit]'); + this.usernameSubmit = document.querySelector('*[data-username-submit]'); this.bodyParts = ['Head', 'Torso', 'Right_Arm', diff --git a/client/clientSocket.js b/client/clientSocket.js index f6b963b..e3543c7 100644 --- a/client/clientSocket.js +++ b/client/clientSocket.js @@ -5,9 +5,9 @@ var game = null; // We should move all of this ! We may need to pass a socket instance to the game if the reason this is here is // down to the fact that data doesn't flow from clientGame to clientSocket ( i.e a simple example, to pass the letter guess to here ) -var onlinePlayers = document.querySelectorAll('*[data-online-players]')[0]; -var guessSubmit = document.querySelectorAll('*[data-guess-submit]')[0]; -var guessInput = document.querySelectorAll('[data-guess-input]')[0]; +var onlinePlayers = document.querySelector('*[data-online-players]'); +var guessSubmit = document.querySelector('*[data-guess-submit]'); +var guessInput = document.querySelector('[data-guess-input]'); console.log(guessInput); guessSubmit.addEventListener('click', function(){ submitGuess(guessInput.value);