Added some style logic

This commit is contained in:
2021-12-27 15:04:07 -03:00
parent 70e6ddcedb
commit 0102f9b106
14 changed files with 200 additions and 14 deletions

View File

@@ -0,0 +1,6 @@
export default function addStartButtonFunctionality(game) {
const button = document.getElementById('start')
button.addEventListener('click', game)
}

View File

@@ -0,0 +1,47 @@
export default function checkInputs() {
const player1 = document.getElementsByClassName('player player-1')[0]
const player2 = document.getElementsByClassName('player player-2')[0]
const inputsPlayer1 = [player1.children[0], player1.children[1].children[1]]
const inputsPlayer2 = [player2.children[0], player2.children[1].children[0]]
const inputsEmptys = []
inputsPlayer1.forEach(input => {
if (input.value === '') {
inputsEmptys.push(' ' + input.className + ' (player 1)')
}
})
inputsPlayer2.forEach(input => {
if (input.value === '') {
inputsEmptys.push(' ' + input.className + ' (player 2)')
}
})
if (inputsEmptys.length) {
alert('Please fill the inputs: ' + inputsEmptys)
return true
}
if (inputsPlayer1[0].value === inputsPlayer2[0].value) {
alert('Same usernames')
return true
}
if (inputsPlayer1[1].value === inputsPlayer2[1].value) {
alert('Same symbol')
return true
}
}

View File

@@ -0,0 +1,12 @@
export default function hidePlayerSelection() {
const playerSelection = document.getElementsByClassName('player-selection')[0]
playerSelection.classList.add('animate__fadeOutDown')
setTimeout(() => {
playerSelection.classList.add('hidden')
}, 1000)
}

View File

@@ -0,0 +1,11 @@
export default function showTicTacToe() {
const game = document.getElementsByClassName('game')[0]
setTimeout(() => {
game.classList.remove('hidden')
game.classList.add('animate__fadeInDown')
}, 1000);
}