word-games-theme 1.1.9 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/_data/wordgames/en/root.json +2 -0
  3. data/_data/wordgames/en/word-game-generator-online.json +58 -0
  4. data/_data/wordgames/en/word-game-play.json +21 -0
  5. data/_data/wordgames/fr/four_letter_word_finder.json +1 -0
  6. data/_data/wordgames/hi/four_letter_word_finder.json +1 -0
  7. data/_includes/adBlocker/adBlocker.html +7 -7
  8. data/_includes/autogenerated/content.html +1 -1
  9. data/_includes/footer/index.html +2 -2
  10. data/_includes/footer/unqFooter.html +4 -4
  11. data/_includes/google-analytics.html +0 -31
  12. data/_includes/head/index.html +3 -3
  13. data/_includes/script.html +1 -1
  14. data/_includes/section/commonPage.html +3 -2
  15. data/_includes/section/home.html +1 -1
  16. data/_includes/section/home2.html +3 -2
  17. data/_includes/word-game/word-game-generator-online.html +41 -0
  18. data/_includes/word-game/word-game-play.html +191 -0
  19. data/_includes/wordfinderstrategy/content.html +1 -1
  20. data/_includes/wordle-solver/wordle-solver.html +12 -1
  21. data/_includes/xyzpages/xyz.html +2 -2
  22. data/_layouts/page.html +2 -2
  23. data/_layouts/tools.html +1 -1
  24. data/assets/css/game.css +406 -0
  25. data/assets/css/wordleSolver.css +11 -0
  26. data/assets/images/close.png +0 -0
  27. data/assets/images/copy.svg +1 -0
  28. data/assets/images/facebooks.svg +1 -0
  29. data/assets/images/twitters.svg +1 -0
  30. data/assets/images/whatsapp.svg +1 -0
  31. data/assets/images/wordle.png +0 -0
  32. data/assets/js/X-letter-test.js +3 -1
  33. data/assets/js/confetti.js +130 -0
  34. data/assets/js/createWordle.js +71 -0
  35. data/assets/js/game.js +268 -0
  36. data/assets/js/wordScrabble-test.js +3 -5
  37. data/assets/js/words-starting-with.js +3 -1
  38. metadata +16 -2
@@ -0,0 +1,71 @@
1
+ let customWord = document.querySelector(".custom-word")
2
+ let generateLinkButton = document.querySelector(".generate-word-game-link")
3
+ let wordleGameLink = document.querySelector(".wordle-game-link")
4
+ let copy_btn = document.querySelector(".copy-btn")
5
+
6
+ let form = document.querySelector('#create-wordle-form')
7
+ let openPopup = document.querySelector(".open-popup")
8
+
9
+ const alertContainer = document.querySelector(".alert-container")
10
+ let errorMsg = document.querySelector("#errorMsg")
11
+
12
+ customWord.focus()
13
+
14
+
15
+ let dictionary
16
+ async function getData() {
17
+ const response = await fetch("/dictionary.json")
18
+ const data = await response.json()
19
+ dictionary = data
20
+ }
21
+ getData()
22
+
23
+
24
+
25
+ const createWordle = (e) => {
26
+ e.preventDefault();
27
+
28
+ if (customWord.value.length < 5) {
29
+ errorMsg.innerHTML = "Not enough letters"
30
+ alertContainer.classList.add("active-alert")
31
+ setTimeout(() => {
32
+ alertContainer.classList.remove("active-alert")
33
+ }, 1000)
34
+ }
35
+ if (customWord.value.length === 5 && !dictionary.includes(customWord.value.toLocaleLowerCase())) {
36
+ errorMsg.innerHTML = "Not a valid word"
37
+ alertContainer.classList.add("active-alert")
38
+ setTimeout(() => {
39
+ alertContainer.classList.remove("active-alert")
40
+ }, 1000)
41
+ } else {
42
+ if (customWord.value.length === 5) {
43
+ openPopup.click()
44
+ copy_btn.innerHTML = "Copy"
45
+ copy_btn.style.background = "dodgerblue"
46
+ wordleGameLink.setAttribute("href", `/word-game-play?q=${btoa(customWord.value.toLocaleLowerCase())}`)
47
+ wordleGameLink.innerHTML = `${window.location.protocol + "//" + window.location.hostname}/word-game-play?q=${btoa(customWord.value.toLocaleLowerCase())}`
48
+ }
49
+ }
50
+ }
51
+ form.addEventListener('submit', createWordle);
52
+
53
+
54
+ const copyToClipboard = (str) => {
55
+ try {
56
+ const el = document.createElement('textarea')
57
+ el.value = str
58
+ document.body.appendChild(el)
59
+ el.select()
60
+ document.execCommand('copy')
61
+ document.body.removeChild(el)
62
+ copy_btn.innerHTML = "Copied !"
63
+ copy_btn.style.background = "#444"
64
+ // copy_btn.setAttribute('data-tooltip', 'Copied !')
65
+ } catch (error) {
66
+ console.log(error)
67
+ }
68
+ }
69
+ copy_btn.addEventListener('click', () => {
70
+ copyToClipboard(wordleGameLink.innerHTML)
71
+ })
data/assets/js/game.js ADDED
@@ -0,0 +1,268 @@
1
+ const params = new URLSearchParams(window.location.search)
2
+ let gameBoard = document.querySelector(".game-board")
3
+ let serachValue = params.get('q')
4
+ let decodeBase64 = atob(serachValue)
5
+ let word = decodeBase64
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
109
+ }
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)
124
+ }
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)}&quote=
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)}&quote=
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
+
@@ -172,8 +172,9 @@ if (lengthValue === '1') {
172
172
  lengthValue = params.get('length')
173
173
  dictonary = params.get('dictionary')
174
174
 
175
- // console.log('/result' + location.search)
176
- ga('send', 'pageview', window.location.pathname + location.search)
175
+ gtag('event', 'page_view', {
176
+ page_location: window.location.pathname + location.search,
177
+ })
177
178
  }
178
179
  getData(txtBox.value.toLowerCase())
179
180
  addFilterCount()
@@ -184,9 +185,6 @@ if (lengthValue === '1') {
184
185
  selectedDictionary.addEventListener("change", ((e) => {
185
186
  logSubmit(e)
186
187
  }))
187
-
188
-
189
-
190
188
  applyBtn.addEventListener('submit', logSubmit)
191
189
  form.addEventListener('submit', logSubmit);
192
190
  }
@@ -121,7 +121,9 @@ if (lengthValue === '1') {
121
121
  lengthValue = params.get('length')
122
122
  dictonary = params.get('dictionary')
123
123
 
124
- ga('send', 'pageview', window.location.pathname + location.search)
124
+ gtag('event', 'page_view', {
125
+ page_location: window.location.pathname + location.search,
126
+ })
125
127
  }
126
128
  getData(txtBox.value.toLowerCase())
127
129
  addFilterCount()
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.1.9
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-12 00:00:00.000000000 Z
11
+ date: 2022-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -105,6 +105,8 @@ files:
105
105
  - _data/wordgames/en/two_letter_word_finder.json
106
106
  - _data/wordgames/en/unscramble_letters_to_make_words.json
107
107
  - _data/wordgames/en/unscramble_words_and_jumble_solver.json
108
+ - _data/wordgames/en/word-game-generator-online.json
109
+ - _data/wordgames/en/word-game-play.json
108
110
  - _data/wordgames/en/word-meaning.json
109
111
  - _data/wordgames/en/words_with_friends_word_finder.json
110
112
  - _data/wordgames/es/four_letter_word_finder.json
@@ -171,6 +173,8 @@ files:
171
173
  - _includes/section/xyzGroup.html
172
174
  - _includes/seo.html
173
175
  - _includes/share/socialshare.html
176
+ - _includes/word-game/word-game-generator-online.html
177
+ - _includes/word-game/word-game-play.html
174
178
  - _includes/wordfinderstrategy/content.html
175
179
  - _includes/wordle-solver/wordle-solver.html
176
180
  - _includes/xyzpages/xyz.html
@@ -200,6 +204,7 @@ files:
200
204
  - assets/css/content.css
201
205
  - assets/css/feature.css
202
206
  - assets/css/footer.css
207
+ - assets/css/game.css
203
208
  - assets/css/home.css
204
209
  - assets/css/news.css
205
210
  - assets/css/style.css
@@ -218,8 +223,11 @@ files:
218
223
  - assets/images/bg_elements.png
219
224
  - assets/images/bg_elements.svg
220
225
  - assets/images/board-game.png
226
+ - assets/images/close.png
227
+ - assets/images/copy.svg
221
228
  - assets/images/facebook-square.svg
222
229
  - assets/images/facebook.svg
230
+ - assets/images/facebooks.svg
223
231
  - assets/images/footer.png
224
232
  - assets/images/footer2-bg.webp
225
233
  - assets/images/header.svg
@@ -255,11 +263,14 @@ files:
255
263
  - assets/images/twitter-square.svg
256
264
  - assets/images/twitter.svg
257
265
  - assets/images/twitter2.svg
266
+ - assets/images/twitters.svg
258
267
  - assets/images/uo.svg
268
+ - assets/images/whatsapp.svg
259
269
  - assets/images/window-close.png
260
270
  - assets/images/window-close.svg
261
271
  - assets/images/word-games-logo.svg
262
272
  - assets/images/word-games-logo.webp
273
+ - assets/images/wordle.png
263
274
  - assets/images/wordswithletters-logo.png
264
275
  - assets/images/yellow_bg.png
265
276
  - assets/js/TopScroll.js
@@ -269,6 +280,9 @@ files:
269
280
  - assets/js/advancedFilter.js
270
281
  - assets/js/advancedFilter2.js
271
282
  - assets/js/advancedFilter3.js
283
+ - assets/js/confetti.js
284
+ - assets/js/createWordle.js
285
+ - assets/js/game.js
272
286
  - assets/js/leftNav.js
273
287
  - assets/js/other-lang-wordScrabble.js
274
288
  - assets/js/scrabbleDictonary.js