word-games-theme 2.7.1 → 2.7.2

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,19 @@ 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 onclick="showMoreWords(this)" type="button" class="my-4 showmore_btn" id="${i}">More Words</button>
424
+ </div>
425
+ </div>`
426
+
427
+ showMoreLimit()
400
428
  }
401
429
  }
402
430
  }
@@ -437,6 +465,118 @@ function getWords(data) {
437
465
  }
438
466
  }
439
467
  }
468
+ async function getMoreWords() {
469
+ let flattenedArray = moreData.flat();
470
+ let uniqueArray = [...new Set(flattenedArray)];
471
+ // console.log(uniqueArray);
472
+ return uniqueArray
473
+ }
474
+
475
+ let previousDataIndex = null
476
+ let previousID = null;
477
+ let storepreviousIndex = []
478
+ async function showMoreWords(e) {
479
+ try {
480
+ let showmore = e.parentElement.children[0];
481
+ let id = showmore.id;
482
+
483
+ if (previousID !== null && parseInt(previousID) !== parseInt(id)) {
484
+ data_index = 25
485
+ console.log(storepreviousIndex);
486
+ const filteredIndexes = storepreviousIndex.filter(item => item.id === id);
487
+ if (filteredIndexes.length > 0) {
488
+ const lastItem = filteredIndexes[filteredIndexes.length - 1];
489
+ data_index = lastItem.data_index + 25;
490
+ lastItem.data_index = data_index;
491
+ }
492
+ console.log(filteredIndexes);
493
+
494
+ }
495
+ previousID = id;
496
+ storepreviousIndex.push({
497
+ data_index,
498
+ id
499
+ })
500
+ console.log("Current data_index:", data_index);
501
+
502
+ document.getElementById(id).innerHTML = `Loading...`;
503
+ let content_area = document.getElementById("alpha_" + id).getElementsByClassName("wordList")[0];
504
+ const result = await getMoreWords();
505
+ let full_words = result.filter((item) => item.length === Number(id));
506
+
507
+ if (data_index < full_words.length) {
508
+ for (let d = data_index; d < data_index + 25; d++) {
509
+ if (full_words[d] != undefined) {
510
+ let itemHtml = "";
511
+ if (serachValue) {
512
+ var text1 = serachValue.replace("?", "");
513
+ var text2 = full_words[d];
514
+ var text3 = full_words[d];
515
+ let chars = text1.split("");
516
+ let indexs = [];
517
+ chars.map((i) => {
518
+ let findIndexes = findIndex(text3, i);
519
+ if (findIndexes.length > 0) {
520
+ text3 = text3.split("");
521
+ text3[findIndexes] = "$";
522
+ text3 = text3.join("");
523
+ indexs = [...indexs, ...findIndexes];
524
+ }
525
+ });
526
+ text2.split("").map((itemValue, index) => {
527
+ let check = indexs.find((i) => i === index);
528
+ if (check !== undefined) {
529
+ itemHtml += `${itemValue}`;
530
+ } else {
531
+ itemHtml += `<span class='highlight'>${itemValue}</span>`;
532
+ }
533
+ });
534
+ } else {
535
+ itemHtml = full_words[d]
536
+ }
537
+ let ScrabbleLetterScore = ScrabbleScore();
538
+ let points = 0;
539
+ full_words[d] = full_words[d].toLowerCase();
540
+ for (let i = 0; i < full_words[d].length; i++) {
541
+ points += ScrabbleLetterScore[full_words[d][i]] || 0; // for unknown characters
542
+ }
543
+
544
+ let span = document.createElement("span");
545
+ span.setAttribute("class", "points");
546
+ span.setAttribute("value", `${points}`);
547
+ span.innerHTML = `${points}`;
548
+
549
+ let a = document.createElement("a");
550
+ a.setAttribute("class", "anchor__style");
551
+ a.setAttribute("target", "_blank");
552
+ a.setAttribute("href", "/word-meaning?search=" + full_words[d].replace(/<\/?[^>]+>/gi, ''));
553
+ a.setAttribute("data-original-title", `Lookup ${full_words[d].replace(/<\/?[^>]+>/gi, '')} in Dictionary`)
554
+ a.innerHTML = ` ${itemHtml} `;
555
+ a.appendChild(span)
556
+ content_area.appendChild(a);
557
+ }
558
+ }
559
+ document.getElementById(id).innerHTML = `More Words`;
560
+ data_index += 25;
561
+ } else {
562
+ document.getElementById(id).style.display = "none";
563
+ }
564
+ } catch (error) {
565
+ console.error("Error fetching or processing data:", error);
566
+ }
567
+ }
568
+
569
+ function showMoreLimit() {
570
+ let tableFooter = document.querySelectorAll(".btn-container")
571
+ let showmore = document.querySelectorAll(".showmore_btn");
572
+ for (let i = 0; i < showmore.length; i++) {
573
+ let data_of_button = document.getElementById("alpha_" + showmore[i].getAttribute("id"));
574
+ let final_data = data_of_button.getElementsByClassName("anchor__style");
575
+ if (final_data.length < 25) {
576
+ tableFooter[i].style.display = "none";
577
+ }
578
+ }
579
+ }
440
580
  function sortWords(data) {
441
581
  if (sortingFilter.selectedIndex == 0) {
442
582
  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,26 @@ 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 onclick="showMoreWords(this)" type="button" class="my-4 showmore_btn" id="${itemLength}">More Words</button>
453
+ </div>
443
454
  </div>
444
455
  `;
456
+ showMoreLimit()
445
457
  }
446
458
  if (serachValue) {
447
- wordCount.innerHTML = `<strong>Found ${newWordsLength} words with letters with ${serachValue.split(
448
- ''
449
- )}</strong>`
450
- }else{
459
+ wordCount.innerHTML = `<strong>Found ${newWordsLength} words with letters with ${serachValue.split(
460
+ ''
461
+ )}</strong>`
462
+ } else {
451
463
 
452
464
  let startwithMsg = ""
453
465
  let endwithMsg = ""
@@ -477,6 +489,94 @@ function x_with_letters(data) {
477
489
  }
478
490
  }
479
491
 
492
+ async function getMoreWords() {
493
+ let flattenedArray = moreData.flat();
494
+ let uniqueArray = [...new Set(flattenedArray)];
495
+ return uniqueArray
496
+ }
497
+ async function showMoreWords(e) {
498
+ try {
499
+ let showmore = e.parentElement.children[0];
500
+ let id = showmore.id;
501
+
502
+ document.getElementById(id).innerHTML = `Loading...`;
503
+ let content_area = document.getElementById("alpha_" + id).getElementsByClassName("wordList")[0];
504
+ const result = await getMoreWords();
505
+ let full_words = result.filter((item) => item.length === Number(id));
506
+
507
+ console.log(data_index);
508
+
509
+ if (data_index < full_words.length) {
510
+ for (let d = data_index; d < data_index + 25; d++) {
511
+ if (full_words[d] != undefined) {
512
+ let itemHtml = "";
513
+ if (serachValue) {
514
+ var text1 = serachValue.replace("?", "");
515
+ var text2 = full_words[d];
516
+ var text3 = full_words[d];
517
+ let chars = text1.split("");
518
+ let indexs = [];
519
+ chars.map((i) => {
520
+ let findIndexes = findIndex(text3, i);
521
+ if (findIndexes.length > 0) {
522
+ text3 = text3.split("");
523
+ text3[findIndexes] = "$";
524
+ text3 = text3.join("");
525
+ indexs = [...indexs, ...findIndexes];
526
+ }
527
+ });
528
+ text2.split("").map((itemValue, index) => {
529
+ let check = indexs.find((i) => i === index);
530
+ if (check !== undefined) {
531
+ itemHtml += `${itemValue}`;
532
+ } else {
533
+ itemHtml += `<span class='highlight'>${itemValue}</span>`;
534
+ }
535
+ });
536
+ } else {
537
+ itemHtml = full_words[d]
538
+ }
539
+ let ScrabbleLetterScore = ScrabbleScore();
540
+ let points = 0;
541
+ full_words[d] = full_words[d].toLowerCase();
542
+ for (let i = 0; i < full_words[d].length; i++) {
543
+ points += ScrabbleLetterScore[full_words[d][i]] || 0; // for unknown characters
544
+ }
545
+
546
+ let span = document.createElement("span");
547
+ span.setAttribute("class", "points");
548
+ span.setAttribute("value", `${points}`);
549
+ span.innerHTML = `${points}`;
550
+
551
+ let a = document.createElement("a");
552
+ a.setAttribute("class", "anchor__style");
553
+ a.setAttribute("target", "_blank");
554
+ a.setAttribute("href", "/word-meaning?search=" + full_words[d].replace(/<\/?[^>]+>/gi, ''));
555
+ a.setAttribute("data-original-title", `Lookup ${full_words[d].replace(/<\/?[^>]+>/gi, '')} in Dictionary`)
556
+ a.innerHTML = ` ${itemHtml} `;
557
+ a.appendChild(span)
558
+ content_area.appendChild(a);
559
+ }
560
+ }
561
+ document.getElementById(id).innerHTML = `More Words`;
562
+ data_index += 25;
563
+ } else {
564
+ data_index = 25
565
+ document.getElementById(id).style.display = "none";
566
+ }
567
+ } catch (error) {
568
+ console.error("Error fetching or processing data:", error);
569
+ }
570
+ }
571
+ function showMoreLimit() {
572
+ let tableFooter = document.querySelector(".btn-container");
573
+ let wordList = document.querySelector(".wordList");
574
+ let final_data = wordList.getElementsByClassName("anchor__style");
575
+ if (final_data.length < 25) {
576
+ tableFooter.style.display = "none";
577
+ }
578
+ }
579
+
480
580
  function sortWords(data) {
481
581
  if (sortingFilter.selectedIndex == 0) {
482
582
  return data;
@@ -518,3 +618,18 @@ function sortWords(data) {
518
618
  return tempArr;
519
619
  }
520
620
  }
621
+
622
+
623
+ function findIndex(str, char) {
624
+ const strLength = str.length;
625
+ const indexes = [];
626
+ let newStr = str;
627
+
628
+ while (newStr && newStr.indexOf(char) > -1) {
629
+ indexes.push(newStr.indexOf(char) + strLength - newStr.length);
630
+ newStr = newStr.substring(newStr.indexOf(char) + 5);
631
+ newStr = newStr.substring(newStr.indexOf(char) + 5);
632
+ }
633
+
634
+ return indexes;
635
+ }
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.2
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