word-games-theme 2.3.9 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/_data/wordgames/en/jumble_word_finder.json +9 -1
- data/_data/wordgames/en/root.json +8 -1
- data/_includes/authors/authors.html +1 -1
- data/_includes/featurePageAuthors/featurePageAuthors.html +93 -102
- data/_includes/head/index.html +5 -0
- data/_includes/wordgames/featurehighlights/featurehighlights.html +2 -2
- data/_includes/wordgames/head/head.html +10 -0
- data/_includes/wordgames/search-box/search-box.html +59 -1
- data/_includes/wordgames/words-data/words-data.html +1 -1
- data/_layouts/wordgames-home.html +34 -2
- data/assets/css/style.css +1 -0
- data/assets/css/wordgames-home.css +16 -9
- data/assets/css/wordgames-result.css +2 -2
- data/assets/css/wordgames-theme.css +95 -0
- data/assets/css/wordgames-variables.css +2 -1
- data/assets/js/wordfinder-home.js +198 -0
- data/assets/js/wordfinder.js +952 -0
- data/assets/js/wordgames-home.js +1 -3
- data/assets/js/wordgames-result.js +2 -1
- metadata +4 -2
@@ -0,0 +1,952 @@
|
|
1
|
+
/***************
|
2
|
+
SCRABBLER_JS
|
3
|
+
***************/
|
4
|
+
console.log(true);
|
5
|
+
const getScript = document.currentScript;
|
6
|
+
let form = document.querySelector("#form");
|
7
|
+
let wordCount = document.querySelector(".wordCount");
|
8
|
+
let main = document.querySelector(".main");
|
9
|
+
// let loader = document.querySelector(".main-loader")
|
10
|
+
let errorMsg = document.querySelector(".errorMsg");
|
11
|
+
let script = document.currentScript;
|
12
|
+
|
13
|
+
// getqueryUrl from form
|
14
|
+
const params = new URLSearchParams(window.location.search);
|
15
|
+
let serachValue = params.get("search").toLowerCase();
|
16
|
+
let prefixValue = params.get("prefix");
|
17
|
+
let containsValue = params.get("contains");
|
18
|
+
let suffixValue = params.get("suffix");
|
19
|
+
let exculdeValue = params.get("exclude");
|
20
|
+
let includeValue = params.get("include");
|
21
|
+
let lengthValue = params.get("length");
|
22
|
+
let dictonary = params.get("dictionary");
|
23
|
+
|
24
|
+
// advanced filter element grabs
|
25
|
+
let tick;
|
26
|
+
// let startsWith = document.getElementById("startsWith");
|
27
|
+
// let mustInclude = document.getElementById("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
|
+
let ok = true;
|
35
|
+
|
36
|
+
let tab_container = document.querySelector(".tab_container");
|
37
|
+
let lengthSelect = document.querySelector(".length-select");
|
38
|
+
const siteUrl = getScript.dataset.url;
|
39
|
+
var sortValue;
|
40
|
+
var sortBool = false;
|
41
|
+
|
42
|
+
// let letterCloseButton = document.querySelector(
|
43
|
+
// ".letter-close-button-commonPage"
|
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();
|
55
|
+
txtBox.value = serachValue;
|
56
|
+
|
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
|
+
let theSelect = document.getElementById("select_dropDown");
|
174
|
+
|
175
|
+
const sortup = document.querySelector(".sortup-icon");
|
176
|
+
let bool = false;
|
177
|
+
sortup.addEventListener("click", () => {
|
178
|
+
if (bool) {
|
179
|
+
theSelect.size = 0;
|
180
|
+
bool = false;
|
181
|
+
theSelect.style.display = "none";
|
182
|
+
} else {
|
183
|
+
bool = true;
|
184
|
+
theSelect.size = 3;
|
185
|
+
theSelect.style.display = "block";
|
186
|
+
}
|
187
|
+
});
|
188
|
+
document.querySelector(".select_dropDown2").value = dictonary;
|
189
|
+
const getDiff = (text1, text2) => {
|
190
|
+
var diffRange = [];
|
191
|
+
var currentRange = undefined;
|
192
|
+
for (var i = 0; i < text1.length; i++) {
|
193
|
+
if (text1[i] != text2[i]) {
|
194
|
+
if (currentRange == undefined) {
|
195
|
+
currentRange = [i];
|
196
|
+
}
|
197
|
+
}
|
198
|
+
if (currentRange != undefined && text1[i] == text2[i]) {
|
199
|
+
currentRange.push(i);
|
200
|
+
diffRange.push(currentRange);
|
201
|
+
currentRange = undefined;
|
202
|
+
}
|
203
|
+
}
|
204
|
+
if (currentRange != undefined) {
|
205
|
+
currentRange.push(i);
|
206
|
+
diffRange.push(currentRange);
|
207
|
+
}
|
208
|
+
return diffRange;
|
209
|
+
};
|
210
|
+
|
211
|
+
// getWords define...
|
212
|
+
const getData = async (serachValue) => {
|
213
|
+
try {
|
214
|
+
errorMsg.innerHTML = "";
|
215
|
+
wordCount.innerHTML = "";
|
216
|
+
let selectedDictionary = document.querySelector(".select_dropDown2").value;
|
217
|
+
main.innerHTML = `<main class="placeholder-loader">
|
218
|
+
<ul class="o-vertical-spacing o-vertical-spacing--l">
|
219
|
+
<li class="blog-post o-media">
|
220
|
+
<div class="o-media__body">
|
221
|
+
<div class="o-vertical-spacing">
|
222
|
+
<p class="m-0">
|
223
|
+
<span class="skeleton-box" style="width:40%;"></span>
|
224
|
+
</p>
|
225
|
+
</div>
|
226
|
+
</div>
|
227
|
+
</li>
|
228
|
+
<li class="blog-post o-media">
|
229
|
+
<div class="o-media__figure">
|
230
|
+
<span class="skeleton-box" style="width:800px;height:140px;"></span>
|
231
|
+
</div>
|
232
|
+
</li>
|
233
|
+
<li class="blog-post o-media">
|
234
|
+
<div class="o-media__figure">
|
235
|
+
<span class="skeleton-box" style="width:800px;height:140px;"></span>
|
236
|
+
</div>
|
237
|
+
</li>
|
238
|
+
<li class="blog-post o-media">
|
239
|
+
<div class="o-media__figure">
|
240
|
+
<span class="skeleton-box" style="width:800px;height:140px;"></span>
|
241
|
+
</div>
|
242
|
+
</li>
|
243
|
+
</ul>
|
244
|
+
</main>`;
|
245
|
+
/// loader
|
246
|
+
const response = await fetch(
|
247
|
+
`/.netlify/functions/getWords?name=${serachValue}&selecteddictionary=${selectedDictionary}`
|
248
|
+
);
|
249
|
+
const data = await response.json();
|
250
|
+
main.innerHTML = "";
|
251
|
+
getWords(data);
|
252
|
+
//getWords calling...
|
253
|
+
} catch (error) {
|
254
|
+
console.log(error);
|
255
|
+
}
|
256
|
+
};
|
257
|
+
//getData calling...
|
258
|
+
if (lengthValue === "1") {
|
259
|
+
errorMsg.innerHTML = "words length should be more than 1";
|
260
|
+
} else {
|
261
|
+
getData(serachValue.toLowerCase());
|
262
|
+
function logSubmit(event) {
|
263
|
+
document.querySelector(".fillterWrapper").classList.add("hide")
|
264
|
+
|
265
|
+
|
266
|
+
const scrollingElement = document.scrollingElement || document.body;
|
267
|
+
scrollingElement.scroll({ top: 0, behavior: "smooth" });
|
268
|
+
// if (rangeOfBlankTile) {
|
269
|
+
// if (!txtBox.value.includes("?")) {
|
270
|
+
// txtBox.value = txtBox.value + quesMark.repeat(rangeOfBlankTile); //
|
271
|
+
// }
|
272
|
+
// }
|
273
|
+
|
274
|
+
let selectedDictionary = document.querySelector(".select_dropDown2").value;
|
275
|
+
event.preventDefault();
|
276
|
+
if (history.pushState) {
|
277
|
+
var newurl =
|
278
|
+
window.location.protocol +
|
279
|
+
"//" +
|
280
|
+
window.location.host +
|
281
|
+
window.location.pathname +
|
282
|
+
"?" +
|
283
|
+
"search" +
|
284
|
+
"=" +
|
285
|
+
txtBox.value.toLowerCase() +
|
286
|
+
"&" +
|
287
|
+
"dictionary" +
|
288
|
+
"=" +
|
289
|
+
selectedDictionary +
|
290
|
+
"&" +
|
291
|
+
"prefix" +
|
292
|
+
"=" +
|
293
|
+
startsWith.value +
|
294
|
+
"&" +
|
295
|
+
"contains" +
|
296
|
+
"=" +
|
297
|
+
mustInclude.value +
|
298
|
+
"&" +
|
299
|
+
"suffix" +
|
300
|
+
"=" +
|
301
|
+
endsWith.value +
|
302
|
+
"&" +
|
303
|
+
"exclude" +
|
304
|
+
"=" +
|
305
|
+
exculdeWith.value +
|
306
|
+
"&" +
|
307
|
+
"include" +
|
308
|
+
"=" +
|
309
|
+
inculdeWith.value +
|
310
|
+
"&" +
|
311
|
+
"length" +
|
312
|
+
"=" +
|
313
|
+
wordLength.value;
|
314
|
+
window.history.pushState({ path: newurl }, "", newurl);
|
315
|
+
|
316
|
+
const params = new URLSearchParams(window.location.search);
|
317
|
+
serachValue = params.get("search");
|
318
|
+
prefixValue = params.get("prefix");
|
319
|
+
containsValue = params.get("contains");
|
320
|
+
suffixValue = params.get("suffix");
|
321
|
+
exculdeValue = params.get("exclude");
|
322
|
+
includeValue = params.get("include");
|
323
|
+
lengthValue = params.get("length");
|
324
|
+
dictonary = params.get("dictionary");
|
325
|
+
|
326
|
+
gtag("event", "page_view", {
|
327
|
+
page_location: window.location.pathname + location.search,
|
328
|
+
});
|
329
|
+
}
|
330
|
+
getData(txtBox.value.toLowerCase());
|
331
|
+
// addFilterCount();
|
332
|
+
}
|
333
|
+
let selectedDictionary = document.querySelector(".select_dropDown2");
|
334
|
+
selectedDictionary.addEventListener("change", (e) => {
|
335
|
+
logSubmit(e);
|
336
|
+
});
|
337
|
+
// applyBtn.addEventListener("submit", logSubmit);
|
338
|
+
form.addEventListener("submit", logSubmit);
|
339
|
+
}
|
340
|
+
|
341
|
+
// getWords function define...
|
342
|
+
function getWords(data) {
|
343
|
+
main.innerHTML = "";
|
344
|
+
// tab_container.innerHTML = "";
|
345
|
+
lengthSelect.innerHTML = ""
|
346
|
+
document.querySelector(".sortingFilters").style.display="flex"
|
347
|
+
if (typeof data === "string") {
|
348
|
+
errorMsg.innerHTML = "no words found";
|
349
|
+
wordCount.innerHTML = `<strong>Found 0 words with letters ${serachValue.split(
|
350
|
+
""
|
351
|
+
)}</strong>`;
|
352
|
+
} else {
|
353
|
+
let newWordsLength = 0;
|
354
|
+
let dataArr = [];
|
355
|
+
for (let i = serachValue.length; i >= 1; i--) {
|
356
|
+
let newdata = data.filter((item) => item.length === i);
|
357
|
+
if (prefixValue) {
|
358
|
+
newdata = newdata.filter((item2) =>
|
359
|
+
item2.startsWith(prefixValue.toLowerCase())
|
360
|
+
);
|
361
|
+
startsWith.nextElementSibling.querySelector("img").src = "/assets/images/close-btn.svg"
|
362
|
+
startsWith.classList.add("tick");
|
363
|
+
startsWith.value = prefixValue;
|
364
|
+
} else {
|
365
|
+
startsWith.classList.remove("tick");
|
366
|
+
}
|
367
|
+
if (containsValue) {
|
368
|
+
newdata = newdata.filter((item) =>
|
369
|
+
item.includes(containsValue.toLowerCase())
|
370
|
+
);
|
371
|
+
mustInclude.nextElementSibling.querySelector("img").src = "/assets/images/close-btn.svg"
|
372
|
+
mustInclude.classList.add("tick");
|
373
|
+
mustInclude.value = containsValue;
|
374
|
+
} else {
|
375
|
+
mustInclude.classList.remove("tick");
|
376
|
+
}
|
377
|
+
if (suffixValue) {
|
378
|
+
newdata = newdata.filter((item) =>
|
379
|
+
item.endsWith(suffixValue.toLowerCase())
|
380
|
+
);
|
381
|
+
endsWith.nextElementSibling.querySelector("img").src = "/assets/images/close-btn.svg"
|
382
|
+
endsWith.classList.add("tick");
|
383
|
+
endsWith.value = suffixValue;
|
384
|
+
} else {
|
385
|
+
endsWith.classList.remove("tick");
|
386
|
+
}
|
387
|
+
if (exculdeValue) {
|
388
|
+
let data = [];
|
389
|
+
newdata.map((item) => {
|
390
|
+
let check = false;
|
391
|
+
for (let e = 0; e < exculdeValue.length; e++) {
|
392
|
+
const element = exculdeValue[e].toLowerCase();
|
393
|
+
if (item.includes(element)) {
|
394
|
+
check = true;
|
395
|
+
break;
|
396
|
+
} else {
|
397
|
+
check = false;
|
398
|
+
}
|
399
|
+
}
|
400
|
+
if (check === false) {
|
401
|
+
data.push(item);
|
402
|
+
}
|
403
|
+
});
|
404
|
+
exculdeWith.nextElementSibling.querySelector("img").src = "/assets/images/close-btn.svg"
|
405
|
+
exculdeWith.classList.add("tick");
|
406
|
+
exculdeWith.value = exculdeValue;
|
407
|
+
newdata = data;
|
408
|
+
} else {
|
409
|
+
exculdeWith.classList.remove("tick");
|
410
|
+
}
|
411
|
+
if (includeValue) {
|
412
|
+
let data = [];
|
413
|
+
newdata.map((item) => {
|
414
|
+
let check = false;
|
415
|
+
for (let e = 0; e < includeValue.length; e++) {
|
416
|
+
const element = includeValue[e].toLowerCase();
|
417
|
+
if (!item.includes(element)) {
|
418
|
+
check = true;
|
419
|
+
break;
|
420
|
+
} else {
|
421
|
+
check = false;
|
422
|
+
}
|
423
|
+
}
|
424
|
+
if (check === false) {
|
425
|
+
data.push(item);
|
426
|
+
}
|
427
|
+
});
|
428
|
+
inculdeWith.nextElementSibling.querySelector("img").src = "/assets/images/close-btn.svg"
|
429
|
+
inculdeWith.classList.add("tick");
|
430
|
+
inculdeWith.value = includeValue;
|
431
|
+
newdata = data;
|
432
|
+
} else {
|
433
|
+
inculdeWith.classList.remove("tick");
|
434
|
+
}
|
435
|
+
if (lengthValue) {
|
436
|
+
newdata = newdata.filter((item) => item.length == lengthValue);
|
437
|
+
wordLength.nextElementSibling.querySelector("img").src = "/assets/images/close-btn.svg"
|
438
|
+
wordLength.classList.add("tick");
|
439
|
+
wordLength.value = lengthValue;
|
440
|
+
} else {
|
441
|
+
wordLength.classList.remove("tick");
|
442
|
+
}
|
443
|
+
if (newdata.length === 0) {
|
444
|
+
main.innerHTML += "";
|
445
|
+
} else {
|
446
|
+
newWordsLength += newdata.length;
|
447
|
+
const result = newdata.map((item) => {
|
448
|
+
var text1 = serachValue.replace("?", "");
|
449
|
+
var text2 = item;
|
450
|
+
var text3 = item;
|
451
|
+
let chars = text1.split("");
|
452
|
+
|
453
|
+
let indexs = [];
|
454
|
+
chars.map((i) => {
|
455
|
+
let findIndexes = findIndex(text3, i);
|
456
|
+
if (findIndexes.length > 0) {
|
457
|
+
text3 = text3.split("");
|
458
|
+
text3[findIndexes] = "$";
|
459
|
+
text3 = text3.join("");
|
460
|
+
|
461
|
+
indexs = [...indexs, ...findIndexes];
|
462
|
+
}
|
463
|
+
});
|
464
|
+
let itemHtml = "";
|
465
|
+
text2.split("").map((itemValue, index) => {
|
466
|
+
let check = indexs.find((i) => i === index);
|
467
|
+
|
468
|
+
if (check !== undefined) {
|
469
|
+
itemHtml += `${itemValue}`;
|
470
|
+
} else {
|
471
|
+
itemHtml += `<span class='highlight'>${itemValue}</span>`;
|
472
|
+
}
|
473
|
+
});
|
474
|
+
|
475
|
+
if (item.length === 1) {
|
476
|
+
ok = false;
|
477
|
+
newWordsLength = newWordsLength - 1;
|
478
|
+
} else {
|
479
|
+
let ScrabbleLetterScore = ScrabbleScore();
|
480
|
+
sum = 0;
|
481
|
+
item = item.toLowerCase();
|
482
|
+
for (let i = 0; i < item.length; i++) {
|
483
|
+
sum += ScrabbleLetterScore[item[i]] || 0; // for unknown characters
|
484
|
+
}
|
485
|
+
dataArr.push(item);
|
486
|
+
return `<a class="anchor__style" title="Lookup ${item} in Dictionary" target="_blank" href="/word-meaning?search=${item.toLowerCase()}">
|
487
|
+
<li>${itemHtml}
|
488
|
+
<span class="points" value="${sum}" style="position:relative; top:4px; font-size:12px"> ${sum}</span>
|
489
|
+
</li></a>`;
|
490
|
+
}
|
491
|
+
});
|
492
|
+
|
493
|
+
if (result[0] !== undefined) {
|
494
|
+
var option = document.createElement("option");
|
495
|
+
option.text = `${i} Letter`;
|
496
|
+
option.value = i;
|
497
|
+
lengthSelect.setAttribute("onchange", `Filtering(${i})`)
|
498
|
+
lengthSelect.add(option);
|
499
|
+
|
500
|
+
// tab_container.innerHTML += `
|
501
|
+
// <input type="button" id="Tab_${i}" onclick="Filtering(${i})" value="${i} Letter"
|
502
|
+
// class="tab_link cursorPointer" />
|
503
|
+
// `;
|
504
|
+
// let tabs = document.getElementsByClassName("tab_link");
|
505
|
+
// tabs[0] ? tabs[0].classList.add("active-tab") : "";
|
506
|
+
main.innerHTML += `
|
507
|
+
<div class="allGroupWords wordlistContainer" id="alpha_${i}">
|
508
|
+
<div class="wordListHeading">
|
509
|
+
<h3 class="lead">${i} Letter Words</h3>
|
510
|
+
</div>
|
511
|
+
<div class="wordList">
|
512
|
+
<ul class="ul list-unstyled">
|
513
|
+
${result.join("")}
|
514
|
+
</ul>
|
515
|
+
</div>
|
516
|
+
</div>
|
517
|
+
`;
|
518
|
+
}
|
519
|
+
}
|
520
|
+
}
|
521
|
+
theSelect.addEventListener("change", () => {
|
522
|
+
sortValue = theSelect[theSelect.selectedIndex].text;
|
523
|
+
if (sortValue == "Z-A") {
|
524
|
+
sortBool = true;
|
525
|
+
sortby(sortBool, dataArr);
|
526
|
+
} else {
|
527
|
+
sortBool = false;
|
528
|
+
sortby(sortBool, dataArr);
|
529
|
+
}
|
530
|
+
if (sortValue == "Points") {
|
531
|
+
sortBool = true;
|
532
|
+
sortPointsby(sortBool, dataArr);
|
533
|
+
}
|
534
|
+
});
|
535
|
+
sortValue = theSelect[theSelect.selectedIndex].text;
|
536
|
+
if (sortValue == "Z-A") {
|
537
|
+
sortby(sortBool, dataArr);
|
538
|
+
}
|
539
|
+
if (sortValue == "Points") {
|
540
|
+
sortPointsby(sortBool, dataArr);
|
541
|
+
}
|
542
|
+
if (newWordsLength === 0) {
|
543
|
+
errorMsg.innerHTML = "no words found";
|
544
|
+
} else {
|
545
|
+
wordCount.innerHTML = `<strong>Found ${newWordsLength} words with letters with ${serachValue.split(
|
546
|
+
""
|
547
|
+
)}</strong>`;
|
548
|
+
}
|
549
|
+
}
|
550
|
+
}
|
551
|
+
|
552
|
+
// sorting by points
|
553
|
+
function sortPointsby(sortValue, data) {
|
554
|
+
main.innerHTML = "";
|
555
|
+
if (sortValue) {
|
556
|
+
let newWordsLength = 0;
|
557
|
+
for (let i = serachValue.length; i >= 1; i--) {
|
558
|
+
var newdata = data.filter((item) => item.length === i);
|
559
|
+
if (newdata.length === 0) {
|
560
|
+
main.innerHTML += "";
|
561
|
+
} else {
|
562
|
+
newWordsLength += newdata.length;
|
563
|
+
var newArray = [];
|
564
|
+
newdata.map((item) => {
|
565
|
+
if (item.length === 1) {
|
566
|
+
ok = false;
|
567
|
+
newWordsLength = newWordsLength - 1;
|
568
|
+
} else {
|
569
|
+
let ScrabbleLetterScore = ScrabbleScore();
|
570
|
+
let points = 0;
|
571
|
+
item = item.toLowerCase();
|
572
|
+
for (let i = 0; i < item.length; i++) {
|
573
|
+
points += ScrabbleLetterScore[item[i]] || 0; // for unknown characters
|
574
|
+
}
|
575
|
+
const value = {
|
576
|
+
words: item,
|
577
|
+
points: points,
|
578
|
+
};
|
579
|
+
newArray.push(value);
|
580
|
+
}
|
581
|
+
});
|
582
|
+
|
583
|
+
newArray.sort(function (a, b) {
|
584
|
+
return b.points - a.points;
|
585
|
+
});
|
586
|
+
const result = newArray.map((item) => {
|
587
|
+
var text1 = serachValue.replace("?", "");
|
588
|
+
var text2 = item.words;
|
589
|
+
var text3 = item.words;
|
590
|
+
function findIndex(str, char) {
|
591
|
+
const strLength = str.length;
|
592
|
+
const indexes = [];
|
593
|
+
let newStr = str;
|
594
|
+
while (newStr && newStr.indexOf(char) > -1) {
|
595
|
+
indexes.push(newStr.indexOf(char) + strLength - newStr.length);
|
596
|
+
newStr = newStr.substring(newStr.indexOf(char) + 1);
|
597
|
+
newStr = newStr.substring(newStr.indexOf(char) + 1);
|
598
|
+
}
|
599
|
+
return indexes;
|
600
|
+
}
|
601
|
+
let chars = text1.split("");
|
602
|
+
let indexs = [];
|
603
|
+
chars.map((i) => {
|
604
|
+
let findIndexes = findIndex(text3, i);
|
605
|
+
if (findIndexes.length > 0) {
|
606
|
+
text3 = text3.split("");
|
607
|
+
text3[findIndexes] = "$";
|
608
|
+
text3 = text3.join("");
|
609
|
+
indexs = [...indexs, ...findIndexes];
|
610
|
+
}
|
611
|
+
});
|
612
|
+
let itemHtml = "";
|
613
|
+
text2.split("").map((itemValue, index) => {
|
614
|
+
let check = indexs.find((i) => i === index);
|
615
|
+
if (check !== undefined) {
|
616
|
+
itemHtml += `${itemValue}`;
|
617
|
+
} else {
|
618
|
+
itemHtml += `<span class='highlight'>${itemValue}</span>`;
|
619
|
+
}
|
620
|
+
});
|
621
|
+
return `<a class="anchor__style" title="Lookup ${item} in Dictionary" target="_blank" href="/word-meaning?search=${item.words}">
|
622
|
+
<li>${itemHtml}
|
623
|
+
<span class="points" value="${item.points}" style="position:relative; top:4px; font-size:12px"> ${item.points}</span>
|
624
|
+
</li></a>`;
|
625
|
+
});
|
626
|
+
|
627
|
+
main.innerHTML += `
|
628
|
+
<div class="allGroupWords wordlistContainer" id="alpha_${i}">
|
629
|
+
<div class="wordListHeading">
|
630
|
+
<h3 class="lead">${i} Letter Words</h3>
|
631
|
+
</div>
|
632
|
+
<div class="wordList">
|
633
|
+
<ul class="ul list-unstyled">
|
634
|
+
${result.join("")}
|
635
|
+
</ul>
|
636
|
+
</div>
|
637
|
+
</div>
|
638
|
+
`;
|
639
|
+
}
|
640
|
+
}
|
641
|
+
}
|
642
|
+
}
|
643
|
+
// sort by aplhabets
|
644
|
+
function sortby(sortBool, data) {
|
645
|
+
if (sortBool) {
|
646
|
+
main.innerHTML = "";
|
647
|
+
data.reverse();
|
648
|
+
let newWordsLength = 0;
|
649
|
+
for (let i = serachValue.length; i >= 1; i--) {
|
650
|
+
var newdata = data.filter((item) => item.length === i);
|
651
|
+
|
652
|
+
if (newdata.length === 0) {
|
653
|
+
main.innerHTML += "";
|
654
|
+
} else {
|
655
|
+
newWordsLength += newdata.length;
|
656
|
+
|
657
|
+
const result = newdata.map((item) => {
|
658
|
+
var text1 = serachValue.replace("?", "");
|
659
|
+
var text2 = item;
|
660
|
+
var text3 = item;
|
661
|
+
let chars = text1.split("");
|
662
|
+
let indexs = [];
|
663
|
+
chars.map((i) => {
|
664
|
+
let findIndexes = findIndex(text3, i);
|
665
|
+
if (findIndexes.length > 0) {
|
666
|
+
text3 = text3.split("");
|
667
|
+
text3[findIndexes] = "$";
|
668
|
+
text3 = text3.join("");
|
669
|
+
indexs = [...indexs, ...findIndexes];
|
670
|
+
}
|
671
|
+
});
|
672
|
+
let itemHtml = "";
|
673
|
+
text2.split("").map((itemValue, index) => {
|
674
|
+
let check = indexs.find((i) => i === index);
|
675
|
+
if (check !== undefined) {
|
676
|
+
itemHtml += `${itemValue}`;
|
677
|
+
} else {
|
678
|
+
itemHtml += `<span class='highlight'>${itemValue}</span>`;
|
679
|
+
}
|
680
|
+
});
|
681
|
+
if (item.length === 1) {
|
682
|
+
ok = false;
|
683
|
+
newWordsLength = newWordsLength - 1;
|
684
|
+
} else {
|
685
|
+
let ScrabbleLetterScore = ScrabbleScore();
|
686
|
+
let sum = 0;
|
687
|
+
item = item.toLowerCase();
|
688
|
+
for (let i = 0; i < item.length; i++) {
|
689
|
+
sum += ScrabbleLetterScore[item[i]] || 0; // for unknown characters
|
690
|
+
}
|
691
|
+
|
692
|
+
return `<a class="anchor__style" title="Lookup ${item} in Dictionary" target="_blank" href="/word-meaning?search=${item.toLowerCase()}">
|
693
|
+
<li>${itemHtml}
|
694
|
+
<span class="points" value="${sum}" style="position:relative; top:4px; font-size:12px"> ${sum}</span>
|
695
|
+
</li></a>`;
|
696
|
+
}
|
697
|
+
});
|
698
|
+
|
699
|
+
main.innerHTML += `
|
700
|
+
<div class="allGroupWords wordlistContainer" id="alpha_${i}">
|
701
|
+
<div class="wordListHeading">
|
702
|
+
<h3 class="lead">${i} Letter Words</h3>
|
703
|
+
</div>
|
704
|
+
<div class="wordList">
|
705
|
+
<ul class="ul list-unstyled">
|
706
|
+
${result.join("")}
|
707
|
+
</ul>
|
708
|
+
</div>
|
709
|
+
</div>
|
710
|
+
`;
|
711
|
+
}
|
712
|
+
}
|
713
|
+
} else {
|
714
|
+
main.innerHTML = "";
|
715
|
+
data.sort();
|
716
|
+
for (let i = serachValue.length; i >= 1; i--) {
|
717
|
+
var newdata = data.filter((item) => item.length === i);
|
718
|
+
if (newdata.length === 0) {
|
719
|
+
main.innerHTML += "";
|
720
|
+
} else {
|
721
|
+
const result = newdata.map((item) => {
|
722
|
+
var text1 = serachValue.replace("?", "");
|
723
|
+
var text2 = item;
|
724
|
+
var text3 = item;
|
725
|
+
let chars = text1.split("");
|
726
|
+
let indexs = [];
|
727
|
+
chars.map((i) => {
|
728
|
+
let findIndexes = findIndex(text3, i);
|
729
|
+
if (findIndexes.length > 0) {
|
730
|
+
text3 = text3.split("");
|
731
|
+
text3[findIndexes] = "$";
|
732
|
+
text3 = text3.join("");
|
733
|
+
indexs = [...indexs, ...findIndexes];
|
734
|
+
}
|
735
|
+
});
|
736
|
+
let itemHtml = "";
|
737
|
+
text2.split("").map((itemValue, index) => {
|
738
|
+
let check = indexs.find((i) => i === index);
|
739
|
+
if (check !== undefined) {
|
740
|
+
itemHtml += `${itemValue}`;
|
741
|
+
} else {
|
742
|
+
itemHtml += `<span class='highlight'>${itemValue}</span>`;
|
743
|
+
}
|
744
|
+
});
|
745
|
+
if (item.length === 1) {
|
746
|
+
ok = false;
|
747
|
+
} else {
|
748
|
+
let ScrabbleLetterScore = ScrabbleScore();
|
749
|
+
let sum = 0;
|
750
|
+
item = item.toLowerCase();
|
751
|
+
for (let i = 0; i < item.length; i++) {
|
752
|
+
sum += ScrabbleLetterScore[item[i]] || 0; // for unknown characters
|
753
|
+
}
|
754
|
+
|
755
|
+
return `<a class="anchor__style" title="Lookup ${item} in Dictionary" target="_blank" href="/word-meaning?search=${item.toLowerCase()}">
|
756
|
+
<li>${itemHtml}
|
757
|
+
<span class="points" value="${sum}" style="position:relative; top:4px; font-size:12px"> ${sum}</span>
|
758
|
+
</li></a>`;
|
759
|
+
}
|
760
|
+
});
|
761
|
+
main.innerHTML += `
|
762
|
+
<div class="allGroupWords wordlistContainer" id="alpha_${i}">
|
763
|
+
<div class="wordListHeading">
|
764
|
+
<h3 class="lead">${i} Letter Words</h3>
|
765
|
+
</div>
|
766
|
+
<div class="wordList">
|
767
|
+
<ul class="ul list-unstyled">
|
768
|
+
${result.join("")}
|
769
|
+
</ul>
|
770
|
+
</div>
|
771
|
+
</div>
|
772
|
+
`;
|
773
|
+
}
|
774
|
+
}
|
775
|
+
}
|
776
|
+
}
|
777
|
+
|
778
|
+
// Scrabble Point Array
|
779
|
+
const ScrabbleScore = () => {
|
780
|
+
let twl06_sowpods = {
|
781
|
+
a: 1,
|
782
|
+
e: 1,
|
783
|
+
i: 1,
|
784
|
+
o: 1,
|
785
|
+
u: 1,
|
786
|
+
l: 1,
|
787
|
+
n: 1,
|
788
|
+
r: 1,
|
789
|
+
s: 1,
|
790
|
+
t: 1,
|
791
|
+
d: 2,
|
792
|
+
g: 2,
|
793
|
+
b: 3,
|
794
|
+
c: 3,
|
795
|
+
m: 3,
|
796
|
+
p: 3,
|
797
|
+
f: 4,
|
798
|
+
h: 4,
|
799
|
+
v: 4,
|
800
|
+
w: 4,
|
801
|
+
y: 4,
|
802
|
+
k: 5,
|
803
|
+
j: 8,
|
804
|
+
x: 8,
|
805
|
+
q: 10,
|
806
|
+
z: 10,
|
807
|
+
};
|
808
|
+
|
809
|
+
let wwfScore = {
|
810
|
+
a: 1,
|
811
|
+
b: 4,
|
812
|
+
c: 4,
|
813
|
+
d: 2,
|
814
|
+
e: 1,
|
815
|
+
f: 4,
|
816
|
+
g: 3,
|
817
|
+
h: 3,
|
818
|
+
i: 1,
|
819
|
+
j: 10,
|
820
|
+
k: 5,
|
821
|
+
l: 2,
|
822
|
+
m: 4,
|
823
|
+
n: 2,
|
824
|
+
o: 1,
|
825
|
+
p: 4,
|
826
|
+
q: 10,
|
827
|
+
r: 1,
|
828
|
+
s: 1,
|
829
|
+
t: 1,
|
830
|
+
u: 2,
|
831
|
+
v: 5,
|
832
|
+
w: 4,
|
833
|
+
x: 8,
|
834
|
+
y: 3,
|
835
|
+
z: 10,
|
836
|
+
};
|
837
|
+
|
838
|
+
if (dictonary === "wwf") {
|
839
|
+
return wwfScore;
|
840
|
+
} else {
|
841
|
+
return twl06_sowpods;
|
842
|
+
}
|
843
|
+
};
|
844
|
+
|
845
|
+
// handling of filter on scroll
|
846
|
+
window.onscroll = function () {
|
847
|
+
var section = document.querySelectorAll(".wordlistContainer");
|
848
|
+
let new_sections = {};
|
849
|
+
Array.prototype.forEach.call(section, function (e) {
|
850
|
+
if (document.body.clientWidth > 991) {
|
851
|
+
new_sections[e.id] = e.offsetTop - 10;
|
852
|
+
} else {
|
853
|
+
new_sections[e.id] = e.offsetTop - 10;
|
854
|
+
}
|
855
|
+
});
|
856
|
+
var scrollPosition =
|
857
|
+
document.documentElement.scrollTop || document.body.scrollTop;
|
858
|
+
for (i in new_sections) {
|
859
|
+
let sort_val = document.querySelector(".sort-select").value;
|
860
|
+
if (
|
861
|
+
i.split("_")[0] == sort_val &&
|
862
|
+
new_sections[i] &&
|
863
|
+
new_sections[i] <= scrollPosition
|
864
|
+
) {
|
865
|
+
// document.querySelector(".active-tab").classList.remove("active-tab");
|
866
|
+
// var active_now = document.querySelector("#Tab_" + i.split("_")[1]);
|
867
|
+
// active_now.classList.add("active-tab");
|
868
|
+
// active_now.scrollIntoView({ block: "nearest" });
|
869
|
+
}
|
870
|
+
}
|
871
|
+
};
|
872
|
+
|
873
|
+
// Add Filtering
|
874
|
+
let sections = {};
|
875
|
+
function Filtering(id) {
|
876
|
+
id = lengthSelect.value
|
877
|
+
|
878
|
+
let tabs = document.getElementsByClassName("tab_link");
|
879
|
+
tabs[0] ? tabs[0].classList.add("active-tab") : "";
|
880
|
+
|
881
|
+
Array.from(tabs).map((item) => {
|
882
|
+
item.classList.remove("active-tab");
|
883
|
+
});
|
884
|
+
main.innerHTML += ``;
|
885
|
+
let activeLetter = event.target;
|
886
|
+
activeLetter.classList.add("active-tab");
|
887
|
+
|
888
|
+
var section = document.querySelectorAll(".allGroupWords");
|
889
|
+
var sort_val = "alpha";
|
890
|
+
Array.prototype.forEach.call(section, function (e) {
|
891
|
+
if (document.body.clientWidth > 991) {
|
892
|
+
sections[e.id] = e.offsetTop - 10;
|
893
|
+
} else {
|
894
|
+
sections[e.id] = e.offsetTop - 10;
|
895
|
+
}
|
896
|
+
});
|
897
|
+
document.documentElement.scrollTop = sections[sort_val + "_" + id] + 5;
|
898
|
+
|
899
|
+
setTimeout(() => {
|
900
|
+
document.documentElement.scrollTop = sections[sort_val + "_" + id] + 5;
|
901
|
+
}, 150);
|
902
|
+
}
|
903
|
+
|
904
|
+
// next && previous functionality
|
905
|
+
let prev = document.getElementById("prev");
|
906
|
+
let next = document.getElementById("next");
|
907
|
+
|
908
|
+
if (prev) {
|
909
|
+
prev.onclick = scroll_Right;
|
910
|
+
}
|
911
|
+
if (next) {
|
912
|
+
next.onclick = scroll_Left;
|
913
|
+
}
|
914
|
+
window.addEventListener("resize", function () {
|
915
|
+
scroll_visible();
|
916
|
+
});
|
917
|
+
window.addEventListener("scroll", function () {
|
918
|
+
scroll_visible();
|
919
|
+
});
|
920
|
+
function scroll_visible() {
|
921
|
+
let tab_container = document.querySelector("#tab-container");
|
922
|
+
if (tab_container) {
|
923
|
+
if (tab_container.clientWidth === tab_container.scrollWidth) {
|
924
|
+
prev.style.display = "none";
|
925
|
+
next.style.display = "none";
|
926
|
+
} else {
|
927
|
+
prev.style.display = "block";
|
928
|
+
next.style.display = "block";
|
929
|
+
}
|
930
|
+
}
|
931
|
+
}
|
932
|
+
scroll_visible();
|
933
|
+
|
934
|
+
function scroll_Left() {
|
935
|
+
tab_container.scrollLeft += 130;
|
936
|
+
}
|
937
|
+
function scroll_Right() {
|
938
|
+
tab_container.scrollLeft -= 130;
|
939
|
+
}
|
940
|
+
function findIndex(str, char) {
|
941
|
+
const strLength = str.length;
|
942
|
+
const indexes = [];
|
943
|
+
let newStr = str;
|
944
|
+
|
945
|
+
while (newStr && newStr.indexOf(char) > -1) {
|
946
|
+
indexes.push(newStr.indexOf(char) + strLength - newStr.length);
|
947
|
+
newStr = newStr.substring(newStr.indexOf(char) + 5);
|
948
|
+
newStr = newStr.substring(newStr.indexOf(char) + 5);
|
949
|
+
}
|
950
|
+
|
951
|
+
return indexes;
|
952
|
+
}
|