-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
38 lines (25 loc) · 943 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { INPUTS, SLOTS, initializeInputs, assignSlots } from './create_inputs.js'
import { inputsLogic } from './inputs_logic.js'
import { keyFilter } from './inputs_filter.js'
import { reset } from './reset.js'
import { attemptsTextAndColor, attemptsLogic, attemptsAmount } from './attempts.js'
import { showTip } from './tip.js'
import { gameOver } from './gameover.js'
// INICIALIZAR INPUTS --->
initializeInputs(4)
assignSlots()
// INICIALIZAR TENTATIVAS --->
attemptsTextAndColor()
// DETECTAR INPUT DO USUÁRIO --->
INPUTS.forEach((elem, index) => {
elem.addEventListener('keypress', keyFilter)
elem.addEventListener('input', () => {
inputsLogic(elem, index, INPUTS, SLOTS)
attemptsLogic(index, SLOTS)
showTip()
gameOver(INPUTS, SLOTS)
})
})
// DETECTAR CLIQUE NO RESET --->
const RESET_BUTTON = document.querySelector('[data-retry]')
RESET_BUTTON.addEventListener('click', reset)