abdelhaqueidali commited on
Commit
cced289
·
verified ·
1 Parent(s): 0d275cb

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +50 -522
index.html CHANGED
@@ -1,538 +1,66 @@
1
  <!DOCTYPE html>
2
- <html lang="zgh">
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>ⴰⵙⵏⵎ ⵜⵉⵔⵔⴰ ⵏ ⵜⵎⴰⵣⵉⵖⵜ</title>
7
  <style>
8
- :root {
9
- --bg-color: #f8f8f8;
10
- --text-color: #333;
11
- --accent-color: #007bff;
12
- --nav-bg-color: #e9ecef;
13
- --nav-text-color: #343a40;
14
- --section-bg-color: #fff;
15
- --footer-bg-color: #343a40;
16
- --footer-text-color: #fff;
17
- --button-bg-color: #007bff;
18
- --button-text-color: #fff;
19
- --button-hover-bg-color: #0056b3;
20
- --link-color: #007bff;
21
- --link-hover-color: #0056b3;
22
- --highlight-color: #ffdddd;
23
- --highlight-hover-color: #ffcccc;
24
- --similar-word-color: #007bff;
25
- --replaced-word-color: #4CAF50;
26
- }
27
-
28
- body {
29
- font-family: Arial, sans-serif;
30
- line-height: 1.6;
31
- background-color: var(--bg-color);
32
- color: var(--text-color);
33
- display: flex;
34
- min-height: 100vh;
35
- flex-direction: column;
36
  margin: 0;
37
  padding: 0;
 
 
38
  }
39
 
40
- header {
41
- background-color: var(--accent-color);
42
- color: #fff;
43
- padding: 20px;
44
- text-align: center;
45
- }
46
-
47
- h1 {
48
- margin: 0;
49
- font-size: 2.5rem;
50
- }
51
-
52
- main {
53
- padding: 20px;
54
- flex: 1;
55
- max-width: 800px;
56
- margin: 0 auto;
57
- }
58
-
59
- h1 {
60
- text-align: center;
61
- color: var(--accent-color);
62
- font-size: 128%;
63
- }
64
-
65
- textarea {
66
- width: 100%;
67
- height: 200px;
68
- margin-bottom: 10px;
69
- padding: 10px;
70
- border: 1px solid #ddd;
71
- background-color: var(--section-bg-color);
72
- color: var(--text-color);
73
- }
74
-
75
- .button-container {
76
- display: flex;
77
- justify-content: center;
78
- flex-wrap: wrap;
79
- margin-bottom: 20px;
80
- }
81
-
82
- .button, button {
83
- background-color: var(--button-bg-color);
84
- color: var(--button-text-color);
85
- padding: 10px 20px;
86
- border: none;
87
- cursor: pointer;
88
- margin: 5px;
89
- border-radius: 5px;
90
- }
91
-
92
- .button:hover, button:hover {
93
- background-color: var(--button-hover-bg-color);
94
- }
95
-
96
- .button:disabled, button:disabled {
97
- background-color: #ccc;
98
- cursor: not-allowed;
99
- }
100
-
101
- #resultText {
102
- margin-top: 10px;
103
- border: 1px solid #ddd;
104
- padding: 10px;
105
- min-height: 100px;
106
- white-space: pre-wrap;
107
- word-wrap: break-word;
108
- background-color: var(--section-bg-color);
109
- color: var(--text-color);
110
- }
111
-
112
- .highlight {
113
- cursor: pointer;
114
- transition: background-color 0.3s;
115
- }
116
-
117
- .highlight:hover {
118
- background-color: var(--highlight-hover-color);
119
- }
120
-
121
- .grammar-error {
122
- color: orange;
123
- cursor: pointer;
124
- }
125
-
126
- .similar-word {
127
- color: var(--similar-word-color);
128
- cursor: pointer;
129
- }
130
-
131
- .replaced-word {
132
- color: var(--replaced-word-color);
133
- cursor: pointer;
134
- }
135
-
136
- .modal {
137
- display: none;
138
- position: fixed;
139
- z-index: 1;
140
- left: 0;
141
- top: 0;
142
  width: 100%;
143
  height: 100%;
144
- overflow: auto;
145
- background-color: rgba(0, 0, 0, 0.4);
146
- }
147
-
148
- .modal-content {
149
- background-color: var(--section-bg-color);
150
- color: var(--text-color);
151
- margin: 15% auto;
152
- padding: 20px;
153
- border: 1px solid #888;
154
- width: 80%;
155
- border-radius: 5px;
156
- }
157
-
158
- .close {
159
- color: #aaa;
160
- float: right;
161
- font-size: 28px;
162
- font-weight: bold;
163
- cursor: pointer;
164
- }
165
-
166
- .close:hover,
167
- .close:focus {
168
- color: black;
169
- text-decoration: none;
170
- cursor: pointer;
171
- }
172
-
173
- .pagination {
174
- display: flex;
175
- justify-content: center;
176
- align-items: center;
177
- margin-top: 10px;
178
- }
179
-
180
- .pagination button,
181
- .pagination span {
182
- margin: 0 5px;
183
- padding: 5px 10px;
184
- border: none;
185
- background-color: var(--button-bg-color);
186
- color: var(--button-text-color);
187
- cursor: pointer;
188
- border-radius: 5px;
189
- }
190
-
191
- .pagination button:disabled {
192
- background-color: #ccc;
193
- cursor: not-allowed;
194
- }
195
-
196
- .pagination .current-page {
197
- background-color: var(--accent-color);
198
- font-weight: bold;
199
- }
200
-
201
- footer {
202
- background-color: var(--footer-bg-color);
203
- color: var(--footer-text-color);
204
- text-align: center;
205
- padding: 10px;
206
- margin-top: auto;
207
- }
208
  </style>
209
  </head>
210
  <body>
211
- <header>
212
- <h1>ⵉⵎⴰⵙⵙⵏ</h1>
213
- </header>
214
- <main>
215
- <section>
216
- <textarea id="inputText" placeholder="Text..."></textarea>
217
- <div class="button-container">
218
- <button id="checkSpelling">ⴷⵡⵙ</button>
219
- <button id="clearInput">ⵚⴼⴹ</button>
220
- <button id="pasteInput">ⵙⵍⵖ</button>
221
- <button id="exportResults">ⵙⵙⵓⴼⵖ</button>
222
- </div>
223
- <div id="resultText"></div>
224
- <div class="button-container">
225
- <button id="copyResult">ⵙⵙⵏⵖⵍ</button>
226
- </div>
227
- </section>
228
- </main>
229
- <footer>
230
- <p>ⴰⵎⵉⵎⴰⵙⵙⵏ</p>
231
- </footer>
232
-
233
- <!-- Modal -->
234
- <div id="myModal" class="modal">
235
- <div class="modal-content">
236
- <span class="close">×</span>
237
- <p>ⵜⵉⴳⵓⵔⵉⵡⵉⵏ ⵉⵔⵡⴰⵙⵏ:</p>
238
- <p id="modalContent"></p>
239
- <div class="pagination">
240
- <button id="prevWords"><</button>
241
- <span id="pageNumbers"></span>
242
- <button id="nextWords">></button>
243
- </div>
244
- <input type="text" id="editWord" value="">
245
- <p></p>
246
- <button id="replaceWord">ⵙⵏⴼⵍ</button>
247
- <button id="addToDictionaryBtn">ⵔⵏⵓ ⵖⵔ ⵓⵎⴰⵡⴰⵍ</button> <!-- Add to Dictionary Button -->
248
- </div>
249
- </div>
250
-
251
- <script>
252
- // --- In-Memory Dictionary Management ---
253
- let dictionaryString = `
254
- ⴰⵎⴰⴹⴰⵍ
255
- ⴰⵙⴳⴳⵯⴰⵙ
256
- ⴰⵢⵢⵓⵔ
257
- ⴰⵙⵉⵏⴰⵙ
258
- ⴰⴽⵕⴰⵙ
259
- ⴰⵙⵉⴹⵢⴰⵙ
260
- ⵜⴰⵎⴰⵣⵉⵖⵜ
261
- ⵜⵉⴼⵉⵏⴰⵖ
262
- ⴰⵙⵍⵎⴰⴷ
263
- ⵜⴰⵙⴷⴰⵡⵉⵜ
264
- `; // Initial dictionary
265
-
266
- let dictionary = new Set();
267
-
268
- function loadDictionaryFromString(dictString) {
269
- const words = dictString.trim().split('\n').map(word => word.trim());
270
- words.forEach(word => dictionary.add(word));
271
- console.log('Dictionary loaded from string');
272
- }
273
- loadDictionaryFromString(dictionaryString);
274
-
275
-
276
- function addWordToMemoryDictionary(word) {
277
- if (!dictionary.has(word)) {
278
- dictionary.add(word);
279
- dictionaryString += `\n${word}`;
280
- console.log(`Added "${word}" to in-memory dictionary.`);
281
- }
282
- }
283
-
284
- let currentWordElement = null;
285
- let currentWordText = '';
286
- let allSimilarWords = [];
287
- let currentWordIndex = 0;
288
-
289
- const similarLetters = {
290
- 'ⵣ': 'ⵥ', 'ⵥ': 'ⵣ',
291
- 'ⴷ': 'ⴹ', 'ⴹ': 'ⴷ',
292
- 'ⵜ': 'ⵟ', 'ⵟ': 'ⵜ',
293
- 'ⵟ': 'ⴹⵜ', 'ⴹⵜ': 'ⵟ',
294
- 'ⵔ': 'ⵕ', 'ⵕ': 'ⵔ',
295
- 'ⵙ': 'ⵚ', 'ⵚ': 'ⵙ'
296
- };
297
-
298
- const vowels = new Set(['ⴰ', 'ⵉ', 'ⵓ']);
299
-
300
- function loadDictionary(url, dictSet) {
301
- fetch(url)
302
- .then(response => response.text())
303
- .then(text => {
304
- const words = text.split('\n').map(word => word.trim());
305
- words.forEach(word => dictSet.add(word));
306
- console.log('Dictionary loaded from', url);
307
- })
308
- .catch(error => console.error('Error loading dictionary:', error));
309
- }
310
-
311
- loadDictionary('Dictionary.txt', dictionary); // Load the external file
312
-
313
- function levenshteinDistance(a, b) {
314
- if (a.length === 0) return b.length;
315
- if (b.length === 0) return a.length;
316
-
317
- const matrix = [];
318
-
319
- for (let i = 0; i <= b.length; i++) {
320
- matrix[i] = [i];
321
- }
322
-
323
- for (let j = 0; j <= a.length; j++) {
324
- matrix[0][j] = j;
325
- }
326
-
327
- for (let i = 1; i <= b.length; i++) {
328
- for (let j = 1; j <= a.length; j++) {
329
- if (b.charAt(i - 1) === a.charAt(j - 1)) {
330
- matrix[i][j] = matrix[i - 1][j - 1];
331
- } else {
332
- matrix[i][j] = Math.min(
333
- matrix[i - 1][j - 1] + 1,
334
- matrix[i][j - 1] + 1,
335
- matrix[i - 1][j] + 1
336
- );
337
- }
338
- }
339
- }
340
-
341
- return matrix[b.length][a.length];
342
- }
343
- function findSimilarWords(word, dictionary, maxDistance = 2) {
344
- let similarWords = Array.from(dictionary).filter(dictWord =>
345
- levenshteinDistance(word, dictWord) <= maxDistance
346
- );
347
-
348
- // Check for ⵢ/ⵉ and ⵡ/ⵓ at the beginning
349
- if (word.startsWith('ⵢ')) {
350
- const altWord = 'ⵉ' + word.slice(1);
351
- if (dictionary.has(altWord)) similarWords.unshift(altWord);
352
- } else if (word.startsWith('ⵡ')) {
353
- const altWord = 'ⵓ' + word.slice(1);
354
- if (dictionary.has(altWord)) similarWords.unshift(altWord);
355
- }
356
-
357
- // Check without vowels
358
- const wordWithoutVowels = Array.from(word).filter(char => !vowels.has(char)).join('');
359
- dictionary.forEach(dictWord => {
360
- const dictWordWithoutVowels = Array.from(dictWord).filter(char => !vowels.has(char)).join('');
361
- if (wordWithoutVowels === dictWordWithoutVowels && !similarWords.includes(dictWord)) {
362
- similarWords.push(dictWord);
363
- }
364
- });
365
-
366
- // Check with similar letters
367
- for (let i = 0; i < word.length; i++) {
368
- if (similarLetters[word[i]]) {
369
- const altWord = word.slice(0, i) + similarLetters[word[i]] + word.slice(i + 1);
370
- if (dictionary.has(altWord) && !similarWords.includes(altWord)) {
371
- similarWords.push(altWord);
372
- }
373
- }
374
- }
375
-
376
- return similarWords;
377
- }
378
- function showModal(word, similarWords) {
379
- const modal = document.getElementById("myModal");
380
- const modalContent = document.getElementById("modalContent");
381
- document.getElementById("editWord").value = word;
382
- allSimilarWords = similarWords;
383
- currentWordIndex = 0;
384
- updateModalContent();
385
- modal.style.display = "block";
386
- }
387
-
388
- function updateModalContent() {
389
- const modalContent = document.getElementById("modalContent");
390
- const start = currentWordIndex;
391
- const end = Math.min(start + 10, allSimilarWords.length);
392
- const currentWords = allSimilarWords.slice(start, end);
393
- modalContent.innerHTML = currentWords.map(w => `<span class="similar-word">${w}</span>`).join(', ');
394
-
395
- document.querySelectorAll('.similar-word').forEach(element => {
396
- element.addEventListener('click', () => {
397
- document.getElementById("editWord").value = element.innerText;
398
- });
399
- });
400
-
401
- document.getElementById("prevWords").disabled = start === 0;
402
- document.getElementById("nextWords").disabled = end >= allSimilarWords.length;
403
-
404
- // Update pagination
405
- const totalPages = Math.ceil(allSimilarWords.length / 10);
406
- const currentPage = Math.floor(start / 10) + 1;
407
- let pageNumbers = '';
408
-
409
- if (currentPage > 1) {
410
- pageNumbers += `<span>${currentPage - 1}</span>`;
411
- }
412
- pageNumbers += `<span class="current-page">${currentPage}</span>`;
413
- if (currentPage < totalPages) {
414
- pageNumbers += `<span>${currentPage + 1}</span>`;
415
- }
416
-
417
- document.getElementById("pageNumbers").innerHTML = pageNumbers;
418
- }
419
-
420
-
421
- function handleWordClick(event) {
422
- currentWordElement = event.target;
423
- currentWordText = currentWordElement.innerText.replace(/[.,\/#!$%\^&\*;:{}=\-_`~()]/g, "");
424
- const similarWords = findSimilarWords(currentWordText, dictionary);
425
- showModal(currentWordText, similarWords);
426
- }
427
-
428
- function replaceWord(newWord) {
429
- const originalWord = currentWordElement.innerText; //Keep for later.
430
- currentWordElement.innerHTML = newWord;
431
- currentWordElement.className = "highlight replaced-word";
432
- currentWordElement.style.color = "green";
433
-
434
- document.querySelectorAll('.replaced-word').forEach(element => {
435
- element.addEventListener('click', handleWordClick);
436
- });
437
- }
438
-
439
- // Event listener for "Check Spelling" button
440
- document.getElementById('checkSpelling').addEventListener('click', function() {
441
- const text = document.getElementById('inputText').value;
442
- const words = text.split(/(\s+|\b)/); // Split on spaces and word boundaries
443
- let result = '';
444
-
445
- words.forEach(word => {
446
- const cleanWord = word.replace(/[.,\/#!$%\^&\*;:{}=\-_`~()]/g, "");
447
- if (cleanWord.trim().length > 0 && !dictionary.has(cleanWord)) {
448
- result += `<span class="highlight" style="color: red;">${word}</span>`;
449
- } else {
450
- result += `<span class="highlight">${word}</span>`; // Wrap all words
451
- }
452
- });
453
-
454
- document.getElementById('resultText').innerHTML = result;
455
-
456
- // Add click event listeners to ALL highlighted words (including correctly spelled ones)
457
- document.querySelectorAll('.highlight').forEach(element => {
458
- element.addEventListener('click', handleWordClick);
459
- });
460
- });
461
-
462
- // Event listener for "Replace Word" button
463
- document.getElementById('replaceWord').addEventListener('click', function() {
464
- const newWord = document.getElementById('editWord').value;
465
- replaceWord(newWord);
466
- const modal = document.getElementById("myModal");
467
- modal.style.display = "none";
468
- });
469
-
470
- // --- Add to Dictionary ---
471
- document.getElementById('addToDictionaryBtn').addEventListener('click', function() {
472
- const wordToAdd = document.getElementById('editWord').value;
473
- addWordToMemoryDictionary(wordToAdd);
474
- const modal = document.getElementById("myModal");
475
- modal.style.display = "none";
476
- });
477
-
478
- document.querySelector(".close").addEventListener('click', function() {
479
- const modal = document.getElementById("myModal");
480
- modal.style.display = "none";
481
- });
482
- document.getElementById('prevWords').addEventListener('click', function() {
483
- if (currentWordIndex > 0) {
484
- currentWordIndex -= 10;
485
- updateModalContent();
486
- }
487
- });
488
- document.getElementById('nextWords').addEventListener('click', function() {
489
- if (currentWordIndex + 10 < allSimilarWords.length) {
490
- currentWordIndex += 10;
491
- updateModalContent();
492
- }
493
- });
494
- document.getElementById('clearInput').addEventListener('click', function() {
495
- document.getElementById('inputText').value = '';
496
- });
497
- document.getElementById('pasteInput').addEventListener('click', async function() {
498
- try {
499
- const text = await navigator.clipboard.readText();
500
- document.getElementById('inputText').value = text;
501
- } catch(err) {
502
- console.error('Failed to read clipboard contents: ', err);
503
- alert('ⵓⵔ ⵉⵍⵍⵉ ⵓⵖⴰⵍ ⵏ ⵓⵙⵍⵓⵖⵓ. ⵎⴽ ⵜⵓⴼⵉⴷ ⴰⵔⵎ ⴷⴰⵖ.');
504
- }
505
- });
506
- document.getElementById('copyResult').addEventListener('click', async function() {
507
- const resultText = document.getElementById('resultText').innerText;
508
- try {
509
- await navigator.clipboard.writeText(resultText);
510
- alert('ⵉⵜⵜⵓⵙⵙⵏⵖⵍ ⵓⵙⵓⴼⵖ ⵖⵔ ⵓⵙⵍⵓⵖⵓ!');
511
- } catch (err) {
512
- console.error('Failed to copy text: ', err);
513
- alert('ⵓⵔ ⵉⵍⵍⵉ ⵓⵙⵙⵏⵖⵍ ⵏ ⵓⴹⵕⵉⵚ. ⵎⴽ ⵜⵓⴼⵉⴷ ⴰⵔⵎ ⴷⴰⵖ.');
514
- }
515
-
516
- });
517
- window.onclick = function(event) {
518
- const modal = document.getElementById("myModal");
519
- if (event.target == modal) {
520
- modal.style.display = "none";
521
- }
522
- };
523
- document.getElementById('exportResults').addEventListener('click', function() {
524
- const resultText = document.getElementById('resultText').innerText;
525
- const blob = new Blob([resultText], {type: "text/plain;charset=utf-8"});
526
- const url = URL.createObjectURL(blob);
527
- const a = document.createElement('a');
528
- a.style.display = 'none';
529
- a.href = url;
530
- a.download = 'spell_check_results.txt';
531
- document.body.appendChild(a);
532
- a.click();
533
- window.URL.revokeObjectURL(url);
534
- });
535
-
536
- </script>
537
  </body>
538
  </html>
 
1
  <!DOCTYPE html>
2
+ <html lang="en">
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Amazigh Spell Checker</title>
7
  <style>
8
+ /* Reset default margin and padding */
9
+ body, html {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  margin: 0;
11
  padding: 0;
12
+ height: 100%; /* Make sure body and html take up the full height */
13
+ overflow: hidden; /* Prevent scrollbars on the outer page */
14
  }
15
 
16
+ /* Style the iframe to take up the entire viewport */
17
+ iframe {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  width: 100%;
19
  height: 100%;
20
+ border: none; /* Remove default iframe border */
21
+ }
22
+
23
+ /* Reset default margin and padding */
24
+ body, html {
25
+ margin: 0;
26
+ padding: 0;
27
+ height: 100%; /* Make sure body and html take up the full height */
28
+ overflow: hidden; /* Prevent scrollbars on the outer page */
29
+ }
30
+
31
+ /* Style the iframe to take up the entire viewport */
32
+ iframe {
33
+ width: 100%;
34
+ height: 100%;
35
+ border: none; /* Remove default iframe border */
36
+ }
37
+
38
+ /* Style for the div containing the links */
39
+ div {
40
+ text-align: center; /* Center the links horizontally */
41
+ background-color: #f0f0f0; /* Light gray background (optional) */
42
+ padding: 10px; /* Add some padding around the links */
43
+ position: relative; /* Important for z-index to work */
44
+ z-index: 2; /* Ensure the div is above the iframe */
45
+ box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); /* Subtle shadow (optional) */
46
+ }
47
+
48
+ /* Style for the links themselves (optional) */
49
+ div a {
50
+ margin: 0 10px; /* Add some horizontal spacing between links */
51
+ color: #007bff; /* Blue link color (adjust as desired) */
52
+ text-decoration: none; /* Remove underline (optional) */
53
+ }
54
+
55
+ div a:hover {
56
+ text-decoration: underline; /* Add underline on hover (optional) */
57
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  </style>
59
  </head>
60
  <body>
61
+ <div style="text-align: center;">
62
+ <a href="https://abdelhaqueidali.github.io/Amazigh-Spell-Checker/">Original webpage</a> <a href="https://github.com/abdelhaqueidali/Amazigh-Spell-Checker">Original Repository</a>
63
+ </div>
64
+ <iframe src="https://abdelhaqueidali.github.io/Amazigh-Spell-Checker/" title="Amazigh Conjugator"></iframe>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  </body>
66
  </html>