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