word-games-theme 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/_data/wordgames/en/word-game-play.json +6 -43
- data/_includes/section/home2.html +2 -1
- data/_includes/word-game/word-game-generator-online.html +8 -5
- data/_includes/word-game/word-game-play.html +178 -55
- data/_includes/wordle-solver/wordle-solver.html +11 -0
- data/assets/css/game.css +307 -7
- data/assets/css/wordleSolver.css +11 -0
- data/assets/images/close.png +0 -0
- data/assets/images/copy.svg +1 -0
- data/assets/images/facebooks.svg +1 -0
- data/assets/images/twitters.svg +1 -0
- data/assets/images/whatsapp.svg +1 -0
- data/assets/js/confetti.js +130 -0
- data/assets/js/createWordle.js +39 -5
- data/assets/js/game.js +260 -31
- metadata +8 -2
data/assets/js/game.js
CHANGED
@@ -3,37 +3,266 @@ let gameBoard = document.querySelector(".game-board")
|
|
3
3
|
let serachValue = params.get('q')
|
4
4
|
let decodeBase64 = atob(serachValue)
|
5
5
|
let word = decodeBase64
|
6
|
-
let
|
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
|
-
|
6
|
+
let targetWord = word.toLocaleLowerCase()
|
7
|
+
let ANIMATION_DURATION = 500
|
8
|
+
let wordLength = 5
|
9
|
+
let keyboard = document.querySelector(".game-keyboard")
|
10
|
+
let alertContainer = document.querySelector(".alert-container")
|
11
|
+
let errorMsg = document.querySelector("#errorMsg")
|
12
|
+
let gameResult = document.querySelector(".gameResult")
|
13
|
+
let openPopup = document.querySelector(".open-popup")
|
14
|
+
let wordleGameShareLink = document.querySelector(".wordle-game-share-link")
|
15
|
+
let wordleGameCopyLink = document.querySelector(".wordle-game-copy-link")
|
16
|
+
let ResutlGuessWord = document.querySelector(".guess-word")
|
17
|
+
let answer = document.querySelector("#answer")
|
18
|
+
let facebookSHareLink = document.querySelector(".facebook-share-link")
|
19
|
+
let twitterSHareLink = document.querySelector(".twitter-share-link")
|
20
|
+
let whatsappSHareLink = document.querySelector(".whatsapp-share-link")
|
21
|
+
|
22
|
+
document.querySelector(".navbar").style.display = "none"
|
23
|
+
document.querySelector(".tools_headings").style.display = "none"
|
24
|
+
document.querySelector(".ads_layout").style.display = "none"
|
25
|
+
document.querySelector(".relatedPosts").style.display = "none"
|
26
|
+
document.querySelector(".footer-section").style.display = "none"
|
27
|
+
document.querySelector(".rating-tool").style.display = "none"
|
28
|
+
|
29
|
+
|
30
|
+
let dictionary
|
31
|
+
let attempt = 0
|
32
|
+
async function getData() {
|
33
|
+
const response = await fetch("/dictionary.json")
|
34
|
+
const data = await response.json()
|
35
|
+
dictionary = data
|
36
|
+
}
|
37
|
+
getData()
|
38
|
+
|
39
|
+
const handleClick = (e) => {
|
40
|
+
if (e.target.matches("[data-key]")) {
|
41
|
+
pressKey(e.target.dataset.key)
|
42
|
+
return
|
43
|
+
}
|
44
|
+
if (e.target.matches("[data-enter]")) {
|
45
|
+
handleSubmit()
|
46
|
+
return
|
47
|
+
}
|
48
|
+
if (e.target.matches("[data-delete]")) {
|
49
|
+
deleteKey()
|
50
|
+
return
|
51
|
+
}
|
52
|
+
}
|
53
|
+
const handleKeyPress = (e) => {
|
54
|
+
if (e.key === "Enter") {
|
55
|
+
handleSubmit()
|
56
|
+
return
|
57
|
+
}
|
58
|
+
if (e.key === "Delete" || e.key === "Backspace") {
|
59
|
+
deleteKey()
|
60
|
+
return
|
61
|
+
}
|
62
|
+
|
63
|
+
if (e.key.match(/^[a-zA-Z]$/)) {
|
64
|
+
pressKey(e.key)
|
65
|
+
return
|
66
|
+
}
|
67
|
+
}
|
68
|
+
const getActiveTiles = () => {
|
69
|
+
return gameBoard.querySelectorAll('[data-state="active"]')
|
70
|
+
}
|
71
|
+
const pressKey = (key) => {
|
72
|
+
const activeTiles = getActiveTiles()
|
73
|
+
if (activeTiles.length >= wordLength) return
|
74
|
+
const nextTile = gameBoard.querySelector(":not([data-letter])")
|
75
|
+
nextTile.dataset.letter = key.toLowerCase()
|
76
|
+
nextTile.dataset.state = "active"
|
77
|
+
nextTile.classList.add("popAni")
|
78
|
+
nextTile.innerText = key
|
79
|
+
nextTile.style.border = "2px solid #a7adc0"
|
80
|
+
}
|
81
|
+
const deleteKey = () => {
|
82
|
+
const activeTiles = getActiveTiles()
|
83
|
+
const lastTile = activeTiles[activeTiles.length - 1]
|
84
|
+
if (lastTile == null) return
|
85
|
+
lastTile.textContent = ""
|
86
|
+
delete lastTile.dataset.state
|
87
|
+
delete lastTile.dataset.letter
|
88
|
+
lastTile.style.border = "2px solid #dee1e9"
|
89
|
+
lastTile.classList.remove("popAni")
|
90
|
+
}
|
91
|
+
const handleSubmit = () => {
|
92
|
+
const allTiles = [...getActiveTiles()]
|
93
|
+
if (allTiles.length !== wordLength) {
|
94
|
+
showAlertMessage("Not enough letters")
|
95
|
+
shakeTiles(allTiles)
|
96
|
+
return
|
97
|
+
}
|
98
|
+
const guessWord = allTiles.reduce((word, tile) => {
|
99
|
+
return word + tile.dataset.letter
|
100
|
+
}, "")
|
101
|
+
|
102
|
+
|
103
|
+
if (guessWord === targetWord) {
|
104
|
+
} else {
|
105
|
+
if (!dictionary.includes(guessWord)) {
|
106
|
+
showAlertMessage("Not a valid word")
|
107
|
+
shakeTiles(allTiles)
|
108
|
+
return
|
36
109
|
}
|
37
110
|
}
|
111
|
+
|
112
|
+
stopAllEventListeners()
|
113
|
+
let matchLetters = [...targetWord]
|
114
|
+
let matchedLettersCount = matchLetters.reduce((obj, letter) => {
|
115
|
+
if (obj[letter]) {
|
116
|
+
obj[letter]++;
|
117
|
+
return obj;
|
118
|
+
}
|
119
|
+
|
120
|
+
obj[letter] = 1;
|
121
|
+
return obj;
|
122
|
+
}, {})
|
123
|
+
evaluateTiles(allTiles, matchedLettersCount, guessWord)
|
38
124
|
}
|
39
|
-
|
125
|
+
const evaluateTiles = (allTiles, matchedLettersCount, guessWord) => {
|
126
|
+
let reEvaluate = []
|
127
|
+
allTiles.map((tile, index) => {
|
128
|
+
let letter = tile.dataset.letter
|
129
|
+
let key = keyboard.querySelector(`[data-key="${letter}"i]`)
|
130
|
+
if (targetWord[index] === letter) {
|
131
|
+
tile.dataset.state = "correct-spot"
|
132
|
+
key.dataset.state = "correct-spot"
|
133
|
+
matchedLettersCount[letter]--;
|
134
|
+
return
|
135
|
+
}
|
136
|
+
reEvaluate.push(tile)
|
137
|
+
})
|
138
|
+
reEvaluate.map((tile) => {
|
139
|
+
let letter = tile.dataset.letter
|
140
|
+
let key = keyboard.querySelector(`[data-key="${letter}"i]`)
|
141
|
+
if (matchedLettersCount[letter] > 0) {
|
142
|
+
tile.dataset.state = "wrong-spot"
|
143
|
+
key.dataset.state = "wrong-spot"
|
144
|
+
matchedLettersCount[letter]--;
|
145
|
+
}
|
146
|
+
else {
|
147
|
+
tile.dataset.state = "wrong-word"
|
148
|
+
key.dataset.state = "wrong-word"
|
149
|
+
}
|
150
|
+
|
151
|
+
})
|
152
|
+
startAllEventListeners()
|
153
|
+
gameOver(guessWord, allTiles)
|
154
|
+
}
|
155
|
+
const shakeTiles = (tiles) => {
|
156
|
+
tiles.forEach(tile => {
|
157
|
+
tile.classList.add("shake")
|
158
|
+
tile.addEventListener('animationend', () => {
|
159
|
+
// console.log('Animation ended');
|
160
|
+
tile.classList.remove("shake")
|
161
|
+
});
|
162
|
+
})
|
163
|
+
}
|
164
|
+
const gameOver = (guessWord, tiles) => {
|
165
|
+
attempt++
|
166
|
+
const danceTiles = (tiles) => {
|
167
|
+
tiles.forEach((tile) => {
|
168
|
+
tile.classList.add("dance")
|
169
|
+
tile.addEventListener("animationend", () => {
|
170
|
+
tile.classList.remove("dance")
|
171
|
+
})
|
172
|
+
})
|
173
|
+
}
|
174
|
+
if (guessWord === targetWord) {
|
175
|
+
// console.log(`Wordle guessed in ${attempt}/6!`)
|
176
|
+
facebookSHareLink.setAttribute("href",
|
177
|
+
`https://www.facebook.com/share.php?u=${window.location.protocol + "//" + window.location.hostname}/word-game-play?q=${(serachValue)}"e=
|
178
|
+
I guessed this wordle in ${attempt}/6 tries. Can you do better ?
|
179
|
+
Try this wordle:
|
180
|
+
${window.location.protocol + "//" + window.location.hostname}/word-game-play?q=${(serachValue)}`)
|
181
|
+
|
182
|
+
twitterSHareLink.setAttribute("href",
|
183
|
+
`https://www.twitter.com/compose/tweet?&text=I guessed this wordle in ${attempt}/6 tries.
|
184
|
+
Can you do better ? Try this wordle: ${window.location.protocol + "//" + window.location.hostname}/word-game-play?q=${(serachValue)}`)
|
185
|
+
|
186
|
+
whatsappSHareLink.setAttribute("href", `whatsapp://send?text=I guessed this wordle in ${attempt}/6 tries.
|
187
|
+
Can you do better ? Try this wordle: ${window.location.protocol + "//" + window.location.hostname}/word-game-play?q=${(serachValue)}`)
|
188
|
+
|
189
|
+
startConfetti()
|
190
|
+
showAlertMessage("You WON! 🏆")
|
191
|
+
stopAllEventListeners()
|
192
|
+
danceTiles(tiles)
|
193
|
+
setTimeout(() => {
|
194
|
+
openPopup.click()
|
195
|
+
stopConfetti()
|
196
|
+
}, 1500);
|
197
|
+
return
|
198
|
+
}
|
199
|
+
const remainingTiles = gameBoard.querySelectorAll(":not([data-letter])")
|
200
|
+
if (remainingTiles.length === 0) {
|
201
|
+
facebookSHareLink.setAttribute("href",
|
202
|
+
`https://www.facebook.com/share.php?u=${window.location.protocol + "//" + window.location.hostname}/word-game-play?q=${(serachValue)}"e=
|
203
|
+
I guessed this wordle in ${attempt}/6 tries. Can you do better ?
|
204
|
+
Try this wordle:
|
205
|
+
${window.location.protocol + "//" + window.location.hostname}/word-game-play?q=${(serachValue)}`)
|
206
|
+
twitterSHareLink.setAttribute("href",
|
207
|
+
`https://www.twitter.com/compose/tweet?&text=I guessed this wordle in ${attempt}/6 tries.
|
208
|
+
Can you do better ? Try this wordle: ${window.location.protocol + "//" + window.location.hostname}/word-game-play?q=${(serachValue)}`)
|
209
|
+
whatsappSHareLink.setAttribute("href", `whatsapp://send?text=I guessed this wordle in ${attempt}/6 tries.
|
210
|
+
Can you do better ? Try this wordle: ${window.location.protocol + "//" + window.location.hostname}/word-game-play?q=${(serachValue)}`)
|
211
|
+
showAlertMessage("You LOST!")
|
212
|
+
setTimeout(() => {
|
213
|
+
openPopup.click()
|
214
|
+
}, 1000);
|
215
|
+
stopAllEventListeners()
|
216
|
+
}
|
217
|
+
|
218
|
+
}
|
219
|
+
const startAllEventListeners = () => {
|
220
|
+
document.addEventListener("keydown", handleKeyPress)
|
221
|
+
document.addEventListener("click", handleClick)
|
222
|
+
}
|
223
|
+
startAllEventListeners()
|
224
|
+
|
225
|
+
const stopAllEventListeners = () => {
|
226
|
+
document.removeEventListener("click", handleClick)
|
227
|
+
document.removeEventListener("keydown", handleKeyPress)
|
228
|
+
}
|
229
|
+
const showAlertMessage = (msg) => {
|
230
|
+
if (msg === "You LOST!") {
|
231
|
+
answer.innerText = "The answer was"
|
232
|
+
}
|
233
|
+
|
234
|
+
ResutlGuessWord.innerHTML = targetWord
|
235
|
+
gameResult.innerHTML = msg
|
236
|
+
errorMsg.innerHTML = msg
|
237
|
+
|
238
|
+
alertContainer.classList.add("active-alert")
|
239
|
+
setTimeout(() => {
|
240
|
+
alertContainer.classList.remove("active-alert")
|
241
|
+
}, 1000)
|
242
|
+
}
|
243
|
+
const copyToClipboard = (str) => {
|
244
|
+
try {
|
245
|
+
const el = document.createElement('textarea')
|
246
|
+
el.value = str
|
247
|
+
document.body.appendChild(el)
|
248
|
+
el.select()
|
249
|
+
document.execCommand('copy')
|
250
|
+
document.body.removeChild(el)
|
251
|
+
errorMsg.innerHTML = "Copied !"
|
252
|
+
alertContainer.classList.add("active-alert")
|
253
|
+
setTimeout(() => {
|
254
|
+
alertContainer.classList.remove("active-alert")
|
255
|
+
}, 1000)
|
256
|
+
} catch (error) {
|
257
|
+
console.log(error)
|
258
|
+
}
|
259
|
+
}
|
260
|
+
wordleGameCopyLink.addEventListener('click', () => {
|
261
|
+
copyToClipboard(`${window.location.protocol + "//" + window.location.hostname}/word-game-play?q=${(serachValue)}`)
|
262
|
+
})
|
263
|
+
wordleGameShareLink.addEventListener('click', () => {
|
264
|
+
copyToClipboard(`${window.location.protocol + "//" + window.location.hostname}/word-game-play?q=${(serachValue)}`)
|
265
|
+
})
|
266
|
+
|
267
|
+
|
268
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: word-games-theme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- manpreet-appscms
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-04-
|
11
|
+
date: 2022-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -223,8 +223,11 @@ files:
|
|
223
223
|
- assets/images/bg_elements.png
|
224
224
|
- assets/images/bg_elements.svg
|
225
225
|
- assets/images/board-game.png
|
226
|
+
- assets/images/close.png
|
227
|
+
- assets/images/copy.svg
|
226
228
|
- assets/images/facebook-square.svg
|
227
229
|
- assets/images/facebook.svg
|
230
|
+
- assets/images/facebooks.svg
|
228
231
|
- assets/images/footer.png
|
229
232
|
- assets/images/footer2-bg.webp
|
230
233
|
- assets/images/header.svg
|
@@ -260,7 +263,9 @@ files:
|
|
260
263
|
- assets/images/twitter-square.svg
|
261
264
|
- assets/images/twitter.svg
|
262
265
|
- assets/images/twitter2.svg
|
266
|
+
- assets/images/twitters.svg
|
263
267
|
- assets/images/uo.svg
|
268
|
+
- assets/images/whatsapp.svg
|
264
269
|
- assets/images/window-close.png
|
265
270
|
- assets/images/window-close.svg
|
266
271
|
- assets/images/word-games-logo.svg
|
@@ -275,6 +280,7 @@ files:
|
|
275
280
|
- assets/js/advancedFilter.js
|
276
281
|
- assets/js/advancedFilter2.js
|
277
282
|
- assets/js/advancedFilter3.js
|
283
|
+
- assets/js/confetti.js
|
278
284
|
- assets/js/createWordle.js
|
279
285
|
- assets/js/game.js
|
280
286
|
- assets/js/leftNav.js
|