word-games-theme 2.1.7 → 2.1.8

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