MCPcopy Create free account
hub / github.com/WebDevSimplified/wordle-clone / flipTile

Function flipTile

script.js:15389–15424  ·  view source on GitHub ↗
(tile, index, array, guess)

Source from the content-addressed store, hash-verified

15387}
15388
15389function 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
15426function getActiveTiles() {
15427 return guessGrid.querySelectorAll('[data-state="active"]')

Callers 1

submitGuessFunction · 0.85

Calls 2

startInteractionFunction · 0.85
checkWinLoseFunction · 0.85

Tested by

no test coverage detected