word-games-theme 3.0.9 → 3.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,6 +10,7 @@ self.onmessage = async (event) => {
10
10
  const data = await response.json();
11
11
  self.postMessage({ data });
12
12
  }
13
+
13
14
  if (event.data.type === "filterwords") {
14
15
  const { data, serachValue, prefixValue, containsValue, suffixValue, exculdeValue, includeValue, lengthValue, sortingFilter, dictonary } = event.data
15
16
  let newWordsLength = 0;
@@ -71,71 +72,84 @@ self.onmessage = async (event) => {
71
72
  if (lengthValue) {
72
73
  newdata = newdata.filter((item) => item.length == lengthValue);
73
74
  }
74
- // if (newdata.length === 0) {
75
- // } else {
76
- newWordsLength += newdata.length;
77
- newdata = sortWords(sortingFilter, newdata, dictonary);
78
- let result = newdata.map((item) => {
79
- let itemHtml = "";
80
- if (serachValue) {
81
- var text1 = serachValue.replace("?", "");
82
- var text2 = item;
83
- var text3 = item;
84
- let chars = text1.split("");
85
- let indexs = [];
86
- chars.map((i) => {
87
- let findIndexes = findIndex(text3, i);
88
- if (findIndexes.length > 0) {
89
- text3 = text3.split("");
90
- text3[findIndexes] = "$";
91
- text3 = text3.join("");
92
- indexs = [...indexs, ...findIndexes];
93
- }
94
- });
95
- text2.split("").map((itemValue, index) => {
96
- let check = indexs.find((i) => i === index);
97
- if (check !== undefined) {
98
- itemHtml += `${itemValue}`;
99
- } else {
100
- itemHtml += `<span class='highlight'>${itemValue}</span>`;
101
- }
102
- });
103
- } else {
104
- itemHtml = item
105
- }
106
- if (item.length === 1) {
107
- ok = false;
108
- newWordsLength = newWordsLength - 1;
109
- } else {
110
- let ScrabbleLetterScore = ScrabbleScore();
111
- sum = 0;
112
- item = item.toLowerCase();
113
- for (let i = 0; i < item.length; i++) {
114
- sum += ScrabbleLetterScore[item[i]] || 0; // for unknown characters
75
+ if (newdata.length === 0) {
76
+ self.postMessage({
77
+ type: "filterwords",
78
+ prefixValue: prefixValue,
79
+ containsValue: containsValue,
80
+ suffixValue: suffixValue,
81
+ exculdeValue: exculdeValue,
82
+ includeValue: includeValue,
83
+ lengthValue: lengthValue,
84
+ newdata: newdata,
85
+ i: i,
86
+ newWordsLength: newWordsLength,
87
+ });
88
+
89
+ } else {
90
+ newWordsLength += newdata.length;
91
+ newdata = sortWords(sortingFilter, newdata, dictonary);
92
+ let result = newdata.map((item) => {
93
+ let itemHtml = "";
94
+ if (serachValue) {
95
+ var text1 = serachValue.replace("?", "");
96
+ var text2 = item;
97
+ var text3 = item;
98
+ let chars = text1.split("");
99
+ let indexs = [];
100
+ chars.map((i) => {
101
+ let findIndexes = findIndex(text3, i);
102
+ if (findIndexes.length > 0) {
103
+ text3 = text3.split("");
104
+ text3[findIndexes] = "$";
105
+ text3 = text3.join("");
106
+ indexs = [...indexs, ...findIndexes];
107
+ }
108
+ });
109
+ text2.split("").map((itemValue, index) => {
110
+ let check = indexs.find((i) => i === index);
111
+ if (check !== undefined) {
112
+ itemHtml += `${itemValue}`;
113
+ } else {
114
+ itemHtml += `<span class='highlight'>${itemValue}</span>`;
115
+ }
116
+ });
117
+ } else {
118
+ itemHtml = item
115
119
  }
116
- return `
120
+ if (item.length === 1) {
121
+ ok = false;
122
+ newWordsLength = newWordsLength - 1;
123
+ } else {
124
+ let ScrabbleLetterScore = ScrabbleScore();
125
+ sum = 0;
126
+ item = item.toLowerCase();
127
+ for (let i = 0; i < item.length; i++) {
128
+ sum += ScrabbleLetterScore[item[i]] || 0; // for unknown characters
129
+ }
130
+ return `
117
131
  <a class="anchor__style" title="Lookup ${item} in Dictionary" target="_blank" href="/word-meaning?search=${item.toLowerCase()}">
118
132
  ${itemHtml}
119
133
  <span class="points" value="${sum}" style="position:relative; top:4px; font-size:12px">${sum}</span>
120
134
  </a>
121
135
  `;
122
- }
123
- });
124
- result = result.slice(0, 25)
125
- self.postMessage({
126
- type: "filterwords",
127
- prefixValue: prefixValue,
128
- containsValue: containsValue,
129
- suffixValue: suffixValue,
130
- exculdeValue: exculdeValue,
131
- includeValue: includeValue,
132
- lengthValue: lengthValue,
133
- newdata: newdata,
134
- i: i,
135
- newWordsLength: newWordsLength,
136
- result,
137
- });
138
- // }
136
+ }
137
+ });
138
+ result = result.slice(0, 25)
139
+ self.postMessage({
140
+ type: "filterwords",
141
+ prefixValue: prefixValue,
142
+ containsValue: containsValue,
143
+ suffixValue: suffixValue,
144
+ exculdeValue: exculdeValue,
145
+ includeValue: includeValue,
146
+ lengthValue: lengthValue,
147
+ newdata: newdata,
148
+ i: i,
149
+ newWordsLength: newWordsLength,
150
+ result,
151
+ });
152
+ }
139
153
  }
140
154
  }
141
155
  };
@@ -635,4 +635,4 @@ function findIndex(str, char) {
635
635
  }
636
636
 
637
637
  return indexes;
638
- }
638
+ }
@@ -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.1
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-16 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