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