word-games-theme 3.1.0 → 3.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,13 +7,37 @@ let endsWith = document.getElementById("endsWith");
7
7
  let exculdeWith = document.getElementById("exculdeWith");
8
8
  let inculdeWith = document.getElementById("inculdeWith");
9
9
  let wordLength = document.getElementById("wordLength");
10
-
11
- const serachSection = document.querySelector(".serachSection");
10
+ let textBoxes = document.querySelectorAll('.textBoxes');
11
+ let filterInputs = document.querySelectorAll('.filter_val');
12
+ let formElement = document.querySelector("#form");
13
+ let wordCount = document.querySelector(".wordCount");
14
+ let main = document.querySelector(".main");
15
+ let errorMsg = document.querySelector(".errorMsg");
16
+ let serachBtn = document.querySelector(".serachBtn")
17
+ let tab_container = document.querySelector(".tab_container");
18
+ let lengthSelect = document.querySelector(".length-select");
19
+ let getScript = document.currentScript;
20
+ let siteUrl = getScript.dataset.url;
21
+ let serachSection = document.querySelector(".serachSection");
12
22
  let rangeOfBlankTile = serachSection.dataset.range;
23
+ let letterLen = serachSection.dataset.letter
24
+ let ablank = serachSection.dataset.ablank
25
+ let featureContainer = document.querySelector("#featureContainer")
26
+ let howContainer = document.querySelector("#howContainer")
27
+ let faqsContainer = document.querySelector("#faqsContainer")
28
+ let infographicsContainer = document.querySelector("#infographicsContainer")
29
+ let theSelect = document.getElementById("select_dropDown");
30
+ let sortingFilter = document.querySelector("#select_dropDown");
31
+ let sortup = document.querySelector(".sortup-icon");
32
+ let bool = false;
33
+ let authorsLists = document.querySelector(".authors-list")
34
+ let searchBtnContainer = document.querySelector(".search-btn-container")
35
+ let home_page_search_result
36
+ let homePageSearchResult
37
+ let sortValue;
38
+ let sortBool = false;
39
+ let ok = true;
13
40
 
14
-
15
-
16
- const textBoxes = document.querySelectorAll('.textBoxes');
17
41
  textBoxes.forEach(txtBox => {
18
42
  txtBox.addEventListener("input", () => {
19
43
  if (txtBox.value !== '') {
@@ -27,10 +51,6 @@ textBoxes.forEach(txtBox => {
27
51
  txtBox.classList.remove('blinkBoxShadow');
28
52
  });
29
53
  });
30
-
31
-
32
-
33
- // // when typing on input
34
54
  txtBox.addEventListener('input', (e) => {
35
55
  if (e.target.value === "") {
36
56
  letterCloseButton.style.display = "none"
@@ -54,8 +74,6 @@ letterCloseButton.addEventListener("click", () => {
54
74
  txtBox.value = ""
55
75
  letterCloseButton.style.display = "none"
56
76
  })
57
- //tooltips for advanced filter
58
- const filterInputs = document.querySelectorAll('.filter_val');
59
77
  Array.from(filterInputs).forEach((item) => {
60
78
  item.addEventListener("input", (e) => {
61
79
  const inputValue = e.target.value;
@@ -93,6 +111,47 @@ Array.from(filterInputs).forEach((item) => {
93
111
  })
94
112
  })
95
113
 
114
+ if (ablank) {
115
+ if (!serachValue.includes("?")) {
116
+ if (serachValue.length <= letterLen || serachValue.length >= letterLen) {
117
+ serachValue = serachValue + '?'
118
+ txtBox.value = serachValue
119
+ }
120
+ }
121
+ }
122
+ sortup.addEventListener("click", () => {
123
+ if (bool) {
124
+ theSelect.size = 0;
125
+ bool = false;
126
+ theSelect.style.display = "none";
127
+ } else {
128
+ bool = true;
129
+ theSelect.size = 3;
130
+ theSelect.style.display = "block";
131
+ }
132
+ });
133
+
134
+ const getDiff = (text1, text2) => {
135
+ var diffRange = [];
136
+ var currentRange = undefined;
137
+ for (var i = 0; i < text1.length; i++) {
138
+ if (text1[i] != text2[i]) {
139
+ if (currentRange == undefined) {
140
+ currentRange = [i];
141
+ }
142
+ }
143
+ if (currentRange != undefined && text1[i] == text2[i]) {
144
+ currentRange.push(i);
145
+ diffRange.push(currentRange);
146
+ currentRange = undefined;
147
+ }
148
+ }
149
+ if (currentRange != undefined) {
150
+ currentRange.push(i);
151
+ diffRange.push(currentRange);
152
+ }
153
+ return diffRange;
154
+ };
96
155
 
97
156
  const loadResource = (FILE_URL, data = {}, async = true, type = "text/javascript") => {
98
157
  return new Promise((resolve, reject) => {
@@ -141,14 +200,65 @@ const loadResource = (FILE_URL, data = {}, async = true, type = "text/javascript
141
200
  }
142
201
  });
143
202
  };
144
- const formElement = document.querySelector("#form");
145
- formElement.addEventListener("submit", function (e) {
203
+ function sendPageViewEvent() {
204
+ gtag('event', 'page_view', {
205
+ page_location: window.location.pathname + location.search
206
+ });
207
+ }
208
+
209
+ function logSubmit(e) {
146
210
  e.preventDefault();
147
211
  if (txtBox.value != "" || startsWith.value != "" || endsWith.value != "" || mustInclude.value != "" || exculdeWith.value != "" || inculdeWith.value != "" || wordLength.value != "") {
212
+ if (featureContainer) {
213
+ featureContainer.remove()
214
+ }
215
+ if (howContainer) {
216
+ howContainer.remove()
217
+ }
218
+ if (faqsContainer) {
219
+ faqsContainer.remove()
220
+ }
221
+ if (infographicsContainer) {
222
+ infographicsContainer.remove()
223
+ }
224
+ if (authorsLists) {
225
+ authorsLists.remove()
226
+ }
227
+ serachBtn.style.background = 'url(/assets/images/spinner.gif) no-repeat center center';
228
+ main.innerHTML = `<main class="placeholder-loader">
229
+ <ul class="o-vertical-spacing o-vertical-spacing--l">
230
+ <li class="blog-post o-media">
231
+ <div class="o-media__body">
232
+ <div class="o-vertical-spacing">
233
+ <p class="m-0">
234
+ <span class="skeleton-box" style="width:40%;"></span>
235
+ </p>
236
+ </div>
237
+ </div>
238
+ </li>
239
+ <li class="blog-post o-media">
240
+ <div class="o-media__figure">
241
+ <span class="skeleton-box" style="width:900px;height:140px;"></span>
242
+ </div>
243
+ </li>
244
+ <li class="blog-post o-media">
245
+ <div class="o-media__figure">
246
+ <span class="skeleton-box" style="width:900px;height:140px;"></span>
247
+ </div>
248
+ </li>
249
+ <li class="blog-post o-media">
250
+ <div class="o-media__figure">
251
+ <span class="skeleton-box" style="width:900px;height:140px;"></span>
252
+ </div>
253
+ </li>
254
+ </ul>
255
+ </main>`;
256
+
257
+
148
258
  let quesMark = "?";
149
259
  if (rangeOfBlankTile) {
150
260
  if (!txtBox.value.includes("?")) {
151
- txtBox.value = txtBox.value + quesMark.repeat(rangeOfBlankTile); //
261
+ txtBox.value = txtBox.value + quesMark.repeat(rangeOfBlankTile);
152
262
  txtBox.value = txtBox.value;
153
263
  }
154
264
  }
@@ -204,33 +314,19 @@ formElement.addEventListener("submit", function (e) {
204
314
  lengthValue = params.get("length");
205
315
  dictonary = params.get("dictionary");
206
316
 
207
- gtag("event", "page_view", {
208
- page_location: window.location.pathname + location.search,
209
- });
317
+ getData(txtBox.value.toLowerCase())
318
+
319
+ setTimeout(sendPageViewEvent, 0);
210
320
  }
211
321
  const paramName = 'search';
212
322
  if (new URLSearchParams(window.location.search).has(paramName)) {
213
- const additionalData = {
214
- url: "{{site.url}}",
215
- range: "{{page.blanktilerange}}"
216
- }
323
+ const additionalData = {}
217
324
  var loadJs = document.querySelector(".loaded-js");
218
325
  if (loadJs == null) {
219
326
  loadResource("/assets/css/wordfinder-result.css", additionalData, true, "text/css")
220
327
  .then((data) => {
221
328
  console.log("CSS loaded:", data);
222
329
  })
223
- .then(() => {
224
- // Load the JavaScript file after the CSS file has loaded
225
- loadResource("/assets/js/wordfinder.js", additionalData, true, "text/javascript")
226
- .then((data) => {
227
- console.log("JavaScript loaded:", data);
228
- getData(txtBox.value.toLowerCase());
229
- })
230
- .catch((error) => {
231
- console.error("Error loading JavaScript:", error);
232
- });
233
- })
234
330
  .catch((error) => {
235
331
  console.error("Error loading CSS:", error);
236
332
  });
@@ -239,36 +335,442 @@ formElement.addEventListener("submit", function (e) {
239
335
  } else {
240
336
  console.log("Please Enter Valid Letters.");
241
337
  }
338
+ }
339
+ let selectedDictionary = document.querySelector(".select_dropDown2");
340
+ selectedDictionary.addEventListener("change", (e) => {
341
+ logSubmit(e);
242
342
  });
243
- // Now you can use the loadScript function with additional data
244
- function checkQueryParam() {
245
- const urlParams = new URLSearchParams(window.location.search);
246
- const paramName = 'search';
247
- if (urlParams.has(paramName)) {
248
- const additionalData = {
249
- url: "{{site.url}}",
250
- range: "{{page.blanktilerange}}"
251
- };
252
- loadResource("/assets/css/wordfinder-result.css", additionalData, true, "text/css")
253
- .then((data) => {
254
- console.log("CSS loaded:", data);
255
- })
256
- .then(() => {
257
- // Load the JavaScript file after the CSS file has loaded
258
- loadResource("/assets/js/wordfinder.js", additionalData, true, "text/javascript")
259
- .then((data) => {
260
- console.log("JavaScript loaded:", data);
261
- getData(txtBox.value.toLowerCase());
262
- })
263
- .catch((error) => {
264
- console.error("Error loading JavaScript:", error);
265
- });
266
- })
267
- .catch((error) => {
268
- console.error("Error loading CSS:", error);
269
- });
343
+ formElement.addEventListener("submit", logSubmit);
344
+ sortingFilter.addEventListener("change", logSubmit);
345
+
346
+ // getWords define
347
+ const worker = new Worker('/assets/js/wordfinder-worker.js');
348
+ const getData = async (serachValue) => {
349
+ try {
350
+ let selectedDictionary = document.querySelector(".select_dropDown2").value;
351
+
352
+ if (letterLen) {
353
+ home_page_search_result = document.querySelector("#home_page_search_result")
354
+ homePageSearchResult = `/?search=${serachValue}&dictionary=Dictionary&prefix=&contains=&suffix=&exculde=&inculde=&length=`;
355
+ }
356
+ document.querySelector(".main-header").style.height = "auto"
357
+ document.querySelector(".main-header").style.background = "#fff"
358
+ document.querySelector(".heading-h2").style.display = "none"
359
+ document.querySelector(".sortingFilters").style.display = "none"
360
+
361
+ errorMsg.innerHTML = "";
362
+ wordCount.innerHTML = "";
363
+
364
+ worker.postMessage({
365
+ type: "api",
366
+ serachValue: serachValue,
367
+ selectedDictionary: selectedDictionary,
368
+ endpoint: `/.netlify/functions`
369
+ });
370
+ worker.onmessage = (event) => {
371
+ main.innerHTML = "";
372
+ serachBtn.style.background = 'url(/assets/images/search.svg) no-repeat center center';
373
+ getWords(event.data.data);
374
+ }
375
+ } catch (error) {
376
+ console.log(error);
377
+ }
378
+ };
379
+
380
+ let newUrl = window.location.href;
381
+ if (newUrl.includes("?")) {
382
+ const params = new URLSearchParams(window.location.search);
383
+ let serachValue = params.get("search").toLowerCase();
384
+ let prefixValue = params.get("prefix");
385
+ let containsValue = params.get("contains");
386
+ let suffixValue = params.get("suffix");
387
+ let exculdeValue = params.get("exclude");
388
+ let includeValue = params.get("include");
389
+ let lengthValue = params.get("length");
390
+ let dictonary = params.get("dictionary");
391
+
392
+ txtBox.value = serachValue
393
+ startsWith.value = prefixValue
394
+ mustInclude.value = containsValue
395
+ endsWith.value = suffixValue
396
+ exculdeWith.value = exculdeValue
397
+ inculdeWith.value = includeValue
398
+ wordLength.value = lengthValue
399
+ document.querySelector(".select_dropDown2").value = dictonary
400
+ logSubmit(new Event('submit'))
401
+ }
402
+ let previousDataIndex = null
403
+ let previousID = null;
404
+ let storepreviousIndex = []
405
+ let moreData = []
406
+ let data_index = 25;
407
+ function getWords(data) {
408
+ data_index = 25
409
+ moreData = []
410
+ storepreviousIndex = []
411
+ main.innerHTML = "";
412
+ lengthSelect.innerHTML = ""
413
+ if (typeof data === "string") {
414
+ errorMsg.innerHTML = "no words found";
415
+ } else {
416
+ worker.postMessage({
417
+ type: 'filterwords',
418
+ data: data,
419
+ serachValue: txtBox.value.toLowerCase(),
420
+ prefixValue: startsWith.value,
421
+ containsValue: mustInclude.value,
422
+ suffixValue: endsWith.value,
423
+ exculdeValue: exculdeWith.value,
424
+ includeValue: inculdeWith.value,
425
+ lengthValue: wordLength.value,
426
+ sortingFilter: sortingFilter.selectedIndex,
427
+ dictonary: document.querySelector(".select_dropDown2").value
428
+ });
429
+ worker.onmessage = (event) => {
430
+ if (event.data.type === "filterwords") {
431
+ errorMsg.innerHTML = ""
432
+ document.querySelector(".sortingFilters").style.display = "flex"
433
+ let { prefixValue, containsValue, suffixValue, exculdeValue, includeValue, lengthValue, newdata, i, newWordsLength, result } = event.data
434
+ moreData.push(newdata)
435
+ if (prefixValue) {
436
+ startsWith.nextElementSibling.querySelector("img").src = "/assets/images/close-btn.svg"
437
+ startsWith.classList.add("tick");
438
+ startsWith.value = startsWith.value;
439
+ }
440
+ if (suffixValue) {
441
+ endsWith.nextElementSibling.querySelector("img").src = "/assets/images/close-btn.svg"
442
+ endsWith.classList.add("tick");
443
+ endsWith.value = endsWith.value;
444
+ }
445
+ if (containsValue) {
446
+ mustInclude.nextElementSibling.querySelector("img").src = "/assets/images/close-btn.svg"
447
+ mustInclude.classList.add("tick");
448
+ mustInclude.value = mustInclude.value;
449
+ }
450
+ if (lengthValue) {
451
+ wordLength.nextElementSibling.querySelector("img").src = "/assets/images/close-btn.svg"
452
+ wordLength.classList.add("tick");
453
+ wordLength.value = wordLength.value;
454
+ }
455
+ if (exculdeValue) {
456
+ exculdeWith.nextElementSibling.querySelector("img").src = "/assets/images/close-btn.svg"
457
+ exculdeWith.classList.add("tick");
458
+ exculdeWith.value = exculdeWith.value;
459
+ }
460
+ if (includeValue) {
461
+ inculdeWith.nextElementSibling.querySelector("img").src = "/assets/images/close-btn.svg"
462
+ inculdeWith.classList.add("tick");
463
+ inculdeWith.value = inculdeWith.value;
464
+ }
465
+ if (newdata.length === 0) {
466
+ main.innerHTML += "";
467
+ } else {
468
+ if (result[0] !== undefined) {
469
+ if (wordLength.value) {
470
+ lengthSelect.style.display = "none"
471
+ } else {
472
+ var option = document.createElement("option");
473
+ option.text = `${i} Letter`;
474
+ option.value = i;
475
+ lengthSelect.setAttribute("onchange", `Filtering(${i})`)
476
+ lengthSelect.add(option);
477
+ lengthSelect.style.display = "block"
478
+ }
479
+ if (letterLen) {
480
+ home_page_search_result.href = homePageSearchResult
481
+ home_page_search_result.innerHTML = `See words of any length with letters ${serachValue.split("")}`
482
+ }
483
+
484
+ main.innerHTML += `
485
+ <div class="allGroupWords wordlistContainer" id="alpha_${i}">
486
+ <h3 class="wordListHeading lead">${i} Letter Words</h3>
487
+ <div class="wordList">${result.join("")}</div>
488
+ <div class="w-100 text-center btn-container">
489
+ <button
490
+ style="background: black;
491
+ padding: 1rem 2rem;
492
+ border-radius: 50px;
493
+ color: #fff;
494
+ font-size: 15px;
495
+ border: none;"
496
+ onclick="showMoreWords(this)" type="button" class="my-4 showmore_btn" id="${i}">More Words</button>
497
+ </div>
498
+
499
+ </div>`
500
+ showMoreLimit()
501
+
502
+ }
503
+ }
504
+ if (newWordsLength === 0) {
505
+ console.log(newdata);
506
+ errorMsg.innerHTML = "No Words Found";
507
+ document.querySelector(".sortingFilters").style.display = "none"
508
+ } else {
509
+ if (txtBox.value) {
510
+ wordCount.innerHTML = `<strong>Found ${newWordsLength} words with letters with ${txtBox.value.split("")}</strong>`;
511
+ } else {
512
+ let startwithMsg = ""
513
+ let endwithMsg = ""
514
+ let containsMsg = ""
515
+ let lengthMsg = ""
516
+ let inputVal = ""
517
+ if (txtBox.value) {
518
+ inputVal = `${input.value.split("")} `
519
+ }
520
+ if (prefixValue) {
521
+ startwithMsg = `starting with ${prefixValue.split("")}`
522
+ }
523
+ if (suffixValue) {
524
+ endwithMsg = `ending with ${suffixValue.split("")} `
525
+ }
526
+ if (containsValue) {
527
+ containsMsg = `containing with ${containsValue.split("")} `
528
+ }
529
+ if (lengthValue) {
530
+ lengthMsg = `with ${lengthValue} letter words`
531
+ }
532
+ let msg = `<strong> Found ${newWordsLength} words with letters
533
+ ${lengthMsg} ${inputVal} ${startwithMsg} ${endwithMsg} ${containsMsg} </strong>`
534
+
535
+ wordCount.innerHTML = `${msg} `
536
+ }
537
+ }
538
+ }
539
+ }
540
+ }
541
+ }
542
+ async function getMoreWords() {
543
+ let flattenedArray = moreData.flat();
544
+ let uniqueArray = [...new Set(flattenedArray)];;
545
+ return uniqueArray
546
+ }
547
+ async function showMoreWords(e) {
548
+ try {
549
+ let showmore = e.parentElement.children[0];
550
+ let id = showmore.id;
551
+
552
+ if (previousID !== null && parseInt(previousID) !== parseInt(id)) {
553
+ data_index = 25
554
+ const filteredIndexes = storepreviousIndex.filter(item => item.id === id);
555
+ if (filteredIndexes.length > 0) {
556
+ const lastItem = filteredIndexes[filteredIndexes.length - 1];
557
+ data_index = lastItem.data_index + 25;
558
+ lastItem.data_index = data_index;
559
+ }
560
+ }
561
+ previousID = id;
562
+ storepreviousIndex.push({
563
+ data_index,
564
+ id
565
+ })
566
+ console.log("Current data_index:", data_index);
567
+
568
+ document.getElementById(id).innerHTML = `Loading...`;
569
+ let content_area = document.getElementById("alpha_" + id).getElementsByClassName("wordList")[0];
570
+ const result = await getMoreWords();
571
+ let full_words = result.filter((item) => item.length === Number(id));
572
+
573
+ if (data_index < full_words.length) {
574
+ for (let d = data_index; d < data_index + 25; d++) {
575
+ if (full_words[d] != undefined) {
576
+ let itemHtml = "";
577
+ if (serachValue) {
578
+ var text1 = serachValue.replace("?", "");
579
+ var text2 = full_words[d];
580
+ var text3 = full_words[d];
581
+ let chars = text1.split("");
582
+ let indexs = [];
583
+ chars.map((i) => {
584
+ let findIndexes = findIndex(text3, i);
585
+ if (findIndexes.length > 0) {
586
+ text3 = text3.split("");
587
+ text3[findIndexes] = "$";
588
+ text3 = text3.join("");
589
+ indexs = [...indexs, ...findIndexes];
590
+ }
591
+ });
592
+ text2.split("").map((itemValue, index) => {
593
+ let check = indexs.find((i) => i === index);
594
+ if (check !== undefined) {
595
+ itemHtml += `${itemValue}`;
596
+ } else {
597
+ itemHtml += `<span class='highlight'>${itemValue}</span>`;
598
+ }
599
+ });
600
+ } else {
601
+ itemHtml = full_words[d]
602
+ }
603
+ let ScrabbleLetterScore = ScrabbleScore();
604
+ let points = 0;
605
+ full_words[d] = full_words[d].toLowerCase();
606
+ for (let i = 0; i < full_words[d].length; i++) {
607
+ points += ScrabbleLetterScore[full_words[d][i]] || 0; // for unknown characters
608
+ }
609
+
610
+ let span = document.createElement("span");
611
+ span.setAttribute("class", "points");
612
+ span.setAttribute("value", `${points}`);
613
+ span.innerHTML = `${points}`;
614
+
615
+ let a = document.createElement("a");
616
+ a.setAttribute("class", "anchor__style");
617
+ a.setAttribute("target", "_blank");
618
+ a.setAttribute("href", "/word-meaning?search=" + full_words[d].replace(/<\/?[^>]+>/gi, ''));
619
+ a.setAttribute("data-original-title", `Lookup ${full_words[d].replace(/<\/?[^>]+>/gi, '')} in Dictionary`)
620
+ a.innerHTML = ` ${itemHtml} `;
621
+ a.appendChild(span)
622
+ content_area.appendChild(a);
623
+ }
624
+ }
625
+ document.getElementById(id).innerHTML = `More Words`;
626
+ data_index += 25;
627
+ } else {
628
+ document.getElementById(id).style.display = "none";
629
+ }
630
+ } catch (error) {
631
+ console.error("Error fetching or processing data:", error);
270
632
  }
271
633
  }
272
- checkQueryParam();
634
+ const ScrabbleScore = (dictonary) => {
635
+ let twl06_sowpods = {
636
+ a: 1,
637
+ e: 1,
638
+ i: 1,
639
+ o: 1,
640
+ u: 1,
641
+ l: 1,
642
+ n: 1,
643
+ r: 1,
644
+ s: 1,
645
+ t: 1,
646
+ d: 2,
647
+ g: 2,
648
+ b: 3,
649
+ c: 3,
650
+ m: 3,
651
+ p: 3,
652
+ f: 4,
653
+ h: 4,
654
+ v: 4,
655
+ w: 4,
656
+ y: 4,
657
+ k: 5,
658
+ j: 8,
659
+ x: 8,
660
+ q: 10,
661
+ z: 10,
662
+ };
663
+ let wwfScore = {
664
+ a: 1,
665
+ b: 4,
666
+ c: 4,
667
+ d: 2,
668
+ e: 1,
669
+ f: 4,
670
+ g: 3,
671
+ h: 3,
672
+ i: 1,
673
+ j: 10,
674
+ k: 5,
675
+ l: 2,
676
+ m: 4,
677
+ n: 2,
678
+ o: 1,
679
+ p: 4,
680
+ q: 10,
681
+ r: 1,
682
+ s: 1,
683
+ t: 1,
684
+ u: 2,
685
+ v: 5,
686
+ w: 4,
687
+ x: 8,
688
+ y: 3,
689
+ z: 10,
690
+ };
273
691
 
692
+ if (dictonary === "wwf") {
693
+ return wwfScore;
694
+ } else {
695
+ return twl06_sowpods;
696
+ }
697
+ };
698
+ function showMoreLimit() {
699
+ let tableFooter = document.querySelectorAll(".btn-container")
700
+ let showmore = document.querySelectorAll(".showmore_btn");
701
+ for (let i = 0; i < showmore.length; i++) {
702
+ let data_of_button = document.getElementById("alpha_" + showmore[i].getAttribute("id"));
703
+ let final_data = data_of_button.getElementsByClassName("anchor__style");
704
+ if (final_data.length < 25) {
705
+ tableFooter[i].style.display = "none";
706
+ }
707
+ }
708
+ }
709
+ window.onscroll = function () {
710
+ var section = document.querySelectorAll(".wordlistContainer");
711
+ let new_sections = {};
712
+ Array.prototype.forEach.call(section, function (e) {
713
+ if (document.body.clientWidth > 991) {
714
+ new_sections[e.id] = e.offsetTop - 10;
715
+ } else {
716
+ new_sections[e.id] = e.offsetTop - 10;
717
+ }
718
+ });
719
+ var scrollPosition =
720
+ document.documentElement.scrollTop || document.body.scrollTop;
721
+ for (i in new_sections) {
722
+ let sort_val = document.querySelector(".sort-select").value;
723
+ if (
724
+ i.split("_")[0] == sort_val &&
725
+ new_sections[i] &&
726
+ new_sections[i] <= scrollPosition
727
+ ) {
728
+ // document.querySelector(".active-tab").classList.remove("active-tab");
729
+ // var active_now = document.querySelector("#Tab_" + i.split("_")[1]);
730
+ // active_now.classList.add("active-tab");
731
+ // active_now.scrollIntoView({ block: "nearest" });
732
+ }
733
+ }
734
+ };
735
+ let sections = {};
736
+ function Filtering(id) {
737
+ id = lengthSelect.value
738
+
739
+ let tabs = document.getElementsByClassName("tab_link");
740
+ tabs[0] ? tabs[0].classList.add("active-tab") : "";
741
+
742
+ Array.from(tabs).map((item) => {
743
+ item.classList.remove("active-tab");
744
+ });
745
+ main.innerHTML += ``;
746
+ let activeLetter = event.target;
747
+ activeLetter.classList.add("active-tab");
748
+
749
+ var section = document.querySelectorAll(".allGroupWords");
750
+ var sort_val = "alpha";
751
+ Array.prototype.forEach.call(section, function (e) {
752
+ if (document.body.clientWidth > 991) {
753
+ sections[e.id] = e.offsetTop - 10;
754
+ } else {
755
+ sections[e.id] = e.offsetTop - 10;
756
+ }
757
+ });
758
+ document.documentElement.scrollTop = sections[sort_val + "_" + id] + 5;
759
+
760
+ setTimeout(() => {
761
+ document.documentElement.scrollTop = sections[sort_val + "_" + id] + 5;
762
+ }, 150);
763
+ }
764
+ function findIndex(str, char) {
765
+ const strLength = str.length;
766
+ const indexes = [];
767
+ let newStr = str;
768
+
769
+ while (newStr && newStr.indexOf(char) > -1) {
770
+ indexes.push(newStr.indexOf(char) + strLength - newStr.length);
771
+ newStr = newStr.substring(newStr.indexOf(char) + 5);
772
+ newStr = newStr.substring(newStr.indexOf(char) + 5);
773
+ }
274
774
 
775
+ return indexes;
776
+ }