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f8;
|
11 |
+
--text-color: #333;
|
12 |
+
--accent-color: #007bff; /* Blue */
|
13 |
+
--nav-bg-color: #e9ecef;
|
14 |
+
--nav-text-color: #343a40;
|
15 |
+
--section-bg-color: #fff;
|
16 |
+
--footer-bg-color: #343a40;
|
17 |
+
--footer-text-color: #fff;
|
18 |
+
--button-bg-color: #007bff;
|
19 |
+
--button-text-color: #fff;
|
20 |
+
--button-hover-bg-color: #0056b3;
|
21 |
+
--link-color: #007bff;
|
22 |
+
--link-hover-color: #0056b3;
|
23 |
+
|
24 |
+
/* Dark mode colors */
|
25 |
+
--dark-bg-color: #222;
|
26 |
+
--dark-text-color: #eee;
|
27 |
+
--dark-accent-color: #66b3ff; /* Light blue */
|
28 |
+
--dark-nav-bg-color: #444;
|
29 |
+
--dark-nav-text-color: #eee;
|
30 |
+
--dark-section-bg-color: #333;
|
31 |
+
--dark-footer-bg-color: #111;
|
32 |
+
--dark-footer-text-color: #eee;
|
33 |
+
--dark-button-bg-color: #66b3ff;
|
34 |
+
--dark-button-text-color: #222;
|
35 |
+
--dark-button-hover-bg-color: #3399ff;
|
36 |
+
--dark-link-color: #66b3ff;
|
37 |
+
--dark-link-hover-color: #3399ff;
|
38 |
+
|
39 |
+
--highlight-color: #ffdddd;
|
40 |
+
--highlight-hover-color: #ffcccc;
|
41 |
+
--similar-word-color: #007bff;
|
42 |
+
--replaced-word-color: #4CAF50;
|
43 |
+
}
|
44 |
+
|
45 |
+
body {
|
46 |
+
font-family: Arial, sans-serif;
|
47 |
+
line-height: 1.6;
|
48 |
+
background-color: var(--bg-color);
|
49 |
+
color: var(--text-color);
|
50 |
+
display: flex;
|
51 |
+
min-height: 100vh;
|
52 |
+
flex-direction: column;
|
53 |
+
transition: background-color 0.3s, color 0.3s;
|
54 |
+
margin: 0;
|
55 |
+
padding: 0;
|
56 |
+
}
|
57 |
+
|
58 |
+
body.dark-mode {
|
59 |
+
background-color: var(--dark-bg-color);
|
60 |
+
color: var(--dark-text-color);
|
61 |
+
}
|
62 |
+
|
63 |
+
header {
|
64 |
+
background-color: var(--accent-color);
|
65 |
+
color: #fff;
|
66 |
+
padding: 20px;
|
67 |
+
text-align: center;
|
68 |
+
}
|
69 |
+
|
70 |
+
body.dark-mode header {
|
71 |
+
background-color: var(--dark-accent-color);
|
72 |
+
}
|
73 |
+
|
74 |
+
h1 {
|
75 |
+
margin: 0;
|
76 |
+
font-size: 2.5rem;
|
77 |
+
}
|
78 |
+
|
79 |
+
main {
|
80 |
+
padding: 20px;
|
81 |
+
flex: 1;
|
82 |
+
max-width: 800px;
|
83 |
+
margin: 0 auto;
|
84 |
+
}
|
85 |
+
|
86 |
+
h1 {
|
87 |
+
text-align: center;
|
88 |
+
color: var(--accent-color);
|
89 |
+
font-size: 128%;
|
90 |
+
}
|
91 |
+
|
92 |
+
body.dark-mode h1 {
|
93 |
+
color: var(--dark-accent-color);
|
94 |
+
}
|
95 |
+
|
96 |
+
textarea {
|
97 |
+
width: 100%;
|
98 |
+
height: 200px;
|
99 |
+
margin-bottom: 10px;
|
100 |
+
padding: 10px;
|
101 |
+
border: 1px solid #ddd;
|
102 |
+
background-color: var(--section-bg-color);
|
103 |
+
color: var(--text-color);
|
104 |
+
}
|
105 |
+
|
106 |
+
body.dark-mode textarea {
|
107 |
+
background-color: var(--dark-section-bg-color);
|
108 |
+
color: var(--dark-text-color);
|
109 |
+
}
|
110 |
+
|
111 |
+
.button-container {
|
112 |
+
display: flex;
|
113 |
+
justify-content: center;
|
114 |
+
flex-wrap: wrap;
|
115 |
+
margin-bottom: 20px;
|
116 |
+
}
|
117 |
+
|
118 |
+
.button, button {
|
119 |
+
background-color: var(--button-bg-color);
|
120 |
+
color: var(--button-text-color);
|
121 |
+
padding: 10px 20px;
|
122 |
+
border: none;
|
123 |
+
cursor: pointer;
|
124 |
+
margin: 5px;
|
125 |
+
border-radius: 5px;
|
126 |
+
}
|
127 |
+
|
128 |
+
body.dark-mode .button, body.dark-mode button {
|
129 |
+
background-color: var(--dark-button-bg-color);
|
130 |
+
color: var(--dark-button-text-color);
|
131 |
+
}
|
132 |
+
|
133 |
+
.button:hover, button:hover {
|
134 |
+
background-color: var(--button-hover-bg-color);
|
135 |
+
}
|
136 |
+
|
137 |
+
body.dark-mode .button:hover, body.dark-mode button:hover {
|
138 |
+
background-color: var(--dark-button-hover-bg-color);
|
139 |
+
}
|
140 |
+
|
141 |
+
.button:disabled, button:disabled {
|
142 |
+
background-color: #ccc;
|
143 |
+
cursor: not-allowed;
|
144 |
+
}
|
145 |
+
|
146 |
+
body.dark-mode .button:disabled, body.dark-mode button:disabled {
|
147 |
+
background-color: #555;
|
148 |
+
}
|
149 |
+
|
150 |
+
#resultText {
|
151 |
+
margin-top: 10px;
|
152 |
+
border: 1px solid #ddd;
|
153 |
+
padding: 10px;
|
154 |
+
min-height: 100px;
|
155 |
+
white-space: pre-wrap;
|
156 |
+
word-wrap: break-word;
|
157 |
+
background-color: var(--section-bg-color);
|
158 |
+
color: var(--text-color);
|
159 |
+
}
|
160 |
+
body.dark-mode #resultText{
|
161 |
+
background-color: var(--dark-section-bg-color);
|
162 |
+
color: var(--dark-text-color);
|
163 |
+
}
|
164 |
+
|
165 |
+
.highlight {
|
166 |
+
cursor: pointer;
|
167 |
+
transition: background-color 0.3s;
|
168 |
+
}
|
169 |
+
|
170 |
+
.highlight:hover {
|
171 |
+
background-color: var(--highlight-hover-color);
|
172 |
+
}
|
173 |
+
|
174 |
+
.grammar-error {
|
175 |
+
color: orange;
|
176 |
+
cursor: pointer;
|
177 |
+
}
|
178 |
+
|
179 |
+
.similar-word {
|
180 |
+
color: var(--similar-word-color);
|
181 |
+
cursor: pointer;
|
182 |
+
}
|
183 |
+
|
184 |
+
body.dark-mode .similar-word {
|
185 |
+
color: var(--dark-link-color);
|
186 |
+
}
|
187 |
+
|
188 |
+
.replaced-word {
|
189 |
+
color: var(--replaced-word-color);
|
190 |
+
cursor: pointer;
|
191 |
+
}
|
192 |
+
|
193 |
+
body.dark-mode .replaced-word {
|
194 |
+
color: var(--dark-link-color);
|
195 |
+
}
|
196 |
+
|
197 |
+
.modal {
|
198 |
+
display: none;
|
199 |
+
position: fixed;
|
200 |
+
z-index: 1;
|
201 |
+
left: 0;
|
202 |
+
top: 0;
|
203 |
+
width: 100%;
|
204 |
+
height: 100%;
|
205 |
+
overflow: auto;
|
206 |
+
background-color: rgba(0, 0, 0, 0.4);
|
207 |
+
}
|
208 |
+
|
209 |
+
.modal-content {
|
210 |
+
background-color: var(--section-bg-color);
|
211 |
+
color: var(--text-color);
|
212 |
+
margin: 15% auto;
|
213 |
+
padding: 20px;
|
214 |
+
border: 1px solid #888;
|
215 |
+
width: 80%;
|
216 |
+
border-radius: 5px;
|
217 |
+
}
|
218 |
+
|
219 |
+
body.dark-mode .modal-content {
|
220 |
+
background-color: var(--dark-section-bg-color);
|
221 |
+
color: var(--dark-text-color);
|
222 |
+
}
|
223 |
+
|
224 |
+
.close {
|
225 |
+
color: #aaa;
|
226 |
+
float: right;
|
227 |
+
font-size: 28px;
|
228 |
+
font-weight: bold;
|
229 |
+
cursor: pointer;
|
230 |
+
}
|
231 |
+
|
232 |
+
.close:hover,
|
233 |
+
.close:focus {
|
234 |
+
color: black;
|
235 |
+
text-decoration: none;
|
236 |
+
cursor: pointer;
|
237 |
+
}
|
238 |
+
|
239 |
+
body.dark-mode .close:hover,
|
240 |
+
body.dark-mode .close:focus {
|
241 |
+
color: var(--dark-text-color);
|
242 |
+
}
|
243 |
+
|
244 |
+
.pagination {
|
245 |
+
display: flex;
|
246 |
+
justify-content: center;
|
247 |
+
align-items: center;
|
248 |
+
margin-top: 10px;
|
249 |
+
}
|
250 |
+
|
251 |
+
.pagination button,
|
252 |
+
.pagination span {
|
253 |
+
margin: 0 5px;
|
254 |
+
padding: 5px 10px;
|
255 |
+
border: none;
|
256 |
+
background-color: var(--button-bg-color);
|
257 |
+
color: var(--button-text-color);
|
258 |
+
cursor: pointer;
|
259 |
+
border-radius: 5px;
|
260 |
+
}
|
261 |
+
body.dark-mode .pagination button,
|
262 |
+
body.dark-mode .pagination span{
|
263 |
+
background-color: var(--dark-button-bg-color);
|
264 |
+
color: var(--dark-button-text-color);
|
265 |
+
}
|
266 |
+
|
267 |
+
.pagination button:disabled {
|
268 |
+
background-color: #ccc;
|
269 |
+
cursor: not-allowed;
|
270 |
+
}
|
271 |
+
body.dark-mode .pagination button:disabled{
|
272 |
+
background-color: #555;
|
273 |
+
}
|
274 |
+
|
275 |
+
.pagination .current-page {
|
276 |
+
background-color: var(--accent-color);
|
277 |
+
font-weight: bold;
|
278 |
+
}
|
279 |
+
body.dark-mode .pagination .current-page{
|
280 |
+
background-color: var(--dark-accent-color);
|
281 |
+
}
|
282 |
+
|
283 |
+
#grammarToggle {
|
284 |
+
margin-right: 10px;
|
285 |
+
}
|
286 |
+
footer {
|
287 |
+
background-color: var(--footer-bg-color);
|
288 |
+
color: var(--footer-text-color);
|
289 |
+
text-align: center;
|
290 |
+
padding: 10px;
|
291 |
+
transition: background-color 0.3s;
|
292 |
+
margin-top: auto;
|
293 |
+
}
|
294 |
+
body.dark-mode footer{
|
295 |
+
background-color: var(--dark-footer-bg-color);
|
296 |
+
color: var(--dark-footer-text-color);
|
297 |
+
}
|
298 |
+
</style>
|
299 |
+
</head>
|
300 |
+
<body>
|
301 |
+
<header>
|
302 |
+
<h1 data-i18n="tools-title">AmTools</h1>
|
303 |
+
<div class="button-container">
|
304 |
+
<select class="language-select button">
|
305 |
+
<option value="zgh">ⵜⴰⵎⴰⵣⵉⵖⵜ</option>
|
306 |
+
<option value="en">English</option>
|
307 |
+
<option value="ar">العربية</option>
|
308 |
+
<option value="fr">Français</option>
|
309 |
+
</select>
|
310 |
+
<button class="dark-mode-toggle button">Dark Mode</button>
|
311 |
+
</div>
|
312 |
+
</header>
|
313 |
+
|
314 |
+
<main>
|
315 |
+
<section>
|
316 |
+
<textarea id="inputText" placeholder="Text..."></textarea>
|
317 |
+
<div class="button-container">
|
318 |
+
<button id="checkSpelling" data-i18n="check-spelling">ⵙⵏⵎ</button>
|
319 |
+
<button id="clearInput" data-i18n="clear-input">ⵙⴼⴹ</button>
|
320 |
+
<button id="pasteInput" data-i18n="paste-input">ⵙⵍⵖ</button>
|
321 |
+
<button id="exportResults" data-i18n="export-results">ⵙⵙⵓⴼⵖ</button>
|
322 |
+
</div>
|
323 |
+
<div id="resultText"></div>
|
324 |
+
<div class="button-container">
|
325 |
+
<button id="copyResult" data-i18n="copy-result">ⵙⵙⵏⵖⵍ</button>
|
326 |
+
</div>
|
327 |
+
</section>
|
328 |
+
</main>
|
329 |
+
|
330 |
+
<footer>
|
331 |
+
<p data-i18n="copyright">AmTools</p>
|
332 |
+
</footer>
|
333 |
+
|
334 |
+
<!-- Modal -->
|
335 |
+
<div id="myModal" class="modal">
|
336 |
+
<div class="modal-content">
|
337 |
+
<span class="close">×</span>
|
338 |
+
<p data-i18n="similar-words">ⵜⵉⴳⵓⵔⵉⵡⵉⵏ ⵉⵔⵡⴰⵙⵏ:</p>
|
339 |
+
<p id="modalContent"></p>
|
340 |
+
<div class="pagination">
|
341 |
+
<button id="prevWords"><</button>
|
342 |
+
<span id="pageNumbers"></span>
|
343 |
+
<button id="nextWords">></button>
|
344 |
+
</div>
|
345 |
+
<input type="text" id="editWord" value="">
|
346 |
+
<p></p>
|
347 |
+
<button id="replaceWord" data-i18n="replace-word">ⵙⵎⴰⵜⵜⵉ</button>
|
348 |
+
</div>
|
349 |
+
</div>
|
350 |
+
|
351 |
+
<script>
|
352 |
+
const translations = {
|
353 |
+
en: {
|
354 |
+
"tools-title": "AmTools",
|
355 |
+
"check-spelling": "Check",
|
356 |
+
"clear-input": "Clear",
|
357 |
+
"paste-input": "Paste",
|
358 |
+
"export-results": "Export",
|
359 |
+
"copy-result": "Copy",
|
360 |
+
"copyright": "AmTools",
|
361 |
+
"similar-words": "Similar words:",
|
362 |
+
"replace-word": "Replace",
|
363 |
+
},
|
364 |
+
ar: {
|
365 |
+
"tools-title": "أم-أدوات",
|
366 |
+
"check-spelling": "تحقق",
|
367 |
+
"clear-input": "مسح",
|
368 |
+
"paste-input": "لصق",
|
369 |
+
"export-results": "تصدير",
|
370 |
+
"copy-result": "نسخ",
|
371 |
+
"copyright": "AmTools",
|
372 |
+
"similar-words": "كلمات مشابهة:",
|
373 |
+
"replace-word": "استبدال",
|
374 |
+
},
|
375 |
+
fr: {
|
376 |
+
"tools-title": "AmTools",
|
377 |
+
"check-spelling": "Vérifier",
|
378 |
+
"clear-input": "Effacer",
|
379 |
+
"paste-input": "Coller",
|
380 |
+
"export-results": "Exporter",
|
381 |
+
"copy-result": "Copier",
|
382 |
+
"copyright": "AmTools",
|
383 |
+
"similar-words": "Mots similaires:",
|
384 |
+
"replace-word": "Remplacer",
|
385 |
+
},
|
386 |
+
zgh: {
|
387 |
+
"tools-title": "ⵉⵎⴰⵙⵙⵏ",
|
388 |
+
"check-spelling": "ⴷⵡⵙ",
|
389 |
+
"clear-input": "ⵚⴼⴹ",
|
390 |
+
"paste-input": "ⵙⵍⵖ",
|
391 |
+
"export-results": "ⵙⵙⵓⴼⵖ",
|
392 |
+
"copy-result": "ⵙⵙⵏⵖⵍ",
|
393 |
+
"copyright": "ⴰⵎⵉⵎⴰⵙⵙⵏ",
|
394 |
+
"similar-words": "ⵜⵉⴳⵓⵔⵉⵡⵉⵏ ⵉⵔⵡⴰⵙⵏ:",
|
395 |
+
"replace-word": "ⵙⵏⴼⵍ",
|
396 |
+
}
|
397 |
+
};
|
398 |
+
|
399 |
+
const languageSelect = document.querySelector(".language-select");
|
400 |
+
const elementsToTranslate = document.querySelectorAll("[data-i18n]");
|
401 |
+
|
402 |
+
languageSelect.addEventListener("change", () => {
|
403 |
+
const selectedLanguage = languageSelect.value;
|
404 |
+
setLanguage(selectedLanguage);
|
405 |
+
});
|
406 |
+
|
407 |
+
function setLanguage(language) {
|
408 |
+
elementsToTranslate.forEach(element => {
|
409 |
+
const key = element.getAttribute("data-i18n");
|
410 |
+
element.textContent = translations[language][key];
|
411 |
+
});
|
412 |
+
}
|
413 |
+
|
414 |
+
// Set initial language based on user's preference or default to English
|
415 |
+
const userLanguage = navigator.language || navigator.userLanguage;
|
416 |
+
const initialLanguage = userLanguage.startsWith("ar") ? "ar" : userLanguage.startsWith("fr") ? "fr" : userLanguage.startsWith("zgh") ? "zgh" : "en";
|
417 |
+
setLanguage(initialLanguage);
|
418 |
+
languageSelect.value = initialLanguage;
|
419 |
+
|
420 |
+
let dictionary = new Set();
|
421 |
+
let currentWordElement = null;
|
422 |
+
let currentWordText = '';
|
423 |
+
let allSimilarWords = [];
|
424 |
+
let currentWordIndex = 0;
|
425 |
+
|
426 |
+
const similarLetters = {
|
427 |
+
'ⵣ': 'ⵥ', 'ⵥ': 'ⵣ',
|
428 |
+
'ⴷ': 'ⴹ', 'ⴹ': 'ⴷ',
|
429 |
+
'ⵜ': 'ⵟ', 'ⵟ': 'ⵜ',
|
430 |
+
'ⵟ': 'ⴹⵜ', 'ⴹⵜ': 'ⵟ',
|
431 |
+
'ⵔ': 'ⵕ', 'ⵕ': 'ⵔ',
|
432 |
+
'ⵙ': 'ⵚ', 'ⵚ': 'ⵙ'
|
433 |
+
};
|
434 |
+
|
435 |
+
const vowels = new Set(['ⴰ', 'ⵉ', 'ⵓ']);
|
436 |
+
|
437 |
+
function loadDictionary(url, dictSet) {
|
438 |
+
fetch(url)
|
439 |
+
.then(response => response.text())
|
440 |
+
.then(text => {
|
441 |
+
const words = text.split('\n').map(word => word.trim());
|
442 |
+
words.forEach(word => dictSet.add(word));
|
443 |
+
console.log('Dictionary loaded from', url);
|
444 |
+
})
|
445 |
+
.catch(error => console.error('Error loading dictionary:', error));
|
446 |
+
}
|
447 |
+
|
448 |
+
loadDictionary('Dictionary.txt', dictionary);
|
449 |
+
|
450 |
+
function levenshteinDistance(a, b) {
|
451 |
+
if (a.length === 0) return b.length;
|
452 |
+
if (b.length === 0) return a.length;
|
453 |
+
|
454 |
+
const matrix = [];
|
455 |
+
|
456 |
+
for (let i = 0; i <= b.length; i++) {
|
457 |
+
matrix[i] = [i];
|
458 |
+
}
|
459 |
+
|
460 |
+
for (let j = 0; j <= a.length; j++) {
|
461 |
+
matrix[0][j] = j;
|
462 |
+
}
|
463 |
+
|
464 |
+
for (let i = 1; i <= b.length; i++) {
|
465 |
+
for (let j = 1; j <= a.length; j++) {
|
466 |
+
if (b.charAt(i - 1) === a.charAt(j - 1)) {
|
467 |
+
matrix[i][j] = matrix[i - 1][j - 1];
|
468 |
+
} else {
|
469 |
+
matrix[i][j] = Math.min(
|
470 |
+
matrix[i - 1][j - 1] + 1,
|
471 |
+
matrix[i][j - 1] + 1,
|
472 |
+
matrix[i - 1][j] + 1
|
473 |
+
);
|
474 |
+
}
|
475 |
+
}
|
476 |
+
}
|
477 |
+
|
478 |
+
return matrix[b.length][a.length];
|
479 |
+
}
|
480 |
+
|
481 |
+
function findSimilarWords(word, dictionary, maxDistance = 2) {
|
482 |
+
let similarWords = Array.from(dictionary).filter(dictWord =>
|
483 |
+
levenshteinDistance(word, dictWord) <= maxDistance
|
484 |
+
);
|
485 |
+
|
486 |
+
// Check for ⵢ/ⵉ and ⵡ/ⵓ at the beginning
|
487 |
+
if (word.startsWith('ⵢ')) {
|
488 |
+
const altWord = 'ⵉ' + word.slice(1);
|
489 |
+
if (dictionary.has(altWord)) similarWords.unshift(altWord);
|
490 |
+
} else if (word.startsWith('ⵡ')) {
|
491 |
+
const altWord = 'ⵓ' + word.slice(1);
|
492 |
+
if (dictionary.has(altWord)) similarWords.unshift(altWord);
|
493 |
+
}
|
494 |
+
|
495 |
+
// Check without vowels
|
496 |
+
const wordWithoutVowels = Array.from(word).filter(char => !vowels.has(char)).join('');
|
497 |
+
dictionary.forEach(dictWord => {
|
498 |
+
const dictWordWithoutVowels = Array.from(dictWord).filter(char => !vowels.has(char)).join('');
|
499 |
+
if (wordWithoutVowels === dictWordWithoutVowels && !similarWords.includes(dictWord)) {
|
500 |
+
similarWords.push(dictWord);
|
501 |
+
}
|
502 |
+
});
|
503 |
+
|
504 |
+
// Check with similar letters
|
505 |
+
for (let i = 0; i < word.length; i++) {
|
506 |
+
if (similarLetters[word[i]]) {
|
507 |
+
const altWord = word.slice(0, i) + similarLetters[word[i]] + word.slice(i + 1);
|
508 |
+
if (dictionary.has(altWord) && !similarWords.includes(altWord)) {
|
509 |
+
similarWords.push(altWord);
|
510 |
+
}
|
511 |
+
}
|
512 |
+
}
|
513 |
+
|
514 |
+
return similarWords;
|
515 |
+
}
|
516 |
+
|
517 |
+
function showModal(word, similarWords) {
|
518 |
+
const modal = document.getElementById("myModal");
|
519 |
+
const modalContent = document.getElementById("modalContent");
|
520 |
+
document.getElementById("editWord").value = word;
|
521 |
+
allSimilarWords = similarWords;
|
522 |
+
currentWordIndex = 0;
|
523 |
+
updateModalContent();
|
524 |
+
modal.style.display = "block";
|
525 |
+
}
|
526 |
+
|
527 |
+
function updateModalContent() {
|
528 |
+
const modalContent = document.getElementById("modalContent");
|
529 |
+
const start = currentWordIndex;
|
530 |
+
const end = Math.min(start + 10, allSimilarWords.length);
|
531 |
+
const currentWords = allSimilarWords.slice(start, end);
|
532 |
+
modalContent.innerHTML = currentWords.map(w => `<span class="similar-word">${w}</span>`).join(', ');
|
533 |
+
|
534 |
+
document.querySelectorAll('.similar-word').forEach(element => {
|
535 |
+
element.addEventListener('click', () => {
|
536 |
+
document.getElementById("editWord").value = element.innerText;
|
537 |
+
});
|
538 |
+
});
|
539 |
+
|
540 |
+
document.getElementById("prevWords").disabled = start === 0;
|
541 |
+
document.getElementById("nextWords").disabled = end >= allSimilarWords.length;
|
542 |
+
|
543 |
+
// Update pagination
|
544 |
+
const totalPages = Math.ceil(allSimilarWords.length / 10);
|
545 |
+
const currentPage = Math.floor(start / 10) + 1;
|
546 |
+
let pageNumbers = '';
|
547 |
+
|
548 |
+
if (currentPage > 1) {
|
549 |
+
pageNumbers += `<span>${currentPage - 1}</span>`;
|
550 |
+
}
|
551 |
+
pageNumbers += `<span class="current-page">${currentPage}</span>`;
|
552 |
+
if (currentPage < totalPages) {
|
553 |
+
pageNumbers += `<span>${currentPage + 1}</span>`;
|
554 |
+
}
|
555 |
+
|
556 |
+
document.getElementById("pageNumbers").innerHTML = pageNumbers;
|
557 |
+
}
|
558 |
+
|
559 |
+
function handleWordClick(event) {
|
560 |
+
currentWordElement = event.target;
|
561 |
+
currentWordText = currentWordElement.innerText.replace(/[.,\/#!$%\^&\*;:{}=\-_`~()]/g, "");
|
562 |
+
const similarWords = findSimilarWords(currentWordText, dictionary);
|
563 |
+
showModal(currentWordText, similarWords);
|
564 |
+
}
|
565 |
+
|
566 |
+
function replaceWord(newWord) {
|
567 |
+
const originalWord = currentWordElement.innerText;
|
568 |
+
currentWordElement.innerHTML = newWord;
|
569 |
+
currentWordElement.className = "highlight replaced-word";
|
570 |
+
currentWordElement.style.color = "green";
|
571 |
+
document.querySelectorAll('.replaced-word').forEach(element => {
|
572 |
+
element.addEventListener('click', handleWordClick);
|
573 |
+
});
|
574 |
+
}
|
575 |
+
|
576 |
+
document.getElementById('checkSpelling').addEventListener('click', function() {
|
577 |
+
const text = document.getElementById('inputText').value;
|
578 |
+
const words = text.split(/(\s+|\b)/);
|
579 |
+
let result = '';
|
580 |
+
|
581 |
+
words.forEach(word => {
|
582 |
+
const cleanWord = word.replace(/[.,\/#!$%\^&\*;:{}=\-_`~()]/g, "");
|
583 |
+
if (cleanWord.trim().length > 0 && !dictionary.has(cleanWord)) {
|
584 |
+
result += `<span class="highlight" style="color: red;">${word}</span>`;
|
585 |
+
} else {
|
586 |
+
result += `<span class="highlight">${word}</span>`;
|
587 |
+
}
|
588 |
+
});
|
589 |
+
|
590 |
+
document.getElementById('resultText').innerHTML = result;
|
591 |
+
document.querySelectorAll('.highlight').forEach(element => {
|
592 |
+
element.addEventListener('click', handleWordClick);
|
593 |
+
});
|
594 |
+
});
|
595 |
+
|
596 |
+
document.getElementById('replaceWord').addEventListener('click', function() {
|
597 |
+
const newWord = document.getElementById('editWord').value;
|
598 |
+
replaceWord(newWord);
|
599 |
+
const modal = document.getElementById("myModal");
|
600 |
+
modal.style.display = "none";
|
601 |
+
});
|
602 |
+
|
603 |
+
document.querySelector(".close").addEventListener('click', function() {
|
604 |
+
const modal = document.getElementById("myModal");
|
605 |
+
modal.style.display = "none";
|
606 |
+
});
|
607 |
+
|
608 |
+
document.getElementById('prevWords').addEventListener('click', function() {
|
609 |
+
if (currentWordIndex > 0) {
|
610 |
+
currentWordIndex -= 10;
|
611 |
+
updateModalContent();
|
612 |
+
}
|
613 |
+
});
|
614 |
+
|
615 |
+
document.getElementById('nextWords').addEventListener('click', function() {
|
616 |
+
if (currentWordIndex + 10 < allSimilarWords.length) {
|
617 |
+
currentWordIndex += 10;
|
618 |
+
updateModalContent();
|
619 |
+
}
|
620 |
+
});
|
621 |
+
|
622 |
+
document.getElementById('clearInput').addEventListener('click', function() {
|
623 |
+
document.getElementById('inputText').value = '';
|
624 |
+
});
|
625 |
+
|
626 |
+
document.getElementById('pasteInput').addEventListener('click', async function() {
|
627 |
+
try {
|
628 |
+
const text = await navigator.clipboard.readText();
|
629 |
+
document.getElementById('inputText').value = text;
|
630 |
+
} catch (err) {
|
631 |
+
console.error('Failed to read clipboard contents: ', err);
|
632 |
+
alert('ⵓⵔ ⵉⵍⵍⵉ ⵓⵖⴰⵍ ⵏ ⵓⵙⵍⵓⵖⵓ. ⵎⴽ ⵜⵓⴼⵉⴷ ⴰⵔⵎ ⴷⴰⵖ.');
|
633 |
+
}
|
634 |
+
});
|
635 |
+
|
636 |
+
document.getElementById('copyResult').addEventListener('click', async function() {
|
637 |
+
const resultText = document.getElementById('resultText').innerText;
|
638 |
+
try {
|
639 |
+
await navigator.clipboard.writeText(resultText);
|
640 |
+
alert('ⵉⵜⵜⵓⵙⵙⵏⵖⵍ ⵓⵙⵓⴼⵖ ⵖⵔ ⵓⵙⵍⵓⵖⵓ!');
|
641 |
+
} catch (err) {
|
642 |
+
console.error('Failed to copy text: ', err);
|
643 |
+
alert('ⵓⵔ ⵉⵍⵍⵉ ⵓⵙⵙⵏⵖⵍ ⵏ ⵓⴹⵕⵉⵚ. ⵎⴽ ⵜⵓⴼⵉⴷ ⴰⵔⵎ ⴷⴰⵖ.');
|
644 |
+
}
|
645 |
+
});
|
646 |
+
|
647 |
+
window.onclick = function(event) {
|
648 |
+
const modal = document.getElementById("myModal");
|
649 |
+
if (event.target == modal) {
|
650 |
+
modal.style.display = "none";
|
651 |
+
}
|
652 |
+
}
|
653 |
+
document.getElementById('exportResults').addEventListener('click', function() {
|
654 |
+
const resultText = document.getElementById('resultText').innerText;
|
655 |
+
const blob = new Blob([resultText], {type: "text/plain;charset=utf-8"});
|
656 |
+
const url = URL.createObjectURL(blob);
|
657 |
+
const a = document.createElement('a');
|
658 |
+
a.style.display = 'none';
|
659 |
+
a.href = url;
|
660 |
+
a.download = 'spell_check_results.txt';
|
661 |
+
document.body.appendChild(a);
|
662 |
+
a.click();
|
663 |
+
window.URL.revokeObjectURL(url);
|
664 |
+
});
|
665 |
+
|
666 |
+
// Dark mode toggle
|
667 |
+
const darkModeToggle = document.querySelector(".dark-mode-toggle");
|
668 |
+
darkModeToggle.addEventListener("click", () => {
|
669 |
+
document.body.classList.toggle("dark-mode");
|
670 |
+
});
|
671 |
+
</script>
|
672 |
+
</body>
|
673 |
+
</html>
|