(tile, index, array, guess)
| 15387 | } |
| 15388 | |
| 15389 | function flipTile(tile, index, array, guess) { |
| 15390 | const letter = tile.dataset.letter |
| 15391 | const key = keyboard.querySelector(`[data-key="${letter}"i]`) |
| 15392 | setTimeout(() => { |
| 15393 | tile.classList.add("flip") |
| 15394 | }, (index * FLIP_ANIMATION_DURATION) / 2) |
| 15395 | |
| 15396 | tile.addEventListener( |
| 15397 | "transitionend", |
| 15398 | () => { |
| 15399 | tile.classList.remove("flip") |
| 15400 | if (targetWord[index] === letter) { |
| 15401 | tile.dataset.state = "correct" |
| 15402 | key.classList.add("correct") |
| 15403 | } else if (targetWord.includes(letter)) { |
| 15404 | tile.dataset.state = "wrong-location" |
| 15405 | key.classList.add("wrong-location") |
| 15406 | } else { |
| 15407 | tile.dataset.state = "wrong" |
| 15408 | key.classList.add("wrong") |
| 15409 | } |
| 15410 | |
| 15411 | if (index === array.length - 1) { |
| 15412 | tile.addEventListener( |
| 15413 | "transitionend", |
| 15414 | () => { |
| 15415 | startInteraction() |
| 15416 | checkWinLose(guess, array) |
| 15417 | }, |
| 15418 | { once: true } |
| 15419 | ) |
| 15420 | } |
| 15421 | }, |
| 15422 | { once: true } |
| 15423 | ) |
| 15424 | } |
| 15425 | |
| 15426 | function getActiveTiles() { |
| 15427 | return guessGrid.querySelectorAll('[data-state="active"]') |
no test coverage detected