word-games-theme 2.8.0 → 2.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/assets/js/wordfinder-worker.js +262 -0
- data/assets/js/wordfinder.js +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 17543ce741f1baf1603be070f547faa129ea0b2703492c0fa418cbea54fbd50a
|
|
4
|
+
data.tar.gz: d8b0b9bd3b601d0a247d0c12d138bbd42c9897cf4cb40992624c384f8b6b83ba
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 405d3f0bccfa8c5ba69aab5c1ef9e1c4208266a1a29f6e4f3425f5ebaa4578087d070c5cc5857fa446eaeb01b3818768003a9cf2f227c0391157ade011a05d5a
|
|
7
|
+
data.tar.gz: a41b7171d014c4c82036d7935f61c8000d5b3ac06f2b8b37aef9698bad619dc3aa2d502ba07154d599fe28eba85b5b8f39e8482f2bc0439ebea9be880f2326b5
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
self.onmessage = async (event) => {
|
|
2
|
+
if (event.data.type === "api") {
|
|
3
|
+
const { endpoint, serachValue, selectedDictionary } = event.data
|
|
4
|
+
let response
|
|
5
|
+
if (serachValue) {
|
|
6
|
+
response = await fetch(`${endpoint}/getWords?name=${serachValue}&selecteddictionary=${selectedDictionary}`);
|
|
7
|
+
} else {
|
|
8
|
+
response = await fetch(`${endpoint}/getData?name=${serachValue}&selecteddictionary=${selectedDictionary}`);
|
|
9
|
+
}
|
|
10
|
+
const data = await response.json();
|
|
11
|
+
self.postMessage({ data });
|
|
12
|
+
}
|
|
13
|
+
if (event.data.type === "filterwords") {
|
|
14
|
+
const { data, serachValue, prefixValue, containsValue, suffixValue, exculdeValue, includeValue, lengthValue, sortingFilter, dictonary } = event.data
|
|
15
|
+
let newWordsLength = 0;
|
|
16
|
+
for (let i = 15; i > 0; i--) {
|
|
17
|
+
let newdata = data.filter((item) => item.length === i);
|
|
18
|
+
if (prefixValue) {
|
|
19
|
+
newdata = newdata.filter((item2) =>
|
|
20
|
+
item2.startsWith(prefixValue.toLowerCase())
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
if (containsValue) {
|
|
24
|
+
newdata = newdata.filter((item) =>
|
|
25
|
+
item.includes(containsValue.toLowerCase())
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
if (suffixValue) {
|
|
29
|
+
newdata = newdata.filter((item) =>
|
|
30
|
+
item.endsWith(suffixValue.toLowerCase())
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
if (exculdeValue) {
|
|
34
|
+
let data = [];
|
|
35
|
+
newdata.map((item) => {
|
|
36
|
+
let check = false;
|
|
37
|
+
for (let e = 0; e < exculdeValue.length; e++) {
|
|
38
|
+
const element = exculdeValue[e].toLowerCase();
|
|
39
|
+
if (item.includes(element)) {
|
|
40
|
+
check = true;
|
|
41
|
+
break;
|
|
42
|
+
} else {
|
|
43
|
+
check = false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (check === false) {
|
|
47
|
+
data.push(item);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
newdata = data;
|
|
51
|
+
}
|
|
52
|
+
if (includeValue) {
|
|
53
|
+
let data = [];
|
|
54
|
+
newdata.map((item) => {
|
|
55
|
+
let check = false;
|
|
56
|
+
for (let e = 0; e < includeValue.length; e++) {
|
|
57
|
+
const element = includeValue[e].toLowerCase();
|
|
58
|
+
if (!item.includes(element)) {
|
|
59
|
+
check = true;
|
|
60
|
+
break;
|
|
61
|
+
} else {
|
|
62
|
+
check = false;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (check === false) {
|
|
66
|
+
data.push(item);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
newdata = data;
|
|
70
|
+
}
|
|
71
|
+
if (lengthValue) {
|
|
72
|
+
newdata = newdata.filter((item) => item.length == lengthValue);
|
|
73
|
+
}
|
|
74
|
+
// if (newdata.length === 0) {
|
|
75
|
+
// } else {
|
|
76
|
+
newWordsLength += newdata.length;
|
|
77
|
+
newdata = sortWords(sortingFilter, newdata, dictonary);
|
|
78
|
+
let result = newdata.map((item) => {
|
|
79
|
+
let itemHtml = "";
|
|
80
|
+
if (serachValue) {
|
|
81
|
+
var text1 = serachValue.replace("?", "");
|
|
82
|
+
var text2 = item;
|
|
83
|
+
var text3 = item;
|
|
84
|
+
let chars = text1.split("");
|
|
85
|
+
let indexs = [];
|
|
86
|
+
chars.map((i) => {
|
|
87
|
+
let findIndexes = findIndex(text3, i);
|
|
88
|
+
if (findIndexes.length > 0) {
|
|
89
|
+
text3 = text3.split("");
|
|
90
|
+
text3[findIndexes] = "$";
|
|
91
|
+
text3 = text3.join("");
|
|
92
|
+
indexs = [...indexs, ...findIndexes];
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
text2.split("").map((itemValue, index) => {
|
|
96
|
+
let check = indexs.find((i) => i === index);
|
|
97
|
+
if (check !== undefined) {
|
|
98
|
+
itemHtml += `${itemValue}`;
|
|
99
|
+
} else {
|
|
100
|
+
itemHtml += `<span class='highlight'>${itemValue}</span>`;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
} else {
|
|
104
|
+
itemHtml = item
|
|
105
|
+
}
|
|
106
|
+
if (item.length === 1) {
|
|
107
|
+
ok = false;
|
|
108
|
+
newWordsLength = newWordsLength - 1;
|
|
109
|
+
} else {
|
|
110
|
+
let ScrabbleLetterScore = ScrabbleScore();
|
|
111
|
+
sum = 0;
|
|
112
|
+
item = item.toLowerCase();
|
|
113
|
+
for (let i = 0; i < item.length; i++) {
|
|
114
|
+
sum += ScrabbleLetterScore[item[i]] || 0; // for unknown characters
|
|
115
|
+
}
|
|
116
|
+
return `
|
|
117
|
+
<a class="anchor__style" title="Lookup ${item} in Dictionary" target="_blank" href="/word-meaning?search=${item.toLowerCase()}">
|
|
118
|
+
${itemHtml}
|
|
119
|
+
<span class="points" value="${sum}" style="position:relative; top:4px; font-size:12px">${sum}</span>
|
|
120
|
+
</a>
|
|
121
|
+
`;
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
result = result.slice(0, 25)
|
|
125
|
+
self.postMessage({
|
|
126
|
+
type: "filterwords",
|
|
127
|
+
prefixValue: prefixValue,
|
|
128
|
+
containsValue: containsValue,
|
|
129
|
+
suffixValue: suffixValue,
|
|
130
|
+
exculdeValue: exculdeValue,
|
|
131
|
+
includeValue: includeValue,
|
|
132
|
+
lengthValue: lengthValue,
|
|
133
|
+
newdata: newdata,
|
|
134
|
+
i: i,
|
|
135
|
+
newWordsLength: newWordsLength,
|
|
136
|
+
result,
|
|
137
|
+
});
|
|
138
|
+
// }
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
function sortWords(sortingFilter, data, dictonary) {
|
|
145
|
+
if (sortingFilter == 0) {
|
|
146
|
+
return data;
|
|
147
|
+
} else if (sortingFilter == 1) {
|
|
148
|
+
return data.sort();
|
|
149
|
+
} else if (sortingFilter == 2) {
|
|
150
|
+
return data.reverse();
|
|
151
|
+
} else if (sortingFilter == 3) {
|
|
152
|
+
var tempArr = [];
|
|
153
|
+
var newArray = [];
|
|
154
|
+
data.map((item) => {
|
|
155
|
+
let newWordsLength = 0;
|
|
156
|
+
if (item.length === 1) {
|
|
157
|
+
ok = false;
|
|
158
|
+
newWordsLength = newWordsLength - 1;
|
|
159
|
+
} else {
|
|
160
|
+
let ScrabbleLetterScore = ScrabbleScore(dictonary);
|
|
161
|
+
let points = 0;
|
|
162
|
+
item = item.toLowerCase();
|
|
163
|
+
for (let i = 0; i < item.length; i++) {
|
|
164
|
+
points += ScrabbleLetterScore[item[i]] || 0; // for unknown characters
|
|
165
|
+
}
|
|
166
|
+
const value = {
|
|
167
|
+
words: item,
|
|
168
|
+
points: points,
|
|
169
|
+
};
|
|
170
|
+
newArray.push(value);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
newArray.sort(function (a, b) {
|
|
175
|
+
return b.points - a.points;
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
newArray.map((ele) => {
|
|
179
|
+
tempArr.push(ele.words);
|
|
180
|
+
});
|
|
181
|
+
return tempArr;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
// Scrabble Point Array
|
|
185
|
+
const ScrabbleScore = (dictonary) => {
|
|
186
|
+
let twl06_sowpods = {
|
|
187
|
+
a: 1,
|
|
188
|
+
e: 1,
|
|
189
|
+
i: 1,
|
|
190
|
+
o: 1,
|
|
191
|
+
u: 1,
|
|
192
|
+
l: 1,
|
|
193
|
+
n: 1,
|
|
194
|
+
r: 1,
|
|
195
|
+
s: 1,
|
|
196
|
+
t: 1,
|
|
197
|
+
d: 2,
|
|
198
|
+
g: 2,
|
|
199
|
+
b: 3,
|
|
200
|
+
c: 3,
|
|
201
|
+
m: 3,
|
|
202
|
+
p: 3,
|
|
203
|
+
f: 4,
|
|
204
|
+
h: 4,
|
|
205
|
+
v: 4,
|
|
206
|
+
w: 4,
|
|
207
|
+
y: 4,
|
|
208
|
+
k: 5,
|
|
209
|
+
j: 8,
|
|
210
|
+
x: 8,
|
|
211
|
+
q: 10,
|
|
212
|
+
z: 10,
|
|
213
|
+
};
|
|
214
|
+
let wwfScore = {
|
|
215
|
+
a: 1,
|
|
216
|
+
b: 4,
|
|
217
|
+
c: 4,
|
|
218
|
+
d: 2,
|
|
219
|
+
e: 1,
|
|
220
|
+
f: 4,
|
|
221
|
+
g: 3,
|
|
222
|
+
h: 3,
|
|
223
|
+
i: 1,
|
|
224
|
+
j: 10,
|
|
225
|
+
k: 5,
|
|
226
|
+
l: 2,
|
|
227
|
+
m: 4,
|
|
228
|
+
n: 2,
|
|
229
|
+
o: 1,
|
|
230
|
+
p: 4,
|
|
231
|
+
q: 10,
|
|
232
|
+
r: 1,
|
|
233
|
+
s: 1,
|
|
234
|
+
t: 1,
|
|
235
|
+
u: 2,
|
|
236
|
+
v: 5,
|
|
237
|
+
w: 4,
|
|
238
|
+
x: 8,
|
|
239
|
+
y: 3,
|
|
240
|
+
z: 10,
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
if (dictonary === "wwf") {
|
|
244
|
+
return wwfScore;
|
|
245
|
+
} else {
|
|
246
|
+
return twl06_sowpods;
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
function findIndex(str, char) {
|
|
251
|
+
const strLength = str.length;
|
|
252
|
+
const indexes = [];
|
|
253
|
+
let newStr = str;
|
|
254
|
+
|
|
255
|
+
while (newStr && newStr.indexOf(char) > -1) {
|
|
256
|
+
indexes.push(newStr.indexOf(char) + strLength - newStr.length);
|
|
257
|
+
newStr = newStr.substring(newStr.indexOf(char) + 5);
|
|
258
|
+
newStr = newStr.substring(newStr.indexOf(char) + 5);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
return indexes;
|
|
262
|
+
}
|
data/assets/js/wordfinder.js
CHANGED
|
@@ -76,7 +76,7 @@ let serachBtn = document.querySelector(".serachBtn")
|
|
|
76
76
|
let searchBtnContainer = document.querySelector(".search-btn-container")
|
|
77
77
|
|
|
78
78
|
// getWords define...
|
|
79
|
-
const worker = new Worker('wordfinder-worker.js');
|
|
79
|
+
const worker = new Worker('./assets/js/wordfinder-worker.js');
|
|
80
80
|
const getData = async (serachValue) => {
|
|
81
81
|
try {
|
|
82
82
|
document.querySelector(".main-header").style.background = "#fff"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: word-games-theme
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.8.
|
|
4
|
+
version: 2.8.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- manpreet-appscms
|
|
@@ -393,6 +393,7 @@ files:
|
|
|
393
393
|
- assets/js/wordScrabble-test.js
|
|
394
394
|
- assets/js/wordScrabble.js
|
|
395
395
|
- assets/js/wordfinder-home.js
|
|
396
|
+
- assets/js/wordfinder-worker.js
|
|
396
397
|
- assets/js/wordfinder.js
|
|
397
398
|
- assets/js/wordgames-home.js
|
|
398
399
|
- assets/js/wordgames-result.js
|