word-games-theme 3.2.8 → 3.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 900611bb28204da634f1165025f425f840de6edb5d29797dd82e0319b7104ba3
4
- data.tar.gz: 0f8ddc00d1856577f7b4002feb303ad90d9d1ce763c0639214c1748b4c98cd85
3
+ metadata.gz: 303593070d80b64a5932a3e7c0df9452e8310db4cc1b3cf99859f4e64031aa69
4
+ data.tar.gz: '08b7c920e3c4bdbb16ccc72f7e36b51557c63f620b217dc6086561e929c76033'
5
5
  SHA512:
6
- metadata.gz: 923014eea445e747a893542af0bd47ebac8add509bb2975fac87f6bf5046d17dfd878f210e24695d1502631192c8e24e3875d3966ae05cd431d642cd828bbd15
7
- data.tar.gz: 5bfaa100c83aca7ab9ad2cad9f5480d431b703c8c6f4a857d34a66e1c5f293fde577576ecf7f0dd3d423ca91d5d5f5db6cafada0e4c41d9f048f7da62a81dfe6
6
+ metadata.gz: 1d7695f45979cbe6ea891c267d1685ff0f6c09601abf33987efdc77b0cb52130746669c645b14c1db59f6828ef0d7fed588f40daa8f83df837b624d576f6fe75
7
+ data.tar.gz: ee14c79d178c1ef005b22b7b34569bd5d59a37ca251ffead87226b24eed8560920d977303aefacffa641b9cf8fa57d35683b166e52edcd2d01d90428f475d23b
@@ -20,7 +20,8 @@
20
20
  z-index: 1;
21
21
  max-height: 300px;
22
22
  height: auto;
23
- overflow-y: scroll;
23
+ overflow-y: hidden;
24
+ overflow-x: auto;
24
25
  border-radius: 8px;
25
26
  }
26
27
 
@@ -18,7 +18,7 @@
18
18
  <style>
19
19
  .main-header {
20
20
  margin: 0px !important;
21
- background-image: radial-gradient(#e4e4f4 2px, transparent 2px);
21
+ /* background-image: radial-gradient(#e4e4f4 2px, transparent 2px); */
22
22
  background-size: 25px 25px;
23
23
  background-color: unset !important;
24
24
  }
@@ -28,7 +28,7 @@
28
28
  .main-header {
29
29
  padding-bottom: 35vh;
30
30
  margin: 0px !important;
31
- background-image: radial-gradient(#e4e4f4 2px, transparent 2px);
31
+ /* background-image: radial-gradient(#e4e4f4 2px, transparent 2px); */
32
32
  background-size: 25px 25px;
33
33
  background-color: unset !important;
34
34
  }
@@ -6,15 +6,79 @@ let defintions = document.querySelector("#Defintions")
6
6
  let txtBox = document.querySelector('.txtBox')
7
7
  txtBox.value = serachValue
8
8
 
9
- defintions.innerHTML = `Defintion(s) for ${serachValue}`
9
+ defintions.innerHTML = `Defintion(s) for ${serachValue}`
10
+
11
+
12
+ const makeSynonymsClickable = (text) => {
13
+ const synonymsMatch = text.match(/Synonyms:\s*(.+?)(?:\.|$)/i);
14
+
15
+ if (synonymsMatch) {
16
+ const synonymsPart = synonymsMatch[1];
17
+ const synonyms = synonymsPart.split(',').map(s => {
18
+ // Clean the synonym text - remove HTML tags and extra characters
19
+ return s.trim()
20
+ .replace(/<[^>]*>/g, '') // Remove HTML tags
21
+ .replace(/&[^;]*;/g, '') // Remove HTML entities
22
+ .replace(/[^\w\s-]/g, '') // Keep only letters, numbers, spaces, hyphens
23
+ .trim();
24
+ }).filter(s => s.length > 0); // Remove empty strings
25
+
26
+ // Create clean links
27
+ const linkedSynonyms = synonyms.map(synonym => {
28
+ const cleanSynonym = synonym.replace(/\s+/g, '_'); // Replace spaces with underscores
29
+ return `<a href="?search=${encodeURIComponent(cleanSynonym)}" class="synonym-link">${synonym}</a>`;
30
+ }).join(', ');
31
+
32
+ return text.replace(synonymsMatch[0], `Synonyms: ${linkedSynonyms}`);
33
+ }
34
+
35
+ return text;
36
+ }
37
+
38
+ function createResultCard(entry, index) {
39
+ const synonymsHTML = entry.synonyms.length > 0
40
+ ? entry.synonyms.map(syn =>
41
+ `<span class="synonym-tag" onclick="searchForWord('${syn}')">${syn}</span>`
42
+ ).join("")
43
+ : '<span style="color: #999; font-style: italic;">No synonyms available</span>';
44
+
45
+ return `
46
+ <div class="result-card" style="animation-delay: ${index * 0.1}s">
47
+ <div class="word-title">
48
+ ${entry.word}
49
+ <span class="pos-tag">${entry.partOfSpeech || 'unknown'}</span>
50
+ </div>
51
+
52
+ <div class="definition-section">
53
+ <div class="definition-text">
54
+ ${entry.definition || 'No definition available'}
55
+ </div>
56
+ </div>
57
+
58
+ <div class="synonyms-section">
59
+ <div class="section-title">
60
+ 🔗 Synonyms ${entry.synonymCount > 0 ? `(${entry.synonymCount})` : ''}:
61
+ </div>
62
+ <div class="synonyms-container">
63
+ ${synonymsHTML}
64
+ </div>
65
+ </div>
66
+
67
+ <div class="synset-info">
68
+ <strong>Synset ID:</strong> ${entry.synsetId} |
69
+ <strong>Entry ID:</strong> ${entry.id}
70
+ </div>
71
+ </div>
72
+ `;
73
+ }
10
74
 
11
- // DICTONARY
12
75
  const fetchMeaning = async (serachValue) => {
13
76
  try {
14
77
  let resMeaning = await fetch(`/.netlify/functions/wordMeaning?search=${serachValue}`)
15
78
  let getDef = await resMeaning.text()
16
79
 
17
- if (getDef && resMeaning.status == 200) {
80
+ const hasData = getDef && resMeaning.status == 200 && getDef.trim() !== '' && getDef.trim().replace(/^"(.*)"$/, "$1") !== "&&&";
81
+ if (hasData) {
18
82
  let removeQuote = getDef.replaceAll(`"`, ``);
19
83
  let arr = removeQuote.split("&");
20
84
  let cols1 = null;
@@ -39,7 +103,7 @@ const fetchMeaning = async (serachValue) => {
39
103
  let temp = document.createElement("li");
40
104
  temp.setAttribute("class", "list-group-item my-2");
41
105
  temp.style.display = "list-item";
42
- temp.innerHTML = cols1[i];
106
+ temp.innerHTML = makeSynonymsClickable(cols1[i]);
43
107
  oList.appendChild(temp);
44
108
  }
45
109
  noun.appendChild(oList);
@@ -55,7 +119,7 @@ const fetchMeaning = async (serachValue) => {
55
119
  let temp = document.createElement("li");
56
120
  temp.setAttribute("class", "list-group-item my-2");
57
121
  temp.style.display = "list-item";
58
- temp.innerHTML = cols2[i];
122
+ temp.innerHTML = makeSynonymsClickable(cols2[i]);
59
123
  oList.appendChild(temp);
60
124
  }
61
125
  verb.appendChild(oList);
@@ -71,7 +135,7 @@ const fetchMeaning = async (serachValue) => {
71
135
  let temp = document.createElement("li");
72
136
  temp.setAttribute("class", "list-group-item my-2");
73
137
  temp.style.display = "list-item";
74
- temp.innerHTML = cols3[i];
138
+ temp.innerHTML = makeSynonymsClickable(cols3[i]);
75
139
  oList.appendChild(temp);
76
140
  }
77
141
  adj.appendChild(oList);
@@ -87,7 +151,7 @@ const fetchMeaning = async (serachValue) => {
87
151
  let temp = document.createElement("li");
88
152
  temp.setAttribute("class", "list-group-item my-2");
89
153
  temp.style.display = "list-item";
90
- temp.innerHTML = cols4[i];
154
+ temp.innerHTML = makeSynonymsClickable(cols4[i]);
91
155
  oList.appendChild(temp);
92
156
  }
93
157
  adv.appendChild(oList);
@@ -96,6 +160,136 @@ const fetchMeaning = async (serachValue) => {
96
160
  document.getElementById("loaderMeaning").style.display = "none";
97
161
  document.getElementById("loaderMeaning1").style.display = "none";
98
162
  } else {
163
+ // OEWN fallback inline
164
+ try {
165
+ const response = await fetch("/assets/js/oewn_dictionary.json");
166
+ if (response.ok) {
167
+ const dictionaryData = await response.json();
168
+ const query = serachValue.toLowerCase().trim();
169
+ const exactMatches = dictionaryData.filter(entry =>
170
+ entry.word.toLowerCase() === query
171
+ );
172
+
173
+ if (exactMatches.length > 0) {
174
+ // Convert OEWN data to your format
175
+ let nounDefs = [];
176
+ let verbDefs = [];
177
+ let adjDefs = [];
178
+ let advDefs = [];
179
+
180
+ exactMatches.forEach(entry => {
181
+ const pos = entry.partOfSpeech?.toLowerCase() || 'noun';
182
+ let labeledDefinition = '';
183
+
184
+ // Add meaning label
185
+ if (entry.definition) {
186
+ labeledDefinition += `<strong style="color: #2d3748;">Meaning:</strong> ${entry.definition}`;
187
+ }
188
+
189
+ // Add synonyms label if available
190
+ if (entry.synonyms && entry.synonyms.length > 0) {
191
+ const synonymLinks = entry.synonyms.map(syn =>
192
+ `<a href="?search=${encodeURIComponent(syn)}" style="color: #007bff; text-decoration: underline;">${syn}</a>`
193
+ ).join(', ');
194
+
195
+ if (labeledDefinition) labeledDefinition += '<br><br>';
196
+ labeledDefinition += `<strong style="color: #2d3748;">Synonyms:</strong> ${synonymLinks}`;
197
+ }
198
+
199
+ switch(pos) {
200
+ case 'noun': case 'n':
201
+ nounDefs.push(labeledDefinition);
202
+ break;
203
+ case 'verb': case 'v':
204
+ verbDefs.push(labeledDefinition);
205
+ break;
206
+ case 'adjective': case 'adj': case 'a':
207
+ adjDefs.push(labeledDefinition);
208
+ break;
209
+ case 'adverb': case 'adv': case 'r':
210
+ advDefs.push(labeledDefinition);
211
+ break;
212
+ default:
213
+ nounDefs.push(labeledDefinition);
214
+ }})
215
+
216
+ // Process OEWN data using your existing logic
217
+ if (nounDefs.length > 0) {
218
+ let noun = document.getElementById("noun");
219
+ let oList = document.createElement("ol");
220
+ oList.setAttribute("class", "list-group list-group-numbered");
221
+ for (let i = 0; i < nounDefs.length; i++) {
222
+ let temp = document.createElement("li");
223
+ temp.setAttribute("class", "list-group-item my-2");
224
+ temp.style.display = "list-item";
225
+ temp.innerHTML = makeSynonymsClickable(nounDefs[i]);
226
+ oList.appendChild(temp);
227
+ }
228
+ noun.appendChild(oList);
229
+ noun.style.display = "inherit";
230
+ }
231
+
232
+ if (verbDefs.length > 0) {
233
+ let verb = document.getElementById("verb");
234
+ let oList = document.createElement("ol");
235
+ oList.setAttribute("class", "list-group list-group-numbered");
236
+ for (let i = 0; i < verbDefs.length; i++) {
237
+ let temp = document.createElement("li");
238
+ temp.setAttribute("class", "list-group-item my-2");
239
+ temp.style.display = "list-item";
240
+ temp.innerHTML = makeSynonymsClickable(verbDefs[i]);
241
+ oList.appendChild(temp);
242
+ }
243
+ verb.appendChild(oList);
244
+ verb.style.display = "inherit";
245
+ }
246
+
247
+ if (adjDefs.length > 0) {
248
+ let adj = document.getElementById("adj");
249
+ let oList = document.createElement("ol");
250
+ oList.setAttribute("class", "list-group list-group-numbered");
251
+ for (let i = 0; i < adjDefs.length; i++) {
252
+ let temp = document.createElement("li");
253
+ temp.setAttribute("class", "list-group-item my-2");
254
+ temp.style.display = "list-item";
255
+ temp.innerHTML = makeSynonymsClickable(adjDefs[i]);
256
+ oList.appendChild(temp);
257
+ }
258
+ adj.appendChild(oList);
259
+ adj.style.display = "inherit";
260
+ }
261
+
262
+ if (advDefs.length > 0) {
263
+ let adv = document.getElementById("adv");
264
+ let oList = document.createElement("ol");
265
+ oList.setAttribute("class", "list-group list-group-numbered");
266
+ for (let i = 0; i < advDefs.length; i++) {
267
+ let temp = document.createElement("li");
268
+ temp.setAttribute("class", "list-group-item my-2");
269
+ temp.style.display = "list-item";
270
+ temp.innerHTML = makeSynonymsClickable(advDefs[i]);
271
+ oList.appendChild(temp);
272
+ }
273
+ adv.appendChild(oList);
274
+ adv.style.display = "inherit";
275
+ }
276
+
277
+ // Show fallback indicator
278
+ const indicator = document.createElement('div');
279
+ indicator.innerHTML = ``;
280
+ const defintions = document.querySelector("#Defintions");
281
+ if (defintions) defintions.parentNode.insertBefore(indicator, defintions.nextElementSibling);
282
+
283
+ document.getElementById("loaderMeaning").style.display = "none";
284
+ document.getElementById("loaderMeaning1").style.display = "none";
285
+ return; // Exit successfully
286
+ }
287
+ }
288
+ } catch (oewnError) {
289
+ console.log("OEWN fallback failed:", oewnError);
290
+ }
291
+
292
+ // Show error if both primary and OEWN fail
99
293
  document.getElementById("loaderMeaning").style.display = "none";
100
294
  document.getElementById("loaderMeaning1").style.display = "none";
101
295
  document.getElementById("err").style.display = "block";
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: word-games-theme
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.8
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - manpreet-appscms
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-02-18 00:00:00.000000000 Z
11
+ date: 2025-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll