word-games-theme 2.7.1 → 2.7.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -229,7 +229,7 @@ header {
229
229
 
230
230
  .footer-bottom .language-drop-down-item {
231
231
  width: 50%;
232
- padding: 10px 12px 1px 1px;
232
+ padding: 1rem;
233
233
  text-align: center;
234
234
  font-size: 15px;
235
235
  margin-bottom: 0;
@@ -183,7 +183,7 @@ const getData = async (serachValue) => {
183
183
  </div>`;
184
184
  /// loader
185
185
  const response = await fetch(
186
- `http://127.0.0.1:9000/getWords?name=${serachValue}&selecteddictionary=${selectedDictionary}`
186
+ `/.netlify/functions/getWords?name=${serachValue}&selecteddictionary=${selectedDictionary}`
187
187
  );
188
188
  const data = await response.json();
189
189
  main.innerHTML = "";
@@ -57,16 +57,20 @@ Array.from(filterInputs).forEach((item) => {
57
57
  imgElement.src = "/assets/images/close-btn.svg"
58
58
  tooltipElement.style.setProperty('--tooltip-padding', '0');
59
59
  tooltipElement.style.setProperty('--tooltip-border-style', 'none');
60
- }
61
- item.nextElementSibling.addEventListener("click", () => {
62
- e.target.value = ""
63
- imgElement.src = "/assets/images/questionmark.svg"
64
- setTimeout(() => {
65
- item.nextElementSibling.setAttribute("data-tip", item.nextElementSibling.id)
66
- }, 100);
67
- tooltipElement.style.setProperty('--tooltip-padding', '0.5rem');
68
- tooltipElement.style.setProperty('--tooltip-border-style', 'soild');
69
- })
60
+ }
61
+ })
62
+
63
+ item.nextElementSibling.addEventListener("click", () => {
64
+ const parentElement = item.parentElement;
65
+ const imgElement = parentElement.querySelector('img');
66
+ const tooltipElement = parentElement.querySelector('.filter-tooltip');
67
+ item.value = ""
68
+ imgElement.src = "/assets/images/questionmark.svg"
69
+ setTimeout(() => {
70
+ item.nextElementSibling.setAttribute("data-tip", item.nextElementSibling.id)
71
+ }, 100);
72
+ tooltipElement.style.setProperty('--tooltip-padding', '0.5rem');
73
+ tooltipElement.style.setProperty('--tooltip-border-style', 'soild');
70
74
  })
71
75
  })
72
76
 
@@ -78,6 +78,7 @@ const getData = async (serachValue) => {
78
78
  try {
79
79
  document.querySelector(".main-header").style.background = "#fff"
80
80
  document.querySelector(".heading-h2").style.display = "none"
81
+ document.querySelector(".sortingFilters").style.display = "none"
81
82
  if (featureContainer) {
82
83
  featureContainer.remove()
83
84
  }
@@ -225,7 +226,11 @@ if (lengthValue === "1") {
225
226
  sortingFilter.addEventListener("change", logSubmit);
226
227
  }
227
228
 
229
+ let moreData = []
230
+ let data_index = 25;
228
231
  function getWords(data) {
232
+ data_index = 25
233
+ moreData = []
229
234
  main.innerHTML = "";
230
235
  lengthSelect.innerHTML = ""
231
236
  document.querySelector(".sortingFilters").style.display = "flex"
@@ -237,7 +242,6 @@ function getWords(data) {
237
242
  } else {
238
243
  let newWordsLength = 0;
239
244
  let dataArr = [];
240
- // for (let i = serachValue.length; i >= 1; i--) {
241
245
  for (let i = 15; i > 0; i--) {
242
246
  let newdata = data.filter((item) => item.length === i);
243
247
  if (prefixValue) {
@@ -245,6 +249,9 @@ function getWords(data) {
245
249
  item2.startsWith(prefixValue.toLowerCase())
246
250
  );
247
251
  startsWith.nextElementSibling.querySelector("img").src = "/assets/images/close-btn.svg"
252
+ startsWith.nextElementSibling.removeAttribute("data-tip")
253
+ startsWith.nextElementSibling.style.setProperty('--tooltip-padding', '0');
254
+ startsWith.nextElementSibling.style.setProperty('--tooltip-border-style', 'none');
248
255
  startsWith.classList.add("tick");
249
256
  startsWith.value = prefixValue;
250
257
  } else {
@@ -255,6 +262,9 @@ function getWords(data) {
255
262
  item.includes(containsValue.toLowerCase())
256
263
  );
257
264
  mustInclude.nextElementSibling.querySelector("img").src = "/assets/images/close-btn.svg"
265
+ mustInclude.nextElementSibling.removeAttribute("data-tip")
266
+ mustInclude.nextElementSibling.style.setProperty('--tooltip-padding', '0');
267
+ mustInclude.nextElementSibling.style.setProperty('--tooltip-border-style', 'none');
258
268
  mustInclude.classList.add("tick");
259
269
  mustInclude.value = containsValue;
260
270
  } else {
@@ -265,6 +275,9 @@ function getWords(data) {
265
275
  item.endsWith(suffixValue.toLowerCase())
266
276
  );
267
277
  endsWith.nextElementSibling.querySelector("img").src = "/assets/images/close-btn.svg"
278
+ endsWith.nextElementSibling.removeAttribute("data-tip")
279
+ endsWith.nextElementSibling.style.setProperty('--tooltip-padding', '0');
280
+ endsWith.nextElementSibling.style.setProperty('--tooltip-border-style', 'none');
268
281
  endsWith.classList.add("tick");
269
282
  endsWith.value = suffixValue;
270
283
  } else {
@@ -288,6 +301,9 @@ function getWords(data) {
288
301
  }
289
302
  });
290
303
  exculdeWith.nextElementSibling.querySelector("img").src = "/assets/images/close-btn.svg"
304
+ exculdeWith.nextElementSibling.removeAttribute("data-tip")
305
+ exculdeWith.nextElementSibling.style.setProperty('--tooltip-padding', '0');
306
+ exculdeWith.nextElementSibling.style.setProperty('--tooltip-border-style', 'none');
291
307
  exculdeWith.classList.add("tick");
292
308
  exculdeWith.value = exculdeValue;
293
309
  newdata = data;
@@ -312,6 +328,9 @@ function getWords(data) {
312
328
  }
313
329
  });
314
330
  inculdeWith.nextElementSibling.querySelector("img").src = "/assets/images/close-btn.svg"
331
+ inculdeWith.nextElementSibling.removeAttribute("data-tip")
332
+ inculdeWith.nextElementSibling.style.setProperty('--tooltip-padding', '0');
333
+ inculdeWith.nextElementSibling.style.setProperty('--tooltip-border-style', 'none');
315
334
  inculdeWith.classList.add("tick");
316
335
  inculdeWith.value = includeValue;
317
336
  newdata = data;
@@ -321,6 +340,9 @@ function getWords(data) {
321
340
  if (lengthValue) {
322
341
  newdata = newdata.filter((item) => item.length == lengthValue);
323
342
  wordLength.nextElementSibling.querySelector("img").src = "/assets/images/close-btn.svg"
343
+ wordLength.nextElementSibling.removeAttribute("data-tip")
344
+ wordLength.nextElementSibling.style.setProperty('--tooltip-padding', '0');
345
+ wordLength.nextElementSibling.style.setProperty('--tooltip-border-style', 'none');
324
346
  wordLength.classList.add("tick");
325
347
  wordLength.value = lengthValue;
326
348
  } else {
@@ -331,7 +353,8 @@ function getWords(data) {
331
353
  } else {
332
354
  newWordsLength += newdata.length;
333
355
  newdata = sortWords(newdata);
334
- const result = newdata.map((item) => {
356
+ moreData.push(newdata)
357
+ let result = newdata.map((item) => {
335
358
  let itemHtml = "";
336
359
  if (serachValue) {
337
360
  var text1 = serachValue.replace("?", "");
@@ -389,14 +412,26 @@ function getWords(data) {
389
412
  lengthSelect.add(option);
390
413
  lengthSelect.style.display = "block"
391
414
  }
415
+
416
+ result = result.slice(0, 25)
417
+
392
418
  main.innerHTML += `
393
- <div class="allGroupWords wordlistContainer" id="alpha_${i}">
394
- <h3 class="wordListHeading lead">${i} Letter Words</h3>
395
- <div class="wordList">
396
- ${result.join("")}
397
- </div>
398
- </div>
399
- `;
419
+ <div class="allGroupWords wordlistContainer" id="alpha_${i}">
420
+ <h3 class="wordListHeading lead">${i} Letter Words</h3>
421
+ <div class="wordList">${result.join("")}</div>
422
+ <div class="w-100 text-center btn-container">
423
+ <button
424
+ style="background: black;
425
+ padding: 1rem 2rem;
426
+ border-radius: 50px;
427
+ color: #fff;
428
+ font-size: 15px;
429
+ border: none;"
430
+ onclick="showMoreWords(this)" type="button" class="my-4 showmore_btn" id="${i}">More Words</button>
431
+ </div>
432
+ </div>`
433
+
434
+ showMoreLimit()
400
435
  }
401
436
  }
402
437
  }
@@ -437,6 +472,118 @@ function getWords(data) {
437
472
  }
438
473
  }
439
474
  }
475
+ async function getMoreWords() {
476
+ let flattenedArray = moreData.flat();
477
+ let uniqueArray = [...new Set(flattenedArray)];
478
+ // console.log(uniqueArray);
479
+ return uniqueArray
480
+ }
481
+
482
+ let previousDataIndex = null
483
+ let previousID = null;
484
+ let storepreviousIndex = []
485
+ async function showMoreWords(e) {
486
+ try {
487
+ let showmore = e.parentElement.children[0];
488
+ let id = showmore.id;
489
+
490
+ if (previousID !== null && parseInt(previousID) !== parseInt(id)) {
491
+ data_index = 25
492
+ console.log(storepreviousIndex);
493
+ const filteredIndexes = storepreviousIndex.filter(item => item.id === id);
494
+ if (filteredIndexes.length > 0) {
495
+ const lastItem = filteredIndexes[filteredIndexes.length - 1];
496
+ data_index = lastItem.data_index + 25;
497
+ lastItem.data_index = data_index;
498
+ }
499
+ console.log(filteredIndexes);
500
+
501
+ }
502
+ previousID = id;
503
+ storepreviousIndex.push({
504
+ data_index,
505
+ id
506
+ })
507
+ console.log("Current data_index:", data_index);
508
+
509
+ document.getElementById(id).innerHTML = `Loading...`;
510
+ let content_area = document.getElementById("alpha_" + id).getElementsByClassName("wordList")[0];
511
+ const result = await getMoreWords();
512
+ let full_words = result.filter((item) => item.length === Number(id));
513
+
514
+ if (data_index < full_words.length) {
515
+ for (let d = data_index; d < data_index + 25; d++) {
516
+ if (full_words[d] != undefined) {
517
+ let itemHtml = "";
518
+ if (serachValue) {
519
+ var text1 = serachValue.replace("?", "");
520
+ var text2 = full_words[d];
521
+ var text3 = full_words[d];
522
+ let chars = text1.split("");
523
+ let indexs = [];
524
+ chars.map((i) => {
525
+ let findIndexes = findIndex(text3, i);
526
+ if (findIndexes.length > 0) {
527
+ text3 = text3.split("");
528
+ text3[findIndexes] = "$";
529
+ text3 = text3.join("");
530
+ indexs = [...indexs, ...findIndexes];
531
+ }
532
+ });
533
+ text2.split("").map((itemValue, index) => {
534
+ let check = indexs.find((i) => i === index);
535
+ if (check !== undefined) {
536
+ itemHtml += `${itemValue}`;
537
+ } else {
538
+ itemHtml += `<span class='highlight'>${itemValue}</span>`;
539
+ }
540
+ });
541
+ } else {
542
+ itemHtml = full_words[d]
543
+ }
544
+ let ScrabbleLetterScore = ScrabbleScore();
545
+ let points = 0;
546
+ full_words[d] = full_words[d].toLowerCase();
547
+ for (let i = 0; i < full_words[d].length; i++) {
548
+ points += ScrabbleLetterScore[full_words[d][i]] || 0; // for unknown characters
549
+ }
550
+
551
+ let span = document.createElement("span");
552
+ span.setAttribute("class", "points");
553
+ span.setAttribute("value", `${points}`);
554
+ span.innerHTML = `${points}`;
555
+
556
+ let a = document.createElement("a");
557
+ a.setAttribute("class", "anchor__style");
558
+ a.setAttribute("target", "_blank");
559
+ a.setAttribute("href", "/word-meaning?search=" + full_words[d].replace(/<\/?[^>]+>/gi, ''));
560
+ a.setAttribute("data-original-title", `Lookup ${full_words[d].replace(/<\/?[^>]+>/gi, '')} in Dictionary`)
561
+ a.innerHTML = ` ${itemHtml} `;
562
+ a.appendChild(span)
563
+ content_area.appendChild(a);
564
+ }
565
+ }
566
+ document.getElementById(id).innerHTML = `More Words`;
567
+ data_index += 25;
568
+ } else {
569
+ document.getElementById(id).style.display = "none";
570
+ }
571
+ } catch (error) {
572
+ console.error("Error fetching or processing data:", error);
573
+ }
574
+ }
575
+
576
+ function showMoreLimit() {
577
+ let tableFooter = document.querySelectorAll(".btn-container")
578
+ let showmore = document.querySelectorAll(".showmore_btn");
579
+ for (let i = 0; i < showmore.length; i++) {
580
+ let data_of_button = document.getElementById("alpha_" + showmore[i].getAttribute("id"));
581
+ let final_data = data_of_button.getElementsByClassName("anchor__style");
582
+ if (final_data.length < 25) {
583
+ tableFooter[i].style.display = "none";
584
+ }
585
+ }
586
+ }
440
587
  function sortWords(data) {
441
588
  if (sortingFilter.selectedIndex == 0) {
442
589
  return data;
@@ -265,7 +265,12 @@ selectedDictionary.addEventListener("change", ((e) => {
265
265
  form.addEventListener('submit', logSubmit);
266
266
  sortingFilter.addEventListener("change", logSubmit);
267
267
 
268
+
269
+ let moreData = []
270
+ let data_index = 25;
268
271
  function x_with_letters(data) {
272
+ data_index = 25
273
+ moreData = []
269
274
  document.querySelector(".sortingFilters").style.display = "flex"
270
275
  main.innerHTML = ""
271
276
  if (typeof data === 'string') {
@@ -374,8 +379,9 @@ function x_with_letters(data) {
374
379
  } else {
375
380
  newWordsLength += filterData.length
376
381
  filterData = sortWords(filterData);
382
+ moreData.push(filterData)
377
383
  let itemLength = ''
378
- const result = filterData.map((item) => {
384
+ let result = filterData.map((item) => {
379
385
  let itemHtml = "";
380
386
  itemLength = item.length
381
387
  let ScrabbleLetterScore = ScrabbleScore()
@@ -434,20 +440,33 @@ function x_with_letters(data) {
434
440
  home_page_search_result.href = homePageSearchResult
435
441
  home_page_search_result.innerHTML = `See words of any length with letters ${serachValue.split("")}`
436
442
 
443
+ result = result.slice(0, 25)
444
+
437
445
  main.innerHTML += `
438
- <div class="allGroupWords">
446
+ <div class="allGroupWords" id="alpha_${itemLength}">
439
447
  <h3 class="wordListHeading lead">${itemLength} Letter Words</h3>
440
448
  <div class="wordList">
441
449
  ${result.join("")}
442
450
  </div>
451
+ <div class="w-100 text-center btn-container">
452
+ <button
453
+ style="background: black;
454
+ padding: 1rem 2rem;
455
+ border-radius: 50px;
456
+ color: #fff;
457
+ font-size: 15px;
458
+ border: none;"
459
+ onclick="showMoreWords(this)" type="button" class="my-4 showmore_btn" id="${itemLength}">More Words</button>
460
+ </div>
443
461
  </div>
444
462
  `;
463
+ showMoreLimit()
445
464
  }
446
465
  if (serachValue) {
447
- wordCount.innerHTML = `<strong>Found ${newWordsLength} words with letters with ${serachValue.split(
448
- ''
449
- )}</strong>`
450
- }else{
466
+ wordCount.innerHTML = `<strong>Found ${newWordsLength} words with letters with ${serachValue.split(
467
+ ''
468
+ )}</strong>`
469
+ } else {
451
470
 
452
471
  let startwithMsg = ""
453
472
  let endwithMsg = ""
@@ -477,6 +496,94 @@ function x_with_letters(data) {
477
496
  }
478
497
  }
479
498
 
499
+ async function getMoreWords() {
500
+ let flattenedArray = moreData.flat();
501
+ let uniqueArray = [...new Set(flattenedArray)];
502
+ return uniqueArray
503
+ }
504
+ async function showMoreWords(e) {
505
+ try {
506
+ let showmore = e.parentElement.children[0];
507
+ let id = showmore.id;
508
+
509
+ document.getElementById(id).innerHTML = `Loading...`;
510
+ let content_area = document.getElementById("alpha_" + id).getElementsByClassName("wordList")[0];
511
+ const result = await getMoreWords();
512
+ let full_words = result.filter((item) => item.length === Number(id));
513
+
514
+ console.log(data_index);
515
+
516
+ if (data_index < full_words.length) {
517
+ for (let d = data_index; d < data_index + 25; d++) {
518
+ if (full_words[d] != undefined) {
519
+ let itemHtml = "";
520
+ if (serachValue) {
521
+ var text1 = serachValue.replace("?", "");
522
+ var text2 = full_words[d];
523
+ var text3 = full_words[d];
524
+ let chars = text1.split("");
525
+ let indexs = [];
526
+ chars.map((i) => {
527
+ let findIndexes = findIndex(text3, i);
528
+ if (findIndexes.length > 0) {
529
+ text3 = text3.split("");
530
+ text3[findIndexes] = "$";
531
+ text3 = text3.join("");
532
+ indexs = [...indexs, ...findIndexes];
533
+ }
534
+ });
535
+ text2.split("").map((itemValue, index) => {
536
+ let check = indexs.find((i) => i === index);
537
+ if (check !== undefined) {
538
+ itemHtml += `${itemValue}`;
539
+ } else {
540
+ itemHtml += `<span class='highlight'>${itemValue}</span>`;
541
+ }
542
+ });
543
+ } else {
544
+ itemHtml = full_words[d]
545
+ }
546
+ let ScrabbleLetterScore = ScrabbleScore();
547
+ let points = 0;
548
+ full_words[d] = full_words[d].toLowerCase();
549
+ for (let i = 0; i < full_words[d].length; i++) {
550
+ points += ScrabbleLetterScore[full_words[d][i]] || 0; // for unknown characters
551
+ }
552
+
553
+ let span = document.createElement("span");
554
+ span.setAttribute("class", "points");
555
+ span.setAttribute("value", `${points}`);
556
+ span.innerHTML = `${points}`;
557
+
558
+ let a = document.createElement("a");
559
+ a.setAttribute("class", "anchor__style");
560
+ a.setAttribute("target", "_blank");
561
+ a.setAttribute("href", "/word-meaning?search=" + full_words[d].replace(/<\/?[^>]+>/gi, ''));
562
+ a.setAttribute("data-original-title", `Lookup ${full_words[d].replace(/<\/?[^>]+>/gi, '')} in Dictionary`)
563
+ a.innerHTML = ` ${itemHtml} `;
564
+ a.appendChild(span)
565
+ content_area.appendChild(a);
566
+ }
567
+ }
568
+ document.getElementById(id).innerHTML = `More Words`;
569
+ data_index += 25;
570
+ } else {
571
+ data_index = 25
572
+ document.getElementById(id).style.display = "none";
573
+ }
574
+ } catch (error) {
575
+ console.error("Error fetching or processing data:", error);
576
+ }
577
+ }
578
+ function showMoreLimit() {
579
+ let tableFooter = document.querySelector(".btn-container");
580
+ let wordList = document.querySelector(".wordList");
581
+ let final_data = wordList.getElementsByClassName("anchor__style");
582
+ if (final_data.length < 25) {
583
+ tableFooter.style.display = "none";
584
+ }
585
+ }
586
+
480
587
  function sortWords(data) {
481
588
  if (sortingFilter.selectedIndex == 0) {
482
589
  return data;
@@ -518,3 +625,18 @@ function sortWords(data) {
518
625
  return tempArr;
519
626
  }
520
627
  }
628
+
629
+
630
+ function findIndex(str, char) {
631
+ const strLength = str.length;
632
+ const indexes = [];
633
+ let newStr = str;
634
+
635
+ while (newStr && newStr.indexOf(char) > -1) {
636
+ indexes.push(newStr.indexOf(char) + strLength - newStr.length);
637
+ newStr = newStr.substring(newStr.indexOf(char) + 5);
638
+ newStr = newStr.substring(newStr.indexOf(char) + 5);
639
+ }
640
+
641
+ return indexes;
642
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: word-games-theme
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.1
4
+ version: 2.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - manpreet-appscms
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-08 00:00:00.000000000 Z
11
+ date: 2024-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll