word-games-theme 2.1.7 → 2.1.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) 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/style.css +1 -1
  48. data/assets/css/wordgames-blog.css +431 -0
  49. data/assets/css/wordgames-home.css +969 -0
  50. data/assets/css/wordgames-result.css +498 -0
  51. data/assets/css/wordgames-theme.css +227 -0
  52. data/assets/css/wordgames-variables.css +20 -0
  53. data/assets/images/background.svg +80 -0
  54. data/assets/images/close-btn.svg +16 -0
  55. data/assets/images/facebook-icon.svg +9 -0
  56. data/assets/images/facebook.svg +10 -1
  57. data/assets/images/how-to.svg +1 -0
  58. data/assets/images/idea.svg +113 -0
  59. data/assets/images/instagram.svg +1 -1
  60. data/assets/images/logo wordswithletter final black.svg +95 -0
  61. data/assets/images/logo.svg +106 -0
  62. data/assets/images/minus-btn.svg +14 -0
  63. data/assets/images/plus btn.svg +16 -0
  64. data/assets/images/questionmark.svg +17 -0
  65. data/assets/images/search.svg +16 -1
  66. data/assets/images/twitter.svg +1 -1
  67. data/assets/images/wordfinder-favicon.svg +69 -0
  68. data/assets/images/wordfinder-pink.svg +82 -0
  69. data/assets/images/wordfinder-result-logo.svg +105 -0
  70. data/assets/images/words with letters logo white text.svg +95 -0
  71. data/assets/js/scrabble-words.js +885 -0
  72. data/assets/js/theme.js +2 -1
  73. data/assets/js/wordgames-home.js +82 -0
  74. data/assets/js/wordgames-result.js +885 -0
  75. data/assets/js/wordgames-xletter.js +740 -0
  76. metadata +65 -2
@@ -0,0 +1,740 @@
1
+ const getScript = document.currentScript
2
+ const letterLen = getScript.dataset.letter
3
+ const ablank = getScript.dataset.ablank
4
+
5
+ const siteUrl = getScript.dataset.url
6
+
7
+ let errorMsg = document.querySelector('.errorMsg')
8
+ let script = document.currentScript
9
+ let wordCount = document.querySelector('.wordCount')
10
+ let main = document.querySelector('.main')
11
+
12
+ const params = new URLSearchParams(window.location.search)
13
+ let serachValue = params.get('search').toLowerCase()
14
+ let prefixValue = params.get('prefix')
15
+ let containsValue = params.get('contains')
16
+ let suffixValue = params.get('suffix')
17
+ let exculdeValue = params.get('exculde')
18
+ let includeValue = params.get('include')
19
+ let lengthValue = params.get('length')
20
+ let dictonary = params.get('dictionary')
21
+
22
+
23
+
24
+ // Scrabble Point Counts
25
+ const ScrabbleScore = () => {
26
+ let twl06_sowpods = {
27
+ a: 1,
28
+ e: 1,
29
+ i: 1,
30
+ o: 1,
31
+ u: 1,
32
+ l: 1,
33
+ n: 1,
34
+ r: 1,
35
+ s: 1,
36
+ t: 1,
37
+ d: 2,
38
+ g: 2,
39
+ b: 3,
40
+ c: 3,
41
+ m: 3,
42
+ p: 3,
43
+ f: 4,
44
+ h: 4,
45
+ v: 4,
46
+ w: 4,
47
+ y: 4,
48
+ k: 5,
49
+ j: 8,
50
+ x: 8,
51
+ q: 10,
52
+ z: 10,
53
+ }
54
+
55
+ let wwfScore = {
56
+ a: 1,
57
+ b: 4,
58
+ c: 4,
59
+ d: 2,
60
+ e: 1,
61
+ f: 4,
62
+ g: 3,
63
+ h: 3,
64
+ i: 1,
65
+ j: 10,
66
+ k: 5,
67
+ l: 2,
68
+ m: 4,
69
+ n: 2,
70
+ o: 1,
71
+ p: 4,
72
+ q: 10,
73
+ r: 1,
74
+ s: 1,
75
+ t: 1,
76
+ u: 2,
77
+ v: 5,
78
+ w: 4,
79
+ x: 8,
80
+ y: 3,
81
+ z: 10,
82
+ }
83
+
84
+ if (dictonary === 'wwf') {
85
+ return wwfScore
86
+ } else {
87
+ return twl06_sowpods
88
+ }
89
+ }
90
+
91
+ let tab_link_wrapper = document.querySelector('.tab_link_wrapper')
92
+ tab_link_wrapper.style.display = "none"
93
+
94
+ let home_page_search_result = document.querySelector("#home_page_search_result")
95
+ let homePageSearchResult = `/result?search=${serachValue}&dictionary=Dictionary&prefix=&contains=&suffix=&exculde=&inculde=&length=`;
96
+
97
+ let txtBox = document.querySelector('.txtBox')
98
+ txtBox.focus()
99
+ txtBox.value = serachValue
100
+
101
+
102
+ if (ablank) {
103
+ if (!serachValue.includes("?")) {
104
+ if (serachValue.length <= letterLen || serachValue.length >= letterLen) {
105
+ serachValue = serachValue + '?'
106
+ txtBox.value = serachValue
107
+ }
108
+ }
109
+ }
110
+
111
+
112
+
113
+
114
+
115
+
116
+ let letterCloseButton = document.querySelector('.letter-close-button-commonPage')
117
+ if (serachValue) {
118
+ letterCloseButton.classList.add("ltr-cls-btn-commonPage")
119
+ }
120
+ letterCloseButton.addEventListener("click", () => {
121
+ txtBox.value = ""
122
+ letterCloseButton.classList.remove("ltr-cls-btn-commonPage")
123
+ })
124
+
125
+ txtBox.addEventListener('input', (e) => {
126
+ if (e.target.value === "") {
127
+ letterCloseButton.classList.remove("ltr-cls-btn-commonPage")
128
+ } else {
129
+ letterCloseButton.classList.add("ltr-cls-btn-commonPage")
130
+ }
131
+ let rangeOfBlankTile = script.dataset.range
132
+ e.target.value = e.target.value.replace(/[^a-zA-Z? ]/g, '')
133
+ if (rangeOfBlankTile === '') {
134
+ rangeOfBlankTile = 3
135
+ }
136
+ e.target.value = e.target.value.replace(/ /g, '?')
137
+ let data = []
138
+ data = e.target.value.split('').filter((i) => i === '?')
139
+ // console.log(data)
140
+ if (data.length > rangeOfBlankTile) {
141
+ e.target.value = e.target.value.replace(/\?$/, '')
142
+ }
143
+ })
144
+
145
+ function mobileScrollTop(x) {
146
+ if (x.matches) {
147
+ txtBox.addEventListener("click", () => {
148
+ document.documentElement.scrollTop = 350
149
+ setTimeout(() => {
150
+ document.documentElement.scrollTop = 350
151
+ }, 150);
152
+ })
153
+ } else {
154
+ console.log("false");
155
+ }
156
+ }
157
+ var x = window.matchMedia("(max-width: 768px)")
158
+ // mobileScrollTop(x)
159
+ // x.addListener(mobileScrollTop)
160
+
161
+ var theSelect = document.getElementById('select_dropDown')
162
+ const sortup = document.querySelector(".sortup-icon")
163
+ let bool = false
164
+ sortup.addEventListener("click", () => {
165
+ if (bool) {
166
+ theSelect.size = 0
167
+ bool = false
168
+ theSelect.style.display = "none"
169
+ }
170
+ else {
171
+ bool = true
172
+ theSelect.size = 3
173
+ theSelect.style.display = "block"
174
+ }
175
+ })
176
+ document.querySelector('.select_dropDown2').value = dictonary
177
+ const getDiff = (text1, text2) => {
178
+ var diffRange = []
179
+ var currentRange = undefined
180
+ for (var i = 0; i < text1.length; i++) {
181
+ if (text1[i] != text2[i]) {
182
+ if (currentRange == undefined) {
183
+ currentRange = [i]
184
+ }
185
+ }
186
+ if (currentRange != undefined && text1[i] == text2[i]) {
187
+ currentRange.push(i)
188
+ diffRange.push(currentRange)
189
+ currentRange = undefined
190
+ }
191
+ }
192
+ if (currentRange != undefined) {
193
+ currentRange.push(i)
194
+ diffRange.push(currentRange)
195
+ }
196
+ return diffRange
197
+ }
198
+ const getData = async (serachValue) => {
199
+ try {
200
+ console.log(true);
201
+ // placeholder_loading.style.display = "none"
202
+ errorMsg.innerHTML = ""
203
+ wordCount.innerHTML = ""
204
+ home_page_search_result.innerHTML = ""
205
+ let selectedDictionary = document.querySelector('.select_dropDown2').value
206
+ main.innerHTML = `<div class="loader">
207
+ <img src='/assets/images/loading.gif'>
208
+ <div style="font-weight:900;font-size:14px" >Finding words - Powered by ${siteUrl.replace(/^https?:\/\//, '')}</div>
209
+ </div>`
210
+ const response = await fetch(
211
+ `/.netlify/functions/getWords?name=${serachValue}&selecteddictionary=${selectedDictionary}`
212
+ )
213
+ const data = await response.json()
214
+ main.innerHTML = ''
215
+ x_with_letters(data)
216
+ } catch (error) {
217
+ console.log(error)
218
+ }
219
+ }
220
+ // calling function
221
+ getData(serachValue.toLowerCase())
222
+
223
+ let quesMark = ''
224
+ quesMark = "?"
225
+
226
+
227
+ function logSubmit(event) {
228
+ document.querySelector(".fillterWrapper").classList.add("hide")
229
+
230
+
231
+ const scrollingElement = (document.scrollingElement || document.body);
232
+ scrollingElement.scroll({ top: 0, behavior: 'smooth' });
233
+ if (ablank) {
234
+ if (!txtBox.value.includes("?")) {
235
+ txtBox.value = txtBox.value + quesMark
236
+ }
237
+ }
238
+ let selectedDictionary = document.querySelector('.select_dropDown2').value
239
+ event.preventDefault();
240
+ if (history.pushState) {
241
+ var newurl = window.location.protocol + "//" + window.location.host +
242
+ window.location.pathname + '?' + "search" + "=" + txtBox.value.toLowerCase() + '&' +
243
+ 'dictionary' + '=' + selectedDictionary +
244
+ '&' + 'prefix' + '=' + startsWith.value + '&' + 'contains' + '=' + mustInclude.value +
245
+ '&' + 'suffix' + '=' + endsWith.value + '&' + 'exculde' + '=' + exculdeWith.value +
246
+ '&' + 'include' + '=' + inculdeWith.value + '&' + 'length' + '=' + wordLength.value;
247
+ window.history.pushState({ path: newurl }, '', newurl);
248
+
249
+ const params = new URLSearchParams(window.location.search)
250
+ serachValue = params.get('search')
251
+ prefixValue = params.get('prefix')
252
+ containsValue = params.get('contains')
253
+ suffixValue = params.get('suffix')
254
+ exculdeValue = params.get('exculde')
255
+ includeValue = params.get('include')
256
+ lengthValue = params.get('length')
257
+ dictonary = params.get('dictionary')
258
+
259
+ gtag('event', 'page_view', {
260
+ page_location: window.location.pathname + location.search,
261
+ })
262
+ }
263
+ getData(txtBox.value.toLowerCase())
264
+ // addFilterCount()
265
+
266
+ }
267
+
268
+ let selectedDictionary = document.querySelector('.select_dropDown2')
269
+ selectedDictionary.addEventListener("change", ((e) => {
270
+ logSubmit(e)
271
+ }))
272
+
273
+
274
+ // applyBtn.addEventListener('submit', logSubmit)
275
+ form.addEventListener('submit', logSubmit);
276
+
277
+
278
+ function x_with_letters(data) {
279
+ main.innerHTML = ""
280
+ if (typeof data === 'string') {
281
+ errorMsg.innerHTML = 'No words found'
282
+ wordCount.innerHTML = `<strong>Found 0 words with letters ${serachValue.split(
283
+ ''
284
+ )}</strong>`
285
+ } else {
286
+ let newWordsLength = 0
287
+ let filterData = ''
288
+ let dataArr = []
289
+
290
+
291
+ if (letterLen) {
292
+ filterData = data.filter((item) => item.length == letterLen)
293
+ }
294
+
295
+ if (prefixValue) {
296
+ filterData = filterData.filter((item2) =>
297
+ item2.startsWith(prefixValue.toLowerCase())
298
+ )
299
+ startsWith.classList.add('tick')
300
+ startsWith.value = prefixValue
301
+ } else {
302
+ startsWith.classList.remove('tick')
303
+ }
304
+ if (containsValue) {
305
+ filterData = filterData.filter((item) =>
306
+ item.includes(containsValue.toLowerCase())
307
+ )
308
+ mustInclude.classList.add('tick')
309
+ mustInclude.value = containsValue
310
+ } else {
311
+ mustInclude.classList.remove('tick')
312
+ }
313
+ if (suffixValue) {
314
+ filterData = filterData.filter((item) =>
315
+ item.endsWith(suffixValue.toLowerCase())
316
+ )
317
+ endsWith.classList.add('tick')
318
+ endsWith.value = suffixValue
319
+ } else {
320
+ endsWith.classList.remove('tick')
321
+ }
322
+ if (exculdeValue) {
323
+ let data = []
324
+ filterData.map((item) => {
325
+ let check = false
326
+ for (let e = 0; e < exculdeValue.length; e++) {
327
+ const element = exculdeValue[e].toLowerCase()
328
+ if (item.includes(element)) {
329
+ check = true
330
+ break
331
+ } else {
332
+ check = false
333
+ }
334
+ }
335
+ if (check === false) {
336
+ data.push(item)
337
+ }
338
+ })
339
+ exculdeWith.classList.add('tick')
340
+ exculdeWith.value = exculdeValue
341
+ filterData = data
342
+ } else {
343
+ exculdeWith.classList.remove('tick')
344
+ }
345
+
346
+ if (includeValue) {
347
+ let data = []
348
+ filterData.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
+ filterData = data
366
+ } else {
367
+ inculdeWith.classList.remove('tick')
368
+ }
369
+
370
+ if (filterData.length === 0) {
371
+ main.innerHTML += ''
372
+ errorMsg.innerHTML = 'No words Found with this length'
373
+ } else {
374
+
375
+ newWordsLength += filterData.length
376
+ let itemLength = ''
377
+ const result = filterData.map((item) => {
378
+ itemLength = item.length
379
+ let ScrabbleLetterScore = ScrabbleScore()
380
+ sum = 0
381
+ item = item.toLowerCase()
382
+ for (let i = 0; i < item.length; i++) {
383
+ sum += ScrabbleLetterScore[item[i]] || 0 // for unknown characters
384
+ }
385
+ wordLength.value = itemLength
386
+
387
+ var text1 = serachValue.replace('?', '')
388
+ var text2 = item
389
+ var text3 = item
390
+ function findIndex(str, char) {
391
+ const strLength = str.length
392
+ const indexes = []
393
+ let newStr = str
394
+ while (newStr && newStr.indexOf(char) > -1) {
395
+ indexes.push(newStr.indexOf(char) + strLength - newStr.length)
396
+ newStr = newStr.substring(newStr.indexOf(char) + 1)
397
+ newStr = newStr.substring(newStr.indexOf(char) + 1)
398
+ }
399
+ return indexes
400
+ }
401
+ let chars = text1.split('')
402
+ let indexs = []
403
+ chars.map((i) => {
404
+ let findIndexes = findIndex(text3, i)
405
+ if (findIndexes.length > 0) {
406
+ text3 = text3.split('')
407
+ text3[findIndexes] = '$'
408
+ text3 = text3.join('')
409
+ indexs = [...indexs, ...findIndexes]
410
+ }
411
+ })
412
+ let itemHtml = ''
413
+ text2.split('').map((itemValue, index) => {
414
+ let check = indexs.find((i) => i === index)
415
+ if (check !== undefined) {
416
+ itemHtml += `${itemValue}`
417
+ } else {
418
+ itemHtml += `<span class='highlight'>${itemValue}</span>`
419
+ }
420
+ })
421
+
422
+ dataArr.push(item)
423
+ return `<a class="anchor__style" title="Lookup ${item} in Dictionary" target="_blank" href="/word-meaning?search=${item}">
424
+ <li>${itemHtml}
425
+ <span class="points" value="${sum}" style="position:relative; top:4px; font-size:12px"> ${sum}</span>
426
+ </li></a>`
427
+ })
428
+
429
+ // tab_container.innerHTML += `
430
+ // <a href="#${itemLength}">
431
+ // <input type="button" value="${itemLength} Letter" id="Tab${itemLength}" onclick="addFilter(${itemLength})"
432
+ // class="tab_link">
433
+ // </a>
434
+ // `
435
+
436
+ // let tabs = document.getElementsByClassName('tab_link')
437
+ // tabs[0] ? tabs[0].classList.add('active-tab') : ''
438
+
439
+ home_page_search_result.href = homePageSearchResult
440
+ home_page_search_result.innerHTML = `See words of any length with letters ${serachValue.split("")}`
441
+
442
+
443
+ main.innerHTML += `
444
+ <div class="allGroupWords">
445
+ <div class="wordListHeading">
446
+ <h3 class="lead">${itemLength} Letter Words</h3>
447
+ </div>
448
+ <div class="wordList">
449
+ <ul class="ul list-unstyled">
450
+ ${result.join('')}
451
+ </ul>
452
+ </div>
453
+ </div>
454
+ `
455
+
456
+ // sort eventlistener
457
+ theSelect.addEventListener('change', () => {
458
+ sortValue = theSelect[theSelect.selectedIndex].text
459
+ if (sortValue == 'Z-A') {
460
+ sortBool = true
461
+ sortby(sortBool, dataArr, itemLength)
462
+ } else {
463
+ sortBool = false
464
+ sortby(sortBool, dataArr, itemLength)
465
+ }
466
+ if (sortValue == 'Points') {
467
+ sortBool = true
468
+ sortPointsby(sortBool, dataArr, itemLength)
469
+ }
470
+ })
471
+
472
+ sortValue = theSelect[theSelect.selectedIndex].text
473
+ if (sortValue == 'Z-A') {
474
+ sortby(sortBool, dataArr, itemLength)
475
+ }
476
+ if (sortValue == 'Points') {
477
+ sortPointsby(sortBool, dataArr, itemLength)
478
+ }
479
+
480
+
481
+ }
482
+
483
+ wordCount.innerHTML = `<strong>Found ${newWordsLength} words with letters with ${serachValue.split(
484
+ ''
485
+ )}</strong>`
486
+ }
487
+ }
488
+
489
+ //Handling of filter counter in advanced filter
490
+ function addFilterCount() {
491
+ let filter_val = document.getElementsByClassName('filter_val')
492
+ let filter = document.querySelector('.filter_count')
493
+ let filter_count = 0
494
+
495
+ filter_val[0].value = prefixValue
496
+ filter_val[1].value = containsValue
497
+ filter_val[2].value = suffixValue
498
+ filter_val[3].value = exculdeValue
499
+ filter_val[4].value = includeValue
500
+ filter_val[5].value = lengthValue
501
+
502
+ for (var i = 0; i <= 4; i++) {
503
+ if (filter_val[i].value != '') {
504
+ filter_count += 1
505
+ }
506
+ if (filter_count === 0) {
507
+ filter.style.display = 'none'
508
+ } else {
509
+ filter.style.display = 'inline-block'
510
+ }
511
+
512
+ filter.innerHTML = filter_count
513
+ }
514
+ }
515
+ // addFilterCount()
516
+
517
+ // sorting by points
518
+ function sortPointsby(sortValue, data, i) {
519
+ if (sortValue) {
520
+ main.innerHTML = ''
521
+ let newArray = []
522
+ data.map((item) => {
523
+ let ScrabbleLetterScore = ScrabbleScore()
524
+ let points = 0
525
+ item = item.toLowerCase()
526
+ for (let i = 0; i < item.length; i++) {
527
+ points += ScrabbleLetterScore[item[i]] || 0 // for unknown characters
528
+ }
529
+ const value = {
530
+ words: item,
531
+ points: points,
532
+ }
533
+ newArray.push(value)
534
+ newArray.sort(function (a, b) {
535
+ return b.points - a.points
536
+ })
537
+ })
538
+ const result = newArray.map((item) => {
539
+ var text1 = serachValue.replace('?', '')
540
+ var text2 = item.words
541
+ var text3 = item.words
542
+ function findIndex(str, char) {
543
+ const strLength = str.length
544
+ const indexes = []
545
+ let newStr = str
546
+ while (newStr && newStr.indexOf(char) > -1) {
547
+ indexes.push(newStr.indexOf(char) + strLength - newStr.length)
548
+ newStr = newStr.substring(newStr.indexOf(char) + 1)
549
+ newStr = newStr.substring(newStr.indexOf(char) + 1)
550
+ }
551
+ return indexes
552
+ }
553
+ let chars = text1.split('')
554
+ let indexs = []
555
+ chars.map((i) => {
556
+ let findIndexes = findIndex(text3, i)
557
+ if (findIndexes.length > 0) {
558
+ text3 = text3.split('')
559
+ text3[findIndexes] = '$'
560
+ text3 = text3.join('')
561
+ indexs = [...indexs, ...findIndexes]
562
+ }
563
+ })
564
+ let itemHtml = ''
565
+ text2.split('').map((itemValue, index) => {
566
+ let check = indexs.find((i) => i === index)
567
+ if (check !== undefined) {
568
+ itemHtml += `${itemValue}`
569
+ } else {
570
+ itemHtml += `<span class='highlight'>${itemValue}</span>`
571
+ }
572
+ })
573
+ return `<a class="anchor__style" title="Lookup ${item} in Dictionary" target="_blank" href="/word-meaning?search=${item.words}">
574
+ <li>${itemHtml}
575
+ <span class="points" value="${item.points}" style="position:relative; top:4px; font-size:12px"> ${item.points}</span>
576
+ </li></a>`
577
+ })
578
+
579
+ main.innerHTML += `
580
+ <div class="allGroupWords wordlistContainer" id="alpha_${i}">
581
+ <div class="wordListHeading">
582
+ <h3 class="lead">${i} Letter Words</h3>
583
+ </div>
584
+ <div class="wordList">
585
+ <ul class="ul list-unstyled">
586
+ ${result.join('')}
587
+ </ul>
588
+ </div>
589
+ </div>
590
+ `
591
+ }
592
+ }
593
+ // sort by aplhabets
594
+ function sortby(sortBool, data, i) {
595
+ if (sortBool) {
596
+ main.innerHTML = ''
597
+ data.reverse()
598
+ const result = data.map((item) => {
599
+ let ScrabbleLetterScore = ScrabbleScore()
600
+ let sum = 0
601
+ item = item.toLowerCase()
602
+ for (let i = 0; i < item.length; i++) {
603
+ sum += ScrabbleLetterScore[item[i]] || 0 // for unknown characters
604
+ }
605
+
606
+ var text1 = serachValue.replace('?', '')
607
+ var text2 = item
608
+ var text3 = item
609
+ function findIndex(str, char) {
610
+ const strLength = str.length
611
+ const indexes = []
612
+ let newStr = str
613
+ while (newStr && newStr.indexOf(char) > -1) {
614
+ indexes.push(newStr.indexOf(char) + strLength - newStr.length)
615
+ newStr = newStr.substring(newStr.indexOf(char) + 1)
616
+ newStr = newStr.substring(newStr.indexOf(char) + 1)
617
+ }
618
+ return indexes
619
+ }
620
+ let chars = text1.split('')
621
+ let indexs = []
622
+ chars.map((i) => {
623
+ let findIndexes = findIndex(text3, i)
624
+ if (findIndexes.length > 0) {
625
+ text3 = text3.split('')
626
+ text3[findIndexes] = '$'
627
+ text3 = text3.join('')
628
+ indexs = [...indexs, ...findIndexes]
629
+ }
630
+ })
631
+ let itemHtml = ''
632
+ text2.split('').map((itemValue, index) => {
633
+ let check = indexs.find((i) => i === index)
634
+ if (check !== undefined) {
635
+ itemHtml += `${itemValue}`
636
+ } else {
637
+ itemHtml += `<span class='highlight'>${itemValue}</span>`
638
+ }
639
+ })
640
+
641
+ return `<a class="anchor__style" title="Lookup ${item} in Dictionary" target="_blank" href="/word-meaning?search=${item}">
642
+ <li>${itemHtml}
643
+ <span class="points" value="${sum}" style="position:relative; top:4px; font-size:12px"> ${sum}</span>
644
+ </li></a>`
645
+ })
646
+
647
+ main.innerHTML += `
648
+ <div class="allGroupWords wordlistContainer" id="alpha_${i}">
649
+ <div class="wordListHeading">
650
+ <h3 class="lead">${i} Letter Words</h3>
651
+ </div>
652
+ <div class="wordList">
653
+ <ul class="ul list-unstyled">
654
+ ${result.join('')}
655
+ </ul>
656
+ </div>
657
+ </div>
658
+
659
+ `
660
+ } else {
661
+ main.innerHTML = ''
662
+ data.sort()
663
+ const result = data.map((item) => {
664
+ let ScrabbleLetterScore = ScrabbleScore()
665
+ let sum = 0
666
+ item = item.toLowerCase()
667
+ for (let i = 0; i < item.length; i++) {
668
+ sum += ScrabbleLetterScore[item[i]] || 0 // for unknown characters
669
+ }
670
+
671
+ var text1 = serachValue.replace('?', '')
672
+ var text2 = item
673
+ var text3 = item
674
+ function findIndex(str, char) {
675
+ const strLength = str.length
676
+ const indexes = []
677
+ let newStr = str
678
+ while (newStr && newStr.indexOf(char) > -1) {
679
+ indexes.push(newStr.indexOf(char) + strLength - newStr.length)
680
+ newStr = newStr.substring(newStr.indexOf(char) + 1)
681
+ newStr = newStr.substring(newStr.indexOf(char) + 1)
682
+ }
683
+ return indexes
684
+ }
685
+ let chars = text1.split('')
686
+ let indexs = []
687
+ chars.map((i) => {
688
+ let findIndexes = findIndex(text3, i)
689
+ if (findIndexes.length > 0) {
690
+ text3 = text3.split('')
691
+ text3[findIndexes] = '$'
692
+ text3 = text3.join('')
693
+ indexs = [...indexs, ...findIndexes]
694
+ }
695
+ })
696
+ let itemHtml = ''
697
+ text2.split('').map((itemValue, index) => {
698
+ let check = indexs.find((i) => i === index)
699
+ if (check !== undefined) {
700
+ itemHtml += `${itemValue}`
701
+ } else {
702
+ itemHtml += `<span class='highlight'>${itemValue}</span>`
703
+ }
704
+ })
705
+
706
+ return `<a class="anchor__style" title="Lookup ${item} in Dictionary" target="_blank" href="/word-meaning?search=${item}">
707
+ <li>${itemHtml}
708
+ <span class="points" value="${sum}" style="position:relative; top:4px; font-size:12px"> ${sum}</span>
709
+ </li></a>`
710
+ })
711
+
712
+ main.innerHTML += `
713
+ <div class="allGroupWords wordlistContainer" id="alpha_${i}">
714
+ <div class="wordListHeading">
715
+ <h3 class="lead">${i} Letter Words</h3>
716
+ </div>
717
+ <div class="wordList">
718
+ <ul class="ul list-unstyled">
719
+ ${result.join('')}
720
+ </ul>
721
+ </div>
722
+ </div>
723
+
724
+ `
725
+ }
726
+ }
727
+
728
+ // Implement Active class
729
+ // const addFilter = () => {
730
+ // let tabs = document.getElementsByClassName('tab_link')
731
+ // tabs[0] ? tabs[0].classList.add('active-tab') : ''
732
+
733
+ // Array.from(tabs).map((item) => {
734
+ // item.classList.remove('active-tab')
735
+ // })
736
+ // main.innerHTML += ``
737
+ // let activeLetter = event.target
738
+ // // console.log(activeLetter)
739
+ // activeLetter.classList.add('active-tab')
740
+ // }