word-games-theme 2.9.1 → 2.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/assets/js/wordleSolver.js +290 -11
- data/assets/js/wordleSolverResult.js +0 -23
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4d43ae91c1161c53a4feda7aa88e9913276f3229eeb5c0298ec6ab40f8f980b
|
4
|
+
data.tar.gz: 88ae5ae8fdb7cedf770f5eb22b092fd8c878232155caef6455a3bb8e7486d184
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c75ce8ba4304ae6754fb9cfe5ab7b78f8ac4d537bafa1b446f50abb8bab6e96d115eff73538d7d6b943e817fa7b70974ff70610bf0f624000bab5af09f4f16d4
|
7
|
+
data.tar.gz: 8a785b845d0dfb2575994637b71e8dab6ac551bac767ac737638e568cd12887e3affa10fd1552ce6573473c0cb30f4f648da5fd121a1b4a549d5015e0c132b4b
|
data/assets/js/wordleSolver.js
CHANGED
@@ -41,34 +41,313 @@ for (let e = 0; e < greyLetters.length; e++) {
|
|
41
41
|
})
|
42
42
|
}
|
43
43
|
|
44
|
+
let wordleSolverData = document.getElementById('wordleSolverData')
|
45
|
+
greenLetters[0].focus()
|
46
|
+
let wordleWordCount = document.querySelector('#wordleWordCount')
|
47
|
+
let wordleSolvererrorMsg = document.querySelector('#wordleSolvererrorMsg')
|
48
|
+
let wordlesolver_submit = document.getElementById('wordlesolver_submit')
|
49
|
+
let newWordsLength = 0
|
50
|
+
|
51
|
+
let errMessage = document.querySelector('.errMessage')
|
52
|
+
let wrapper_div = document.querySelector('.wrapper_div')
|
53
|
+
const params = new URLSearchParams(window.location.search)
|
54
|
+
let spinner = document.querySelector('.spinner')
|
55
|
+
|
56
|
+
let featureContainer = document.querySelector("#featureContainer")
|
57
|
+
let howContainer = document.querySelector("#howContainer")
|
58
|
+
let faqsContainer = document.querySelector("#faqsContainer")
|
59
|
+
let infographicsContainer = document.querySelector("#infographicsContainer")
|
60
|
+
let authorsLists = document.querySelector(".authors-list")
|
61
|
+
|
44
62
|
function handleSubmit(e) {
|
45
63
|
e.preventDefault()
|
64
|
+
|
65
|
+
if (featureContainer) {
|
66
|
+
featureContainer.remove()
|
67
|
+
}
|
68
|
+
if (howContainer) {
|
69
|
+
howContainer.remove()
|
70
|
+
}
|
71
|
+
if (faqsContainer) {
|
72
|
+
faqsContainer.remove()
|
73
|
+
}
|
74
|
+
if (infographicsContainer) {
|
75
|
+
infographicsContainer.remove()
|
76
|
+
}
|
77
|
+
if (authorsLists) {
|
78
|
+
authorsLists.remove()
|
79
|
+
}
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
document.querySelector(".refineSerach").style.display = "block"
|
84
|
+
const scrollingElement = (document.scrollingElement || document.body);
|
85
|
+
scrollingElement.scroll({ top: 515, behavior: 'smooth' });
|
86
|
+
|
87
|
+
let greenWithIndex = getIndexs('.greenWithIndex')
|
88
|
+
|
46
89
|
let corretLettterArray = []
|
90
|
+
let getGreenLetters = []
|
47
91
|
Array.from(greenLetters).map((item) => {
|
48
92
|
if (!item.value) {
|
49
|
-
corretLettterArray.push(item.value.replace("", "_"))
|
93
|
+
corretLettterArray.push(item.value.replace("", "_").toLowerCase())
|
50
94
|
} else {
|
51
|
-
|
95
|
+
getGreenLetters.push(item.value.toLowerCase())
|
96
|
+
corretLettterArray.push(item.value.toLowerCase())
|
52
97
|
}
|
53
98
|
})
|
54
|
-
let
|
99
|
+
let includesLettersArray = []
|
100
|
+
let getYellowLetters = []
|
55
101
|
Array.from(yellowLetters).map((item) => {
|
56
102
|
if (!item.value) {
|
57
|
-
|
103
|
+
includesLettersArray.push(item.value.replace("", "_").toLowerCase())
|
58
104
|
} else {
|
59
|
-
|
105
|
+
getYellowLetters.push(item.value.toLowerCase())
|
106
|
+
includesLettersArray.push(item.value.toLowerCase())
|
60
107
|
}
|
61
108
|
})
|
62
|
-
let
|
109
|
+
let excludesLettersArray = []
|
110
|
+
let getGreyLetters = []
|
63
111
|
Array.from(greyLetters).map((item) => {
|
64
112
|
if (!item.value) {
|
65
|
-
|
113
|
+
excludesLettersArray.push(item.value.replace("", "_").toLowerCase())
|
66
114
|
} else {
|
67
|
-
|
115
|
+
getGreyLetters.push(item.value.toLowerCase())
|
116
|
+
excludesLettersArray.push(item.value.toLowerCase())
|
68
117
|
}
|
69
118
|
})
|
119
|
+
if (history.pushState) {
|
120
|
+
var newurl = window.location.protocol + "//" + window.location.host +
|
121
|
+
window.location.pathname + '?' + "correct" + "=" + corretLettterArray.join("")
|
122
|
+
+ '&includes' + '=' + includesLettersArray.join("") + "&excludes" + '=' + excludesLettersArray.join("")
|
123
|
+
window.history.pushState({ path: newurl }, '', newurl);
|
124
|
+
|
125
|
+
const params = new URLSearchParams(window.location.search)
|
126
|
+
let correct = params.get('correct')
|
127
|
+
let includes = params.get('includes')
|
128
|
+
let excludes = params.get('excludes')
|
129
|
+
|
130
|
+
gtag('event', 'page_view', {
|
131
|
+
page_location: window.location.pathname + location.search,
|
132
|
+
})
|
133
|
+
}
|
134
|
+
wordleSolver(getGreenLetters, getYellowLetters, getGreyLetters, greenWithIndex)
|
135
|
+
}
|
136
|
+
if (params.size > 0) {
|
137
|
+
window.onload = function (e) {
|
138
|
+
handleSubmit(e);
|
139
|
+
}
|
140
|
+
let correct = params.get('correct').toLowerCase()
|
141
|
+
let includes = params.get('includes').toLowerCase()
|
142
|
+
let excludes = params.get('excludes').toLowerCase()
|
143
|
+
for (let g = 0; g < greenLetters.length; g++) {
|
144
|
+
const elem = greenLetters[g]
|
145
|
+
let values = correct.split("")
|
146
|
+
values.map((item, index) => {
|
147
|
+
if (Number(elem.dataset.id) === index) {
|
148
|
+
elem.value = item.replace("_", "")
|
149
|
+
if (elem.value != "") {
|
150
|
+
elem.classList.add('ws-fcs')
|
151
|
+
}
|
152
|
+
}
|
153
|
+
})
|
154
|
+
elem.addEventListener('input', (e) => {
|
155
|
+
e.target.value = e.target.value.replace(/[^a-zA-Z? ]/g, "")
|
156
|
+
if (e.target.value) {
|
157
|
+
e.target.classList.add('ws-fcs')
|
158
|
+
} else {
|
159
|
+
e.target.classList.remove('ws-fcs')
|
160
|
+
}
|
161
|
+
})
|
162
|
+
}
|
163
|
+
for (let y = 0; y < yellowLetters.length; y++) {
|
164
|
+
const elem = yellowLetters[y]
|
165
|
+
let values = includes.split("")
|
166
|
+
values.map((item, index) => {
|
167
|
+
if (Number(elem.dataset.id) === index) {
|
168
|
+
elem.value = item.replace("_", "")
|
169
|
+
if (elem.value != "") {
|
170
|
+
elem.classList.add('ws-fcs2')
|
171
|
+
}
|
172
|
+
}
|
173
|
+
})
|
174
|
+
elem.addEventListener('input', (e) => {
|
175
|
+
e.target.value = e.target.value.replace(/[^a-zA-Z? ]/g, "")
|
176
|
+
if (e.target.value) {
|
177
|
+
e.target.classList.add('ws-fcs2')
|
178
|
+
} else {
|
179
|
+
e.target.classList.remove('ws-fcs2')
|
180
|
+
}
|
181
|
+
})
|
182
|
+
}
|
183
|
+
for (let e = 0; e < greyLetters.length; e++) {
|
184
|
+
const elem = greyLetters[e]
|
185
|
+
let values = excludes.split("")
|
186
|
+
values.map((item, index) => {
|
187
|
+
if (Number(elem.dataset.id) === index) {
|
188
|
+
elem.value = item.replace("_", "")
|
189
|
+
if (elem.value != "") {
|
190
|
+
elem.classList.add('ws-fcs3')
|
191
|
+
}
|
192
|
+
}
|
193
|
+
})
|
194
|
+
|
195
|
+
elem.addEventListener('input', (e) => {
|
196
|
+
e.target.value = e.target.value.replace(/[^a-zA-Z? ]/g, "")
|
197
|
+
if (e.target.value) {
|
198
|
+
e.target.classList.add('ws-fcs3')
|
199
|
+
} else {
|
200
|
+
e.target.classList.remove('ws-fcs3')
|
201
|
+
}
|
202
|
+
})
|
203
|
+
}
|
70
204
|
|
71
|
-
window.location = `/${permalink}/result` + '?' + "correct" + "=" + corretLettterArray.join("")
|
72
|
-
+ '&includes' + '=' + includesLettterArray.join("") + "&excludes" + '=' + exculdesLettterArray.join("")
|
73
205
|
}
|
74
|
-
form.addEventListener('submit', handleSubmit)
|
206
|
+
form.addEventListener('submit', handleSubmit)
|
207
|
+
|
208
|
+
const wordleSolver = async (value, value2, value3, greenWithIndex) => {
|
209
|
+
try {
|
210
|
+
let result = ''
|
211
|
+
document.querySelector('#updateTxt').innerHTML = ''
|
212
|
+
spinner.classList.add('spinner-border')
|
213
|
+
wordleWordCount.innerHTML = 'Searching for best possible letters...'
|
214
|
+
let response = await fetch('/.netlify/functions/wordleSolver', {
|
215
|
+
method: 'POST',
|
216
|
+
body: JSON.stringify({
|
217
|
+
greenLetters: value,
|
218
|
+
yellowLetters: value2,
|
219
|
+
greyLetters: value3,
|
220
|
+
greenWithIndex: greenWithIndex,
|
221
|
+
}),
|
222
|
+
})
|
223
|
+
let data = await response.json()
|
224
|
+
data = data.slice(0, 1000)
|
225
|
+
document.querySelector('#updateTxt').innerHTML = 'Solve'
|
226
|
+
spinner.classList.remove('spinner-border')
|
227
|
+
|
228
|
+
let ok = true
|
229
|
+
if (data.length === 0) {
|
230
|
+
newWordsLength = ''
|
231
|
+
wordleSolverData.innerHTML = ''
|
232
|
+
wordleSolvererrorMsg.classList.add('alert-danger')
|
233
|
+
wordleSolvererrorMsg.innerHTML = 'Sorry!! No words found'
|
234
|
+
wordleWordCount.style.display = 'none'
|
235
|
+
// console.log(wordleWordCount)
|
236
|
+
} else {
|
237
|
+
wordleWordCount.style.display = 'block'
|
238
|
+
wordleSolverData.innerHTML = ''
|
239
|
+
wordleSolvererrorMsg.classList.remove('alert-danger')
|
240
|
+
wordleSolvererrorMsg.innerHTML = ''
|
241
|
+
newWordsLength = ''
|
242
|
+
newWordsLength += data.length
|
243
|
+
result = data.map((item) => {
|
244
|
+
if (item.length === 1) {
|
245
|
+
ok = false
|
246
|
+
newWordsLength = newWordsLength - 1
|
247
|
+
} else {
|
248
|
+
// console.log(newWordsLength);
|
249
|
+
let ScrabbleLetterScore = ScrabbleScore()
|
250
|
+
sum = 0
|
251
|
+
item = item.toLowerCase()
|
252
|
+
for (let i = 0; i < item.length; i++) {
|
253
|
+
sum += ScrabbleLetterScore[item[i]] || 0 // for unknown characters
|
254
|
+
}
|
255
|
+
return `
|
256
|
+
<a class="anchor__style" title="Lookup ${item} in Dictionary" target="_blank" href="/word-meaning?search=${item.toLowerCase()}">
|
257
|
+
<li>
|
258
|
+
${item.toLowerCase()}
|
259
|
+
<span class="points" value="${sum}" style="position:relative; top:4px; font-size:12px"> ${sum}</span>
|
260
|
+
</li>
|
261
|
+
</a>
|
262
|
+
`
|
263
|
+
}
|
264
|
+
})
|
265
|
+
if (ok) {
|
266
|
+
wordleSolverData.innerHTML += `
|
267
|
+
<div class="allfiveletterswords wordlistContainer">
|
268
|
+
<div class="wordListHeading">
|
269
|
+
<h3 class="lead">Solve wordle with these words</h3>
|
270
|
+
</div>
|
271
|
+
<div class="wordList">
|
272
|
+
<ul class="ul list-unstyled">
|
273
|
+
${result.join('')}
|
274
|
+
</ul>
|
275
|
+
</div>
|
276
|
+
</div>
|
277
|
+
`
|
278
|
+
}
|
279
|
+
}
|
280
|
+
|
281
|
+
if (newWordsLength === 0) {
|
282
|
+
console.log(true)
|
283
|
+
wordleSolvererrorMsg.classList.add('alert-danger')
|
284
|
+
wordleSolvererrorMsg.innerHTML = 'Sorry!! No words found'
|
285
|
+
} else {
|
286
|
+
wordleWordCount.innerHTML = `<strong>Found <span style="color:#20a815">${newWordsLength}</span> matching words for wordle</strong>`
|
287
|
+
}
|
288
|
+
} catch (error) {
|
289
|
+
console.log(error)
|
290
|
+
}
|
291
|
+
}
|
292
|
+
const getLetters = (object) => {
|
293
|
+
let letters = []
|
294
|
+
if (typeof object === 'string') {
|
295
|
+
object = document.querySelectorAll(object)
|
296
|
+
}
|
297
|
+
for (let item of object) {
|
298
|
+
if (item.value.trim().length === 1) {
|
299
|
+
letters.push(item.value.toLowerCase())
|
300
|
+
}
|
301
|
+
}
|
302
|
+
return letters
|
303
|
+
}
|
304
|
+
const getIndexs = (object) => {
|
305
|
+
let index = []
|
306
|
+
if (typeof object === 'string') {
|
307
|
+
object = document.querySelectorAll(object)
|
308
|
+
}
|
309
|
+
for (let item of object) {
|
310
|
+
if (item.value.trim().length === 1) {
|
311
|
+
index.push({
|
312
|
+
value: item.value.toLowerCase(),
|
313
|
+
index: item.dataset.id,
|
314
|
+
})
|
315
|
+
}
|
316
|
+
}
|
317
|
+
return index
|
318
|
+
}
|
319
|
+
document.querySelector(".refineSerach").addEventListener("click", () => {
|
320
|
+
const scrollingElement = (document.scrollingElement || document.body);
|
321
|
+
scrollingElement.scroll({ top: 0, behavior: 'smooth' });
|
322
|
+
})
|
323
|
+
const ScrabbleScore = () => {
|
324
|
+
let twl06_sowpods = {
|
325
|
+
a: 1,
|
326
|
+
e: 1,
|
327
|
+
i: 1,
|
328
|
+
o: 1,
|
329
|
+
u: 1,
|
330
|
+
l: 1,
|
331
|
+
n: 1,
|
332
|
+
r: 1,
|
333
|
+
s: 1,
|
334
|
+
t: 1,
|
335
|
+
d: 2,
|
336
|
+
g: 2,
|
337
|
+
b: 3,
|
338
|
+
c: 3,
|
339
|
+
m: 3,
|
340
|
+
p: 3,
|
341
|
+
f: 4,
|
342
|
+
h: 4,
|
343
|
+
v: 4,
|
344
|
+
w: 4,
|
345
|
+
y: 4,
|
346
|
+
k: 5,
|
347
|
+
j: 8,
|
348
|
+
x: 8,
|
349
|
+
q: 10,
|
350
|
+
z: 10,
|
351
|
+
}
|
352
|
+
return twl06_sowpods
|
353
|
+
}
|
@@ -19,29 +19,6 @@ let includes = params.get('includes').toLowerCase()
|
|
19
19
|
let excludes = params.get('excludes').toLowerCase()
|
20
20
|
|
21
21
|
|
22
|
-
// let addMore = document.querySelector('#addMore')
|
23
|
-
|
24
|
-
// addMore.addEventListener('click', (e) => {
|
25
|
-
// e.preventDefault()
|
26
|
-
// let div = document.createElement('div')
|
27
|
-
// div.classList.add('d-flex')
|
28
|
-
// div.classList.add('mt-2')
|
29
|
-
|
30
|
-
// for (let i = 20; i <= 24; i++) {
|
31
|
-
// let input = document.createElement('input')
|
32
|
-
// input.type = 'text'
|
33
|
-
// input.setAttribute('maxlength', '1')
|
34
|
-
// input.setAttribute('autocomplete', 'off')
|
35
|
-
// if (i <= 24) {
|
36
|
-
// input.setAttribute('tabIndex', i)
|
37
|
-
// }
|
38
|
-
// let classes = ['wordleSolver-field', 'greyLetters', 'form-control', 'px-5']
|
39
|
-
// input.classList.add(...classes)
|
40
|
-
// input.id = 'greyLetters'
|
41
|
-
// div.append(input)
|
42
|
-
// wrapper_div.append(div)
|
43
|
-
// }
|
44
|
-
// })
|
45
22
|
|
46
23
|
let spinner = document.querySelector('.spinner')
|
47
24
|
const wordleSolver = async (value, value2, value3, greenWithIndex) => {
|
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: 2.9.
|
4
|
+
version: 2.9.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: 2024-06-
|
11
|
+
date: 2024-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|