word-games-theme 3.0.9 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3eee59c07c0a1dba072f0ee692f5cdc66bdb452fa8ffeb756ae6e15db54c9ae7
4
- data.tar.gz: b862abc3457bd260e754621cd1b5dfa588c188ea5728724d9a0a4918fbd8b3d9
3
+ metadata.gz: 4007887a543ee3ff848e8320cfabbeb77f07ae060662d8a459d5ea409536c4e3
4
+ data.tar.gz: '07139219a6cbfd5e45a831fc0f2e455f3fc856889d22ee71bad2b740dc099c4f'
5
5
  SHA512:
6
- metadata.gz: b680d5b3aedca86e180bb6b0b950a1c017a9a55968c5bfd917f0e16bd15b9bcf052b95a3303c4cba48db5d716edad0a321adc0c0101172f3bbd3591d08c67043
7
- data.tar.gz: b3de6fc27da1c27618ef4e3ffdcf352747a00c7349c49090a1a888d508316226d9618abb3645738c92440d954c04891be1b31f0dc114f043ef10912a8e70a622
6
+ metadata.gz: fbc78b1930b1d325413704082071d91a58b9fc0d79811e296b7cdafb3ed90045c664fabe9c39c21c2d02aa79dc7ff788df5516ed6bfdb8fc72c9aacffc0992c2
7
+ data.tar.gz: e8fac161e3643429d3764c22380992b5022f7e5030b00baa9d0d9b5b93f363cff2d08425aad0f85995ef7d7005e8e89de39e5e290fe606568ff7372ec525adeb
@@ -0,0 +1,113 @@
1
+ self.onmessage = async (event) => {
2
+ if (event.data.type === "api") {
3
+ const { endpoint, greenLetters, yellowLetters, greyLetters, greenWithIndex } = event.data
4
+ let response = await fetch(`${endpoint}`, {
5
+ method: 'POST',
6
+ body: JSON.stringify({
7
+ greenLetters: greenLetters,
8
+ yellowLetters: yellowLetters,
9
+ greyLetters: greyLetters,
10
+ greenWithIndex: greenWithIndex,
11
+ }),
12
+ })
13
+ let data = await response.json();
14
+ data = data.slice(0, 1000)
15
+ let newWordsLength = 0
16
+ let ok = true
17
+ if (data.length === 0) {
18
+ self.postMessage("error");
19
+ } else {
20
+ newWordsLength = ''
21
+ newWordsLength += data.length
22
+ let result = data.map((item) => {
23
+ if (item.length === 1) {
24
+ ok = false
25
+ newWordsLength = newWordsLength - 1
26
+ } else {
27
+ let ScrabbleLetterScore = ScrabbleScore()
28
+ sum = 0
29
+ item = item.toLowerCase()
30
+ for (let i = 0; i < item.length; i++) {
31
+ sum += ScrabbleLetterScore[item[i]] || 0 // for unknown characters
32
+ }
33
+ return `
34
+ <a class="anchor__style" title="Lookup ${item} in Dictionary" target="_blank" href="/word-meaning?search=${item.toLowerCase()}">
35
+ <li>
36
+ ${item.toLowerCase()}
37
+ <span class="points" value="${sum}" style="position:relative; top:4px; font-size:12px"> ${sum}</span>
38
+ </li>
39
+ </a>
40
+ `
41
+ }
42
+ })
43
+ self.postMessage({ result, newWordsLength, ok });
44
+ }
45
+ }
46
+
47
+ };
48
+
49
+ const ScrabbleScore = (dictonary) => {
50
+ let twl06_sowpods = {
51
+ a: 1,
52
+ e: 1,
53
+ i: 1,
54
+ o: 1,
55
+ u: 1,
56
+ l: 1,
57
+ n: 1,
58
+ r: 1,
59
+ s: 1,
60
+ t: 1,
61
+ d: 2,
62
+ g: 2,
63
+ b: 3,
64
+ c: 3,
65
+ m: 3,
66
+ p: 3,
67
+ f: 4,
68
+ h: 4,
69
+ v: 4,
70
+ w: 4,
71
+ y: 4,
72
+ k: 5,
73
+ j: 8,
74
+ x: 8,
75
+ q: 10,
76
+ z: 10,
77
+ };
78
+ let wwfScore = {
79
+ a: 1,
80
+ b: 4,
81
+ c: 4,
82
+ d: 2,
83
+ e: 1,
84
+ f: 4,
85
+ g: 3,
86
+ h: 3,
87
+ i: 1,
88
+ j: 10,
89
+ k: 5,
90
+ l: 2,
91
+ m: 4,
92
+ n: 2,
93
+ o: 1,
94
+ p: 4,
95
+ q: 10,
96
+ r: 1,
97
+ s: 1,
98
+ t: 1,
99
+ u: 2,
100
+ v: 5,
101
+ w: 4,
102
+ x: 8,
103
+ y: 3,
104
+ z: 10,
105
+ };
106
+
107
+ if (dictonary === "wwf") {
108
+ return wwfScore;
109
+ } else {
110
+ return twl06_sowpods;
111
+ }
112
+ };
113
+
@@ -40,7 +40,6 @@ for (let e = 0; e < greyLetters.length; e++) {
40
40
  }
41
41
  })
42
42
  }
43
-
44
43
  let wordleSolverData = document.getElementById('wordleSolverData')
45
44
  greenLetters[0].focus()
46
45
  let wordleWordCount = document.querySelector('#wordleWordCount')
@@ -61,7 +60,6 @@ let authorsLists = document.querySelector(".authors-list")
61
60
 
62
61
  function handleSubmit(e) {
63
62
  e.preventDefault()
64
-
65
63
  if (featureContainer) {
66
64
  featureContainer.remove()
67
65
  }
@@ -78,14 +76,10 @@ function handleSubmit(e) {
78
76
  authorsLists.remove()
79
77
  }
80
78
 
81
-
82
-
83
79
  document.querySelector(".refineSerach").style.display = "block"
84
80
  const scrollingElement = (document.scrollingElement || document.body);
85
81
  scrollingElement.scroll({ top: 515, behavior: 'smooth' });
86
-
87
82
  let greenWithIndex = getIndexs('.greenWithIndex')
88
-
89
83
  let corretLettterArray = []
90
84
  let getGreenLetters = []
91
85
  Array.from(greenLetters).map((item) => {
@@ -203,92 +197,67 @@ if (params.size > 0) {
203
197
  }
204
198
 
205
199
  }
200
+
206
201
  form.addEventListener('submit', handleSubmit)
207
202
 
203
+ const worker = new Worker('/assets/js/wordleSolver-worker.js');
208
204
  const wordleSolver = async (value, value2, value3, greenWithIndex) => {
209
205
  try {
210
- let result = ''
211
206
  document.querySelector('#updateTxt').innerHTML = ''
212
207
  spinner.classList.add('spinner-border')
213
208
  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
209
 
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
210
+ worker.postMessage({
211
+ type: "api",
212
+ endpoint: `/.netlify/functions/wordleSolver/wordleSolver`,
213
+ greenLetters: value,
214
+ yellowLetters: value2,
215
+ greyLetters: value3,
216
+ greenWithIndex: greenWithIndex,
217
+ });
218
+ worker.onmessage = (event) => {
219
+ document.querySelector('#updateTxt').innerHTML = 'Solve'
220
+ spinner.classList.remove('spinner-border')
221
+
222
+ if (event.data == "error") {
223
+ newWordsLength = ''
224
+ wordleSolverData.innerHTML = ''
225
+ wordleSolvererrorMsg.classList.add('alert-danger')
226
+ wordleSolvererrorMsg.innerHTML = 'Sorry!! No words found'
227
+ wordleWordCount.style.display = 'none'
228
+ } else {
229
+ wordleWordCount.style.display = 'block'
230
+ wordleSolverData.innerHTML = ''
231
+ wordleSolvererrorMsg.classList.remove('alert-danger')
232
+ wordleSolvererrorMsg.innerHTML = ''
233
+
234
+ if (event.data.ok) {
235
+ wordleSolverData.innerHTML += `
236
+ <div class="allfiveletterswords wordlistContainer">
237
+ <div class="wordListHeading">
238
+ <h3 class="lead">Solve wordle with these words</h3>
239
+ </div>
240
+ <div class="wordList">
241
+ <ul class="ul list-unstyled">
242
+ ${event.data.result.join('')}
243
+ </ul>
244
+ </div>
245
+ </div>`
246
+ }
247
+
248
+ if (event.data.newWordsLength === 0) {
249
+ wordleSolvererrorMsg.classList.add('alert-danger')
250
+ wordleSolvererrorMsg.innerHTML = 'Sorry!! No words found'
247
251
  } 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
- `
252
+ wordleWordCount.innerHTML = `<strong>Found <span style="color:#20a815">${event.data.newWordsLength}</span> matching words for wordle</strong>`
263
253
  }
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
254
  }
279
255
  }
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
256
  } catch (error) {
289
257
  console.log(error)
290
258
  }
291
259
  }
260
+
292
261
  const getLetters = (object) => {
293
262
  let letters = []
294
263
  if (typeof object === 'string') {
@@ -320,34 +289,3 @@ document.querySelector(".refineSerach").addEventListener("click", () => {
320
289
  const scrollingElement = (document.scrollingElement || document.body);
321
290
  scrollingElement.scroll({ top: 0, behavior: 'smooth' });
322
291
  })
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
- }
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: 3.0.9
4
+ version: 3.1.0
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-07-31 00:00:00.000000000 Z
11
+ date: 2024-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -408,6 +408,7 @@ files:
408
408
  - assets/js/wordgames-result.js
409
409
  - assets/js/wordgames-xletter.js
410
410
  - assets/js/wordgames-xyz.js
411
+ - assets/js/wordleSolver-worker.js
411
412
  - assets/js/wordleSolver.js
412
413
  - assets/js/wordleSolverResult.js
413
414
  - assets/js/words-in-certain-positions-worker.js