word-games-theme 2.7.9 → 2.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/_includes/wordgames/search-box/search-box.html +1 -1
- data/_layouts/wordgames-home.html +1 -0
- data/assets/js/wordfinder.js +135 -358
- data/assets/js/wordgames-result.js +298 -452
- metadata +2 -2
@@ -5,9 +5,7 @@ const getScript = document.currentScript;
|
|
5
5
|
let form = document.querySelector("#form");
|
6
6
|
let wordCount = document.querySelector(".wordCount");
|
7
7
|
let main = document.querySelector(".main");
|
8
|
-
// let loader = document.querySelector(".main-loader")
|
9
8
|
let errorMsg = document.querySelector(".errorMsg");
|
10
|
-
let script = document.currentScript;
|
11
9
|
|
12
10
|
// getqueryUrl from form
|
13
11
|
const params = new URLSearchParams(window.location.search);
|
@@ -22,15 +20,6 @@ let dictonary = params.get("dictionary");
|
|
22
20
|
|
23
21
|
// advanced filter element grabs
|
24
22
|
let tick;
|
25
|
-
let startsWith = document.getElementById("startsWith");
|
26
|
-
let mustInclude = document.getElementById("mustInclude");
|
27
|
-
console.log(mustInclude);
|
28
|
-
let endsWith = document.getElementById("endsWith");
|
29
|
-
let exculdeWith = document.getElementById("exculdeWith");
|
30
|
-
let inculdeWith = document.getElementById("inculdeWith");
|
31
|
-
let wordLength = document.getElementById("wordLength");
|
32
|
-
|
33
|
-
|
34
23
|
let ok = true;
|
35
24
|
|
36
25
|
let tab_container = document.querySelector(".tab_container");
|
@@ -38,140 +27,14 @@ let lengthSelect = document.querySelector(".length-select");
|
|
38
27
|
const siteUrl = getScript.dataset.url;
|
39
28
|
var sortValue;
|
40
29
|
var sortBool = false;
|
41
|
-
|
42
|
-
let
|
43
|
-
|
44
|
-
)
|
45
|
-
if (serachValue) {
|
46
|
-
letterCloseButton.classList.add("ltr-cls-btn-commonPage");
|
47
|
-
}
|
48
|
-
letterCloseButton.addEventListener("click", () => {
|
49
|
-
txtBox.value = "";
|
50
|
-
letterCloseButton.classList.remove("ltr-cls-btn-commonPage");
|
51
|
-
});
|
52
|
-
|
53
|
-
let txtBox = document.querySelector(".txtBox");
|
54
|
-
txtBox.focus();
|
30
|
+
let featureContainer = document.querySelector("#featureContainer")
|
31
|
+
let howContainer = document.querySelector("#howContainer")
|
32
|
+
let faqsContainer = document.querySelector("#faqsContainer")
|
33
|
+
let infographicsContainer = document.querySelector("#infographicsContainer")
|
55
34
|
txtBox.value = serachValue;
|
56
35
|
|
57
|
-
txtBox.addEventListener("input", (e) => {
|
58
|
-
if (e.target.value === "") {
|
59
|
-
letterCloseButton.classList.remove("ltr-cls-btn-commonPage");
|
60
|
-
} else {
|
61
|
-
letterCloseButton.classList.add("ltr-cls-btn-commonPage");
|
62
|
-
}
|
63
|
-
let rangeOfBlankTile = script.dataset.range;
|
64
|
-
e.target.value = e.target.value.replace(/[^a-zA-Z? ]/g, "");
|
65
|
-
if (rangeOfBlankTile === "") {
|
66
|
-
rangeOfBlankTile = 3;
|
67
|
-
}
|
68
|
-
e.target.value = e.target.value.replace(/ /g, "?");
|
69
|
-
let data = [];
|
70
|
-
data = e.target.value.split("").filter((i) => i === "?");
|
71
|
-
if (data.length > rangeOfBlankTile) {
|
72
|
-
e.target.value = e.target.value.replace(/\?$/, "");
|
73
|
-
}
|
74
|
-
});
|
75
|
-
|
76
|
-
function mobileScrollTop(x) {
|
77
|
-
if (x.matches) {
|
78
|
-
console.log(x.matches);
|
79
|
-
txtBox.addEventListener("click", () => {
|
80
|
-
document.documentElement.scrollTop = 350;
|
81
|
-
setTimeout(() => {
|
82
|
-
document.documentElement.scrollTop = 350;
|
83
|
-
}, 300);
|
84
|
-
});
|
85
|
-
} else {
|
86
|
-
console.log("false");
|
87
|
-
}
|
88
|
-
}
|
89
|
-
var x = window.matchMedia("(max-width: 768px)");
|
90
|
-
// mobileScrollTop(x);
|
91
|
-
// x.addListener(mobileScrollTop);
|
92
|
-
|
93
|
-
let rangeOfBlankTile = script.dataset.range;
|
94
|
-
let quesMark = "?";
|
95
|
-
|
96
|
-
if (rangeOfBlankTile) {
|
97
|
-
if (!serachValue.includes("?")) {
|
98
|
-
serachValue = serachValue + quesMark.repeat(rangeOfBlankTile); //
|
99
|
-
txtBox.value = serachValue;
|
100
|
-
}
|
101
|
-
}
|
102
|
-
|
103
|
-
const filterInputs = document.querySelectorAll('.filter_val');
|
104
|
-
Array.from(filterInputs).forEach((item) => {
|
105
|
-
item.addEventListener("input", (e) => {
|
106
|
-
const inputValue = e.target.value;
|
107
|
-
const parentElement = e.target.parentElement;
|
108
|
-
const imgElement = parentElement.querySelector('img');
|
109
|
-
const tooltipElement = parentElement.querySelector('.filter-tooltip');
|
110
|
-
|
111
|
-
if (inputValue == "") {
|
112
|
-
imgElement.src = "/assets/images/questionmark.svg"
|
113
|
-
item.nextElementSibling.setAttribute("data-tip", item.nextElementSibling.id)
|
114
|
-
tooltipElement.style.setProperty('--tooltip-padding', '0.5rem');
|
115
|
-
tooltipElement.style.setProperty('--tooltip-border-style', 'soild');
|
116
|
-
|
117
|
-
} else {
|
118
|
-
item.nextElementSibling.removeAttribute("data-tip")
|
119
|
-
imgElement.src = "/assets/images/close-btn.svg"
|
120
|
-
tooltipElement.style.setProperty('--tooltip-padding', '0');
|
121
|
-
tooltipElement.style.setProperty('--tooltip-border-style', 'none');
|
122
|
-
}
|
123
|
-
item.nextElementSibling.addEventListener("click", () => {
|
124
|
-
e.target.value = ""
|
125
|
-
imgElement.src = "/assets/images/questionmark.svg"
|
126
|
-
item.nextElementSibling.setAttribute("data-tip", item.nextElementSibling.id)
|
127
|
-
tooltipElement.style.setProperty('--tooltip-padding', '0.5rem');
|
128
|
-
tooltipElement.style.setProperty('--tooltip-border-style', 'soild');
|
129
|
-
})
|
130
|
-
})
|
131
|
-
})
|
132
|
-
|
133
|
-
|
134
|
-
function handleFilterInput(e) {
|
135
|
-
const inputValue = e.target.value;
|
136
|
-
const parentElement = e.target.parentElement;
|
137
|
-
const imgElement = parentElement.querySelector('img');
|
138
|
-
const tooltipElement = parentElement.querySelector('.filter-tooltip');
|
139
|
-
|
140
|
-
if (inputValue == "") {
|
141
|
-
imgElement.src = "/assets/images/questionmark.svg"
|
142
|
-
e.target.nextElementSibling.setAttribute("data-tip", e.target.nextElementSibling.id)
|
143
|
-
tooltipElement.style.setProperty('--tooltip-padding', '0.5rem');
|
144
|
-
tooltipElement.style.setProperty('--tooltip-border-style', 'solid');
|
145
|
-
} else {
|
146
|
-
e.target.nextElementSibling.removeAttribute("data-tip")
|
147
|
-
imgElement.src = "/assets/images/close-btn.svg"
|
148
|
-
tooltipElement.style.setProperty('--tooltip-padding', '0');
|
149
|
-
tooltipElement.style.setProperty('--tooltip-border-style', 'none');
|
150
|
-
}
|
151
|
-
|
152
|
-
e.target.nextElementSibling.addEventListener("click", () => {
|
153
|
-
e.target.value = ""
|
154
|
-
imgElement.src = "/assets/images/questionmark.svg"
|
155
|
-
e.target.nextElementSibling.setAttribute("data-tip", e.target.nextElementSibling.id)
|
156
|
-
tooltipElement.style.setProperty('--tooltip-padding', '0.5rem');
|
157
|
-
tooltipElement.style.setProperty('--tooltip-border-style', 'solid');
|
158
|
-
});
|
159
|
-
}
|
160
|
-
|
161
|
-
document.addEventListener("DOMContentLoaded", () => {
|
162
|
-
const filterInputs = document.querySelectorAll('.filter_val');
|
163
|
-
Array.from(filterInputs).forEach((item) => {
|
164
|
-
// Call the function on load
|
165
|
-
handleFilterInput({ target: item });
|
166
|
-
item.addEventListener("input", handleFilterInput);
|
167
|
-
});
|
168
|
-
});
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
36
|
let theSelect = document.getElementById("select_dropDown");
|
174
|
-
|
37
|
+
let sortingFilter = document.querySelector("#select_dropDown");
|
175
38
|
const sortup = document.querySelector(".sortup-icon");
|
176
39
|
let bool = false;
|
177
40
|
sortup.addEventListener("click", () => {
|
@@ -208,23 +71,68 @@ const getDiff = (text1, text2) => {
|
|
208
71
|
return diffRange;
|
209
72
|
};
|
210
73
|
|
74
|
+
let authorsLists = document.querySelector(".authors-list")
|
75
|
+
|
211
76
|
// getWords define...
|
212
77
|
const getData = async (serachValue) => {
|
213
78
|
try {
|
79
|
+
document.querySelector(".main-header").style.background = "#fff"
|
80
|
+
document.querySelector(".heading-h2").style.display = "none"
|
81
|
+
document.querySelector(".sortingFilters").style.display = "none"
|
82
|
+
if (featureContainer) {
|
83
|
+
featureContainer.remove()
|
84
|
+
}
|
85
|
+
if (howContainer) {
|
86
|
+
howContainer.remove()
|
87
|
+
}
|
88
|
+
if (faqsContainer) {
|
89
|
+
faqsContainer.remove()
|
90
|
+
}
|
91
|
+
if (infographicsContainer) {
|
92
|
+
infographicsContainer.remove()
|
93
|
+
}
|
94
|
+
if (authorsLists) {
|
95
|
+
authorsLists.remove()
|
96
|
+
}
|
214
97
|
errorMsg.innerHTML = "";
|
215
98
|
wordCount.innerHTML = "";
|
216
99
|
let selectedDictionary = document.querySelector(".select_dropDown2").value;
|
217
|
-
main.innerHTML = `<
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
100
|
+
main.innerHTML = `<main class="placeholder-loader">
|
101
|
+
<ul class="o-vertical-spacing o-vertical-spacing--l">
|
102
|
+
<li class="blog-post o-media">
|
103
|
+
<div class="o-media__body">
|
104
|
+
<div class="o-vertical-spacing">
|
105
|
+
<p class="m-0">
|
106
|
+
<span class="skeleton-box" style="width:40%;"></span>
|
107
|
+
</p>
|
108
|
+
</div>
|
109
|
+
</div>
|
110
|
+
</li>
|
111
|
+
<li class="blog-post o-media">
|
112
|
+
<div class="o-media__figure">
|
113
|
+
<span class="skeleton-box" style="width:900px;height:140px;"></span>
|
114
|
+
</div>
|
115
|
+
</li>
|
116
|
+
<li class="blog-post o-media">
|
117
|
+
<div class="o-media__figure">
|
118
|
+
<span class="skeleton-box" style="width:900px;height:140px;"></span>
|
119
|
+
</div>
|
120
|
+
</li>
|
121
|
+
<li class="blog-post o-media">
|
122
|
+
<div class="o-media__figure">
|
123
|
+
<span class="skeleton-box" style="width:900px;height:140px;"></span>
|
124
|
+
</div>
|
125
|
+
</li>
|
126
|
+
</ul>
|
127
|
+
</main>`;
|
224
128
|
/// loader
|
225
|
-
|
226
|
-
|
227
|
-
|
129
|
+
let response
|
130
|
+
if (serachValue) {
|
131
|
+
response = await fetch(`/.netlify/functions/getWords?name=${serachValue}&selecteddictionary=${selectedDictionary}`);
|
132
|
+
} else {
|
133
|
+
response = await fetch(`/.netlify/functions/getData?&selecteddictionary=${selectedDictionary}`)
|
134
|
+
}
|
135
|
+
|
228
136
|
const data = await response.json();
|
229
137
|
main.innerHTML = "";
|
230
138
|
getWords(data);
|
@@ -244,11 +152,11 @@ if (lengthValue === "1") {
|
|
244
152
|
|
245
153
|
const scrollingElement = document.scrollingElement || document.body;
|
246
154
|
scrollingElement.scroll({ top: 0, behavior: "smooth" });
|
247
|
-
if (rangeOfBlankTile) {
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
}
|
155
|
+
// if (rangeOfBlankTile) {
|
156
|
+
// if (!txtBox.value.includes("?")) {
|
157
|
+
// txtBox.value = txtBox.value + quesMark.repeat(rangeOfBlankTile); //
|
158
|
+
// }
|
159
|
+
// }
|
252
160
|
|
253
161
|
let selectedDictionary = document.querySelector(".select_dropDown2").value;
|
254
162
|
event.preventDefault();
|
@@ -309,21 +217,23 @@ if (lengthValue === "1") {
|
|
309
217
|
getData(txtBox.value.toLowerCase());
|
310
218
|
// addFilterCount();
|
311
219
|
}
|
312
|
-
|
313
220
|
let selectedDictionary = document.querySelector(".select_dropDown2");
|
314
221
|
selectedDictionary.addEventListener("change", (e) => {
|
315
222
|
logSubmit(e);
|
316
223
|
});
|
317
224
|
// applyBtn.addEventListener("submit", logSubmit);
|
318
225
|
form.addEventListener("submit", logSubmit);
|
226
|
+
sortingFilter.addEventListener("change", logSubmit);
|
319
227
|
}
|
320
228
|
|
321
|
-
|
229
|
+
let moreData = []
|
230
|
+
let data_index = 25;
|
322
231
|
function getWords(data) {
|
232
|
+
data_index = 25
|
233
|
+
moreData = []
|
323
234
|
main.innerHTML = "";
|
324
|
-
document.querySelector(".sortingFilters").style.display="flex"
|
325
|
-
// tab_container.innerHTML = "";
|
326
235
|
lengthSelect.innerHTML = ""
|
236
|
+
document.querySelector(".sortingFilters").style.display = "flex"
|
327
237
|
if (typeof data === "string") {
|
328
238
|
errorMsg.innerHTML = "no words found";
|
329
239
|
wordCount.innerHTML = `<strong>Found 0 words with letters ${serachValue.split(
|
@@ -332,7 +242,7 @@ function getWords(data) {
|
|
332
242
|
} else {
|
333
243
|
let newWordsLength = 0;
|
334
244
|
let dataArr = [];
|
335
|
-
for (let i =
|
245
|
+
for (let i = 15; i > 0; i--) {
|
336
246
|
let newdata = data.filter((item) => item.length === i);
|
337
247
|
if (prefixValue) {
|
338
248
|
newdata = newdata.filter((item2) =>
|
@@ -424,34 +334,36 @@ function getWords(data) {
|
|
424
334
|
main.innerHTML += "";
|
425
335
|
} else {
|
426
336
|
newWordsLength += newdata.length;
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
var text3 = item;
|
431
|
-
let chars = text1.split("");
|
432
|
-
|
433
|
-
let indexs = [];
|
434
|
-
chars.map((i) => {
|
435
|
-
let findIndexes = findIndex(text3, i);
|
436
|
-
if (findIndexes.length > 0) {
|
437
|
-
text3 = text3.split("");
|
438
|
-
text3[findIndexes] = "$";
|
439
|
-
text3 = text3.join("");
|
440
|
-
|
441
|
-
indexs = [...indexs, ...findIndexes];
|
442
|
-
}
|
443
|
-
});
|
337
|
+
newdata = sortWords(newdata);
|
338
|
+
moreData.push(newdata)
|
339
|
+
let result = newdata.map((item) => {
|
444
340
|
let itemHtml = "";
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
341
|
+
if (serachValue) {
|
342
|
+
var text1 = serachValue.replace("?", "");
|
343
|
+
var text2 = item;
|
344
|
+
var text3 = item;
|
345
|
+
let chars = text1.split("");
|
346
|
+
let indexs = [];
|
347
|
+
chars.map((i) => {
|
348
|
+
let findIndexes = findIndex(text3, i);
|
349
|
+
if (findIndexes.length > 0) {
|
350
|
+
text3 = text3.split("");
|
351
|
+
text3[findIndexes] = "$";
|
352
|
+
text3 = text3.join("");
|
353
|
+
indexs = [...indexs, ...findIndexes];
|
354
|
+
}
|
355
|
+
});
|
356
|
+
text2.split("").map((itemValue, index) => {
|
357
|
+
let check = indexs.find((i) => i === index);
|
358
|
+
if (check !== undefined) {
|
359
|
+
itemHtml += `${itemValue}`;
|
360
|
+
} else {
|
361
|
+
itemHtml += `<span class='highlight'>${itemValue}</span>`;
|
362
|
+
}
|
363
|
+
});
|
364
|
+
} else {
|
365
|
+
itemHtml = item
|
366
|
+
}
|
455
367
|
if (item.length === 1) {
|
456
368
|
ok = false;
|
457
369
|
newWordsLength = newWordsLength - 1;
|
@@ -463,298 +375,232 @@ function getWords(data) {
|
|
463
375
|
sum += ScrabbleLetterScore[item[i]] || 0; // for unknown characters
|
464
376
|
}
|
465
377
|
dataArr.push(item);
|
466
|
-
return
|
467
|
-
|
468
|
-
|
469
|
-
|
378
|
+
return `
|
379
|
+
<a class="anchor__style" title="Lookup ${item} in Dictionary" target="_blank" href="/word-meaning?search=${item.toLowerCase()}">
|
380
|
+
${itemHtml}
|
381
|
+
<span class="points" value="${sum}" style="position:relative; top:4px; font-size:12px">${sum}</span>
|
382
|
+
</a>
|
383
|
+
`;
|
470
384
|
}
|
471
385
|
});
|
472
|
-
|
473
386
|
if (result[0] !== undefined) {
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
387
|
+
if (wordLength.value) {
|
388
|
+
lengthSelect.style.display = "none"
|
389
|
+
} else {
|
390
|
+
var option = document.createElement("option");
|
391
|
+
option.text = `${i} Letter`;
|
392
|
+
option.value = i;
|
393
|
+
lengthSelect.setAttribute("onchange", `Filtering(${i})`)
|
394
|
+
lengthSelect.add(option);
|
395
|
+
lengthSelect.style.display = "block"
|
396
|
+
}
|
397
|
+
|
398
|
+
result = result.slice(0, 25)
|
399
|
+
|
486
400
|
main.innerHTML += `
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
</div>
|
497
|
-
`;
|
401
|
+
<div class="allGroupWords wordlistContainer" id="alpha_${i}">
|
402
|
+
<h3 class="wordListHeading lead">${i} Letter Words</h3>
|
403
|
+
<div class="wordList">${result.join("")}</div>
|
404
|
+
<div class="w-100 text-center btn-container">
|
405
|
+
<button onclick="showMoreWords(this)" type="button" class="my-4 showmore_btn" id="${i}">More Words</button>
|
406
|
+
</div>
|
407
|
+
</div>`
|
408
|
+
|
409
|
+
showMoreLimit()
|
498
410
|
}
|
499
411
|
}
|
500
412
|
}
|
501
|
-
theSelect.addEventListener("change", () => {
|
502
|
-
sortValue = theSelect[theSelect.selectedIndex].text;
|
503
|
-
if (sortValue == "Z-A") {
|
504
|
-
sortBool = true;
|
505
|
-
sortby(sortBool, dataArr);
|
506
|
-
} else {
|
507
|
-
sortBool = false;
|
508
|
-
sortby(sortBool, dataArr);
|
509
|
-
}
|
510
|
-
if (sortValue == "Points") {
|
511
|
-
sortBool = true;
|
512
|
-
sortPointsby(sortBool, dataArr);
|
513
|
-
}
|
514
|
-
});
|
515
|
-
sortValue = theSelect[theSelect.selectedIndex].text;
|
516
|
-
if (sortValue == "Z-A") {
|
517
|
-
sortby(sortBool, dataArr);
|
518
|
-
}
|
519
|
-
if (sortValue == "Points") {
|
520
|
-
sortPointsby(sortBool, dataArr);
|
521
|
-
}
|
522
413
|
if (newWordsLength === 0) {
|
523
|
-
errorMsg.innerHTML = "
|
524
|
-
|
525
|
-
wordCount.innerHTML = `<strong>Found ${newWordsLength} words with letters with ${serachValue.split(
|
526
|
-
""
|
527
|
-
)}</strong>`;
|
528
|
-
}
|
529
|
-
}
|
530
|
-
}
|
414
|
+
errorMsg.innerHTML = "No Words Found";
|
415
|
+
document.querySelector(".sortingFilters").style.display = "none"
|
531
416
|
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
if (sortValue) {
|
536
|
-
let newWordsLength = 0;
|
537
|
-
for (let i = serachValue.length; i >= 1; i--) {
|
538
|
-
var newdata = data.filter((item) => item.length === i);
|
539
|
-
if (newdata.length === 0) {
|
540
|
-
main.innerHTML += "";
|
417
|
+
} else {
|
418
|
+
if (serachValue) {
|
419
|
+
wordCount.innerHTML = `<strong>Found ${newWordsLength} words with letters with ${serachValue.split("")}</strong>`;
|
541
420
|
} else {
|
542
|
-
newWordsLength += newdata.length;
|
543
|
-
var newArray = [];
|
544
|
-
newdata.map((item) => {
|
545
|
-
if (item.length === 1) {
|
546
|
-
ok = false;
|
547
|
-
newWordsLength = newWordsLength - 1;
|
548
|
-
} else {
|
549
|
-
let ScrabbleLetterScore = ScrabbleScore();
|
550
|
-
let points = 0;
|
551
|
-
item = item.toLowerCase();
|
552
|
-
for (let i = 0; i < item.length; i++) {
|
553
|
-
points += ScrabbleLetterScore[item[i]] || 0; // for unknown characters
|
554
|
-
}
|
555
|
-
const value = {
|
556
|
-
words: item,
|
557
|
-
points: points,
|
558
|
-
};
|
559
|
-
newArray.push(value);
|
560
|
-
}
|
561
|
-
});
|
562
421
|
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
if (findIndexes.length > 0) {
|
586
|
-
text3 = text3.split("");
|
587
|
-
text3[findIndexes] = "$";
|
588
|
-
text3 = text3.join("");
|
589
|
-
indexs = [...indexs, ...findIndexes];
|
590
|
-
}
|
591
|
-
});
|
592
|
-
let itemHtml = "";
|
593
|
-
text2.split("").map((itemValue, index) => {
|
594
|
-
let check = indexs.find((i) => i === index);
|
595
|
-
if (check !== undefined) {
|
596
|
-
itemHtml += `${itemValue}`;
|
597
|
-
} else {
|
598
|
-
itemHtml += `<span class='highlight'>${itemValue}</span>`;
|
599
|
-
}
|
600
|
-
});
|
601
|
-
return `<a class="anchor__style" title="Lookup ${item} in Dictionary" target="_blank" href="/word-meaning?search=${item.words}">
|
602
|
-
<li>${itemHtml}
|
603
|
-
<span class="points" value="${item.points}" style="position:relative; top:4px; font-size:12px"> ${item.points}</span>
|
604
|
-
</li></a>`;
|
605
|
-
});
|
422
|
+
let startwithMsg = ""
|
423
|
+
let endwithMsg = ""
|
424
|
+
let containsMsg = ""
|
425
|
+
let lengthMsg = ""
|
426
|
+
let inputVal = ""
|
427
|
+
if (serachValue) {
|
428
|
+
inputVal = `${input.value.split("")} `
|
429
|
+
}
|
430
|
+
if (prefixValue) {
|
431
|
+
startwithMsg = `starting with ${prefixValue.split("")}`
|
432
|
+
}
|
433
|
+
if (suffixValue) {
|
434
|
+
endwithMsg = `ending with ${suffixValue.split("")} `
|
435
|
+
}
|
436
|
+
if (containsValue) {
|
437
|
+
containsMsg = `containing with ${containsValue.split("")} `
|
438
|
+
}
|
439
|
+
if (lengthValue) {
|
440
|
+
lengthMsg = `with ${lengthValue} letter words`
|
441
|
+
}
|
442
|
+
let msg = `<strong> Found ${newWordsLength} words with letters
|
443
|
+
${lengthMsg} ${inputVal} ${startwithMsg} ${endwithMsg} ${containsMsg} </strong>`
|
606
444
|
|
607
|
-
|
608
|
-
<div class="allGroupWords wordlistContainer" id="alpha_${i}">
|
609
|
-
<div class="wordListHeading">
|
610
|
-
<h3 class="lead">${i} Letter Words</h3>
|
611
|
-
</div>
|
612
|
-
<div class="wordList">
|
613
|
-
<ul class="ul list-unstyled">
|
614
|
-
${result.join("")}
|
615
|
-
</ul>
|
616
|
-
</div>
|
617
|
-
</div>
|
618
|
-
`;
|
445
|
+
wordCount.innerHTML = `${msg} `
|
619
446
|
}
|
620
447
|
}
|
621
448
|
}
|
622
449
|
}
|
623
|
-
// sort by aplhabets
|
624
|
-
function sortby(sortBool, data) {
|
625
|
-
if (sortBool) {
|
626
|
-
main.innerHTML = "";
|
627
|
-
data.reverse();
|
628
|
-
let newWordsLength = 0;
|
629
|
-
for (let i = serachValue.length; i >= 1; i--) {
|
630
|
-
var newdata = data.filter((item) => item.length === i);
|
631
450
|
|
632
|
-
if (newdata.length === 0) {
|
633
|
-
main.innerHTML += "";
|
634
|
-
} else {
|
635
|
-
newWordsLength += newdata.length;
|
636
451
|
|
637
|
-
const result = newdata.map((item) => {
|
638
|
-
var text1 = serachValue.replace("?", "");
|
639
|
-
var text2 = item;
|
640
|
-
var text3 = item;
|
641
|
-
let chars = text1.split("");
|
642
|
-
let indexs = [];
|
643
|
-
chars.map((i) => {
|
644
|
-
let findIndexes = findIndex(text3, i);
|
645
|
-
if (findIndexes.length > 0) {
|
646
|
-
text3 = text3.split("");
|
647
|
-
text3[findIndexes] = "$";
|
648
|
-
text3 = text3.join("");
|
649
|
-
indexs = [...indexs, ...findIndexes];
|
650
|
-
}
|
651
|
-
});
|
652
|
-
let itemHtml = "";
|
653
|
-
text2.split("").map((itemValue, index) => {
|
654
|
-
let check = indexs.find((i) => i === index);
|
655
|
-
if (check !== undefined) {
|
656
|
-
itemHtml += `${itemValue}`;
|
657
|
-
} else {
|
658
|
-
itemHtml += `<span class='highlight'>${itemValue}</span>`;
|
659
|
-
}
|
660
|
-
});
|
661
|
-
if (item.length === 1) {
|
662
|
-
ok = false;
|
663
|
-
newWordsLength = newWordsLength - 1;
|
664
|
-
} else {
|
665
|
-
let ScrabbleLetterScore = ScrabbleScore();
|
666
|
-
let sum = 0;
|
667
|
-
item = item.toLowerCase();
|
668
|
-
for (let i = 0; i < item.length; i++) {
|
669
|
-
sum += ScrabbleLetterScore[item[i]] || 0; // for unknown characters
|
670
|
-
}
|
671
452
|
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
453
|
+
async function getMoreWords() {
|
454
|
+
let flattenedArray = moreData.flat();
|
455
|
+
let uniqueArray = [...new Set(flattenedArray)];
|
456
|
+
// console.log(uniqueArray);
|
457
|
+
return uniqueArray
|
458
|
+
}
|
678
459
|
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
460
|
+
let previousDataIndex = null
|
461
|
+
let previousID = null;
|
462
|
+
|
463
|
+
async function showMoreWords(e) {
|
464
|
+
try {
|
465
|
+
let showmore = e.parentElement.children[0];
|
466
|
+
let id = showmore.id;
|
467
|
+
|
468
|
+
// Compare previousID with current id
|
469
|
+
if (previousID !== null && parseInt(previousID) !== parseInt(id)) {
|
470
|
+
console.log("Previous ID:", previousID);
|
471
|
+
console.log("Current ID:", id);
|
472
|
+
previousDataIndex = data_index;
|
473
|
+
data_index = 25
|
692
474
|
}
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
if (findIndexes.length > 0) {
|
710
|
-
text3 = text3.split("");
|
711
|
-
text3[findIndexes] = "$";
|
712
|
-
text3 = text3.join("");
|
713
|
-
indexs = [...indexs, ...findIndexes];
|
714
|
-
}
|
715
|
-
});
|
475
|
+
else if (previousID !== null && parseInt(previousID) === parseInt(id)) {
|
476
|
+
data_index = previousDataIndex + 25; // Resume data_index from previous record
|
477
|
+
}
|
478
|
+
previousID = id;
|
479
|
+
|
480
|
+
console.log("Previous data_index:", previousDataIndex);
|
481
|
+
console.log("Current data_index:", data_index);
|
482
|
+
|
483
|
+
document.getElementById(id).innerHTML = `Loading...`;
|
484
|
+
let content_area = document.getElementById("alpha_" + id).getElementsByClassName("wordList")[0];
|
485
|
+
const result = await getMoreWords();
|
486
|
+
let full_words = result.filter((item) => item.length === Number(id));
|
487
|
+
|
488
|
+
if (data_index < full_words.length) {
|
489
|
+
for (let d = data_index; d < data_index + 25; d++) {
|
490
|
+
if (full_words[d] != undefined) {
|
716
491
|
let itemHtml = "";
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
492
|
+
if (serachValue) {
|
493
|
+
var text1 = serachValue.replace("?", "");
|
494
|
+
var text2 = full_words[d];
|
495
|
+
var text3 = full_words[d];
|
496
|
+
let chars = text1.split("");
|
497
|
+
let indexs = [];
|
498
|
+
chars.map((i) => {
|
499
|
+
let findIndexes = findIndex(text3, i);
|
500
|
+
if (findIndexes.length > 0) {
|
501
|
+
text3 = text3.split("");
|
502
|
+
text3[findIndexes] = "$";
|
503
|
+
text3 = text3.join("");
|
504
|
+
indexs = [...indexs, ...findIndexes];
|
505
|
+
}
|
506
|
+
});
|
507
|
+
text2.split("").map((itemValue, index) => {
|
508
|
+
let check = indexs.find((i) => i === index);
|
509
|
+
if (check !== undefined) {
|
510
|
+
itemHtml += `${itemValue}`;
|
511
|
+
} else {
|
512
|
+
itemHtml += `<span class='highlight'>${itemValue}</span>`;
|
513
|
+
}
|
514
|
+
});
|
727
515
|
} else {
|
728
|
-
|
729
|
-
let sum = 0;
|
730
|
-
item = item.toLowerCase();
|
731
|
-
for (let i = 0; i < item.length; i++) {
|
732
|
-
sum += ScrabbleLetterScore[item[i]] || 0; // for unknown characters
|
733
|
-
}
|
734
|
-
|
735
|
-
return `<a class="anchor__style" title="Lookup ${item} in Dictionary" target="_blank" href="/word-meaning?search=${item.toLowerCase()}">
|
736
|
-
<li>${itemHtml}
|
737
|
-
<span class="points" value="${sum}" style="position:relative; top:4px; font-size:12px"> ${sum}</span>
|
738
|
-
</li></a>`;
|
516
|
+
itemHtml = full_words[d]
|
739
517
|
}
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
518
|
+
let ScrabbleLetterScore = ScrabbleScore();
|
519
|
+
let points = 0;
|
520
|
+
full_words[d] = full_words[d].toLowerCase();
|
521
|
+
for (let i = 0; i < full_words[d].length; i++) {
|
522
|
+
points += ScrabbleLetterScore[full_words[d][i]] || 0; // for unknown characters
|
523
|
+
}
|
524
|
+
|
525
|
+
let span = document.createElement("span");
|
526
|
+
span.setAttribute("class", "points");
|
527
|
+
span.setAttribute("value", `${points}`);
|
528
|
+
span.innerHTML = `${points}`;
|
529
|
+
|
530
|
+
let a = document.createElement("a");
|
531
|
+
a.setAttribute("class", "anchor__style");
|
532
|
+
a.setAttribute("target", "_blank");
|
533
|
+
a.setAttribute("href", "/word-meaning?search=" + full_words[d].replace(/<\/?[^>]+>/gi, ''));
|
534
|
+
a.setAttribute("data-original-title", `Lookup ${full_words[d].replace(/<\/?[^>]+>/gi, '')} in Dictionary`)
|
535
|
+
a.innerHTML = ` ${itemHtml} `;
|
536
|
+
a.appendChild(span)
|
537
|
+
content_area.appendChild(a);
|
538
|
+
}
|
753
539
|
}
|
540
|
+
document.getElementById(id).innerHTML = `More Words`;
|
541
|
+
previousDataIndex = data_index;
|
542
|
+
data_index += 25;
|
543
|
+
} else {
|
544
|
+
data_index = 25
|
545
|
+
document.getElementById(id).style.display = "none";
|
546
|
+
}
|
547
|
+
} catch (error) {
|
548
|
+
console.error("Error fetching or processing data:", error);
|
549
|
+
}
|
550
|
+
}
|
551
|
+
|
552
|
+
function showMoreLimit() {
|
553
|
+
let tableFooter = document.querySelectorAll(".btn-container")
|
554
|
+
let showmore = document.querySelectorAll(".showmore_btn");
|
555
|
+
for (let i = 0; i < showmore.length; i++) {
|
556
|
+
let data_of_button = document.getElementById("alpha_" + showmore[i].getAttribute("id"));
|
557
|
+
let final_data = data_of_button.getElementsByClassName("anchor__style");
|
558
|
+
if (final_data.length < 25) {
|
559
|
+
tableFooter[i].style.display = "none";
|
754
560
|
}
|
755
561
|
}
|
756
562
|
}
|
563
|
+
function sortWords(data) {
|
564
|
+
if (sortingFilter.selectedIndex == 0) {
|
565
|
+
return data;
|
566
|
+
} else if (sortingFilter.selectedIndex == 1) {
|
567
|
+
return data.sort();
|
568
|
+
} else if (sortingFilter.selectedIndex == 2) {
|
569
|
+
return data.reverse();
|
570
|
+
} else if (sortingFilter.selectedIndex == 3) {
|
571
|
+
var tempArr = [];
|
572
|
+
var newArray = [];
|
573
|
+
data.map((item) => {
|
574
|
+
let newWordsLength = 0;
|
575
|
+
if (item.length === 1) {
|
576
|
+
ok = false;
|
577
|
+
newWordsLength = newWordsLength - 1;
|
578
|
+
} else {
|
579
|
+
let ScrabbleLetterScore = ScrabbleScore();
|
580
|
+
let points = 0;
|
581
|
+
item = item.toLowerCase();
|
582
|
+
for (let i = 0; i < item.length; i++) {
|
583
|
+
points += ScrabbleLetterScore[item[i]] || 0; // for unknown characters
|
584
|
+
}
|
585
|
+
const value = {
|
586
|
+
words: item,
|
587
|
+
points: points,
|
588
|
+
};
|
589
|
+
newArray.push(value);
|
590
|
+
}
|
591
|
+
});
|
757
592
|
|
593
|
+
newArray.sort(function (a, b) {
|
594
|
+
return b.points - a.points;
|
595
|
+
});
|
596
|
+
|
597
|
+
newArray.map((ele) => {
|
598
|
+
tempArr.push(ele.words);
|
599
|
+
});
|
600
|
+
|
601
|
+
return tempArr;
|
602
|
+
}
|
603
|
+
}
|
758
604
|
// Scrabble Point Array
|
759
605
|
const ScrabbleScore = () => {
|
760
606
|
let twl06_sowpods = {
|