File size: 29,924 Bytes
cfff267
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
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
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>English-Wolof Dictionary</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');
        
        body {
            font-family: 'Poppins', sans-serif;
            background-color: #f8fafc;
        }
        
        .wolof-bg {
            background: linear-gradient(135deg, #1282A2 0%, #034078 100%);
        }
        
        .word-card {
            transition: all 0.3s ease;
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
        }
        
        .word-card:hover {
            transform: translateY(-2px);
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
        }
        
        .type-badge {
            font-size: 0.75rem;
            padding: 0.25rem 0.5rem;
            border-radius: 9999px;
        }
        
        .noun {
            background-color: #3B82F6;
            color: white;
        }
        
        .verb {
            background-color: #10B981;
            color: white;
        }
        
        .adjective {
            background-color: #F59E0B;
            color: white;
        }
        
        .adverb {
            background-color: #8B5CF6;
            color: white;
        }
        
        .phrase {
            background-color: #EC4899;
            color: white;
        }
        
        .search-input:focus {
            outline: none;
            box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.5);
        }
        
        .fade-in {
            animation: fadeIn 0.5s ease-in-out;
        }
        
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(10px); }
            to { opacity: 1; transform: translateY(0); }
        }
        
        .wolof-text {
            color: #034078;
            font-weight: 600;
        }
        
        /* Modal styles */
        .modal {
            display: none;
            position: fixed;
            z-index: 50;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            overflow: auto;
            background-color: rgba(0,0,0,0.4);
        }
        
        .modal-content {
            background-color: #fefefe;
            margin: 10% auto;
            padding: 20px;
            border: 1px solid #888;
            width: 90%;
            max-width: 500px;
            border-radius: 8px;
            animation: modalopen 0.3s;
        }
        
        @keyframes modalopen {
            from {opacity: 0; transform: translateY(-20px)}
            to {opacity: 1; transform: translateY(0)}
        }
        
        .close {
            color: #aaa;
            float: right;
            font-size: 28px;
            font-weight: bold;
            cursor: pointer;
        }
        
        .close:hover {
            color: black;
        }
    </style>
</head>
<body class="min-h-screen">
    <div class="wolof-bg text-white py-6 px-4 shadow-md">
        <div class="container mx-auto">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="flex items-center mb-4 md:mb-0">
                    <i class="fas fa-book-open text-3xl mr-3"></i>
                    <h1 class="text-2xl md:text-3xl font-bold">English-Wolof Dictionary</h1>
                </div>
                <div class="flex items-center space-x-4">
                    <div class="relative w-full md:w-64">
                        <input type="text" id="searchInput" placeholder="Search word..." 
                               class="w-full py-2 px-4 pr-10 rounded-full text-gray-800 focus:outline-none focus:ring-2 focus:ring-blue-500">
                        <button id="searchBtn" class="absolute right-0 top-0 mt-2 mr-4 text-gray-600 hover:text-blue-500">
                            <i class="fas fa-search"></i>
                        </button>
                    </div>
                    <button id="addWordBtn" class="bg-white text-blue-600 hover:bg-blue-50 px-4 py-2 rounded-full font-medium flex items-center">
                        <i class="fas fa-plus mr-2"></i> Add Word
                    </button>
                </div>
            </div>
        </div>
    </div>

    <div class="container mx-auto px-4 py-8">
        <div class="flex flex-col md:flex-row gap-6">
            <!-- Main Content -->
            <div class="w-full md:w-3/4">
                <div class="bg-white rounded-lg shadow-md p-6 mb-6">
                    <h2 class="text-xl font-semibold mb-4 text-gray-800">Welcome to English-Wolof Dictionary</h2>
                    <p class="text-gray-600 mb-4">
                        This dictionary helps you learn and translate between English and Wolof, the most widely spoken language in Senegal.
                        You can search for words, add new words, and hear pronunciations.
                    </p>
                    <div class="flex flex-wrap gap-2 mb-4">
                        <span class="type-badge noun">Noun</span>
                        <span class="type-badge verb">Verb</span>
                        <span class="type-badge adjective">Adjective</span>
                        <span class="type-badge adverb">Adverb</span>
                        <span class="type-badge phrase">Phrase</span>
                    </div>
                    <div class="bg-blue-50 border-l-4 border-blue-500 p-4">
                        <p class="text-blue-700">
                            <i class="fas fa-info-circle mr-2"></i> 
                            Wolof is written with the Latin alphabet but has some unique characters like ñ, ŋ, and ñ.
                        </p>
                    </div>
                </div>

                <!-- Search Results -->
                <div id="searchResults" class="space-y-4">
                    <!-- Results will be displayed here -->
                </div>

                <!-- Popular Words -->
                <div class="mt-8">
                    <div class="flex justify-between items-center mb-4">
                        <h3 class="text-lg font-semibold text-gray-800">Common Wolof Words</h3>
                        <button id="showAllWords" class="text-blue-500 hover:text-blue-700 text-sm flex items-center">
                            <i class="fas fa-list mr-1"></i> Show All Words
                        </button>
                    </div>
                    <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4" id="popularWords">
                        <!-- Popular words will be loaded here -->
                    </div>
                </div>
            </div>

            <!-- Sidebar -->
            <div class="w-full md:w-1/4">
                <div class="bg-white rounded-lg shadow-md p-6 mb-6">
                    <h3 class="font-semibold text-lg mb-4 text-gray-800">Quick Facts</h3>
                    <div class="space-y-4">
                        <div>
                            <h4 class="font-medium text-blue-600">Wolof Speakers</h4>
                            <p class="text-sm text-gray-600">~10 million native speakers</p>
                        </div>
                        <div>
                            <h4 class="font-medium text-blue-600">Countries</h4>
                            <p class="text-sm text-gray-600">Senegal, Gambia, Mauritania</p>
                        </div>
                        <div>
                            <h4 class="font-medium text-blue-600">Language Family</h4>
                            <p class="text-sm text-gray-600">Niger-Congo > Atlantic > Senegambian</p>
                        </div>
                    </div>
                </div>

                <div class="bg-white rounded-lg shadow-md p-6">
                    <h3 class="font-semibold text-lg mb-4 text-gray-800">Common Phrases</h3>
                    <div class="space-y-3">
                        <div>
                            <p class="font-medium">How are you?</p>
                            <p class="wolof-text text-sm">Nanga def?</p>
                        </div>
                        <div>
                            <p class="font-medium">I'm fine</p>
                            <p class="wolof-text text-sm">Mangi fi rekk</p>
                        </div>
                        <div>
                            <p class="font-medium">What's your name?</p>
                            <p class="wolof-text text-sm">Naka nga tudd?</p>
                        </div>
                        <div>
                            <p class="font-medium">My name is...</p>
                            <p class="wolof-text text-sm">Maa ngi tudd...</p>
                        </div>
                        <div>
                            <p class="font-medium">Goodbye</p>
                            <p class="wolof-text text-sm">Ba beneen</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Add Word Modal -->
    <div id="addWordModal" class="modal">
        <div class="modal-content">
            <span class="close">&times;</span>
            <h2 class="text-xl font-bold mb-4">Add New Word</h2>
            <form id="addWordForm">
                <div class="mb-4">
                    <label for="englishWord" class="block text-gray-700 mb-2">English Word</label>
                    <input type="text" id="englishWord" required class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
                </div>
                <div class="mb-4">
                    <label for="wolofWord" class="block text-gray-700 mb-2">Wolof Translation</label>
                    <input type="text" id="wolofWord" required class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
                </div>
                <div class="mb-4">
                    <label for="wordType" class="block text-gray-700 mb-2">Word Type</label>
                    <select id="wordType" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
                        <option value="noun">Noun</option>
                        <option value="verb">Verb</option>
                        <option value="adjective">Adjective</option>
                        <option value="adverb">Adverb</option>
                        <option value="phrase">Phrase</option>
                    </select>
                </div>
                <div class="mb-4">
                    <label for="pronunciation" class="block text-gray-700 mb-2">Pronunciation Guide</label>
                    <input type="text" id="pronunciation" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
                </div>
                <div class="mb-4">
                    <label for="examples" class="block text-gray-700 mb-2">Example Sentences (one per line)</label>
                    <textarea id="examples" rows="3" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"></textarea>
                </div>
                <div class="flex justify-end space-x-3">
                    <button type="button" id="cancelAddWord" class="px-4 py-2 border border-gray-300 rounded-md text-gray-700 hover:bg-gray-100">Cancel</button>
                    <button type="submit" class="px-4 py-2 bg-blue-500 text-white rounded-md hover:bg-blue-600">Add Word</button>
                </div>
            </form>
        </div>
    </div>

    <footer class="wolof-bg text-white py-6 mt-12">
        <div class="container mx-auto px-4">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-4 md:mb-0">
                    <h3 class="text-xl font-bold mb-2">English-Wolof Dictionary</h3>
                    <p class="text-blue-100">Learn the beautiful Wolof language</p>
                </div>
                <div class="flex space-x-4">
                    <a href="#" class="text-white hover:text-blue-200">
                        <i class="fab fa-facebook-f"></i>
                    </a>
                    <a href="#" class="text-white hover:text-blue-200">
                        <i class="fab fa-twitter"></i>
                    </a>
                    <a href="#" class="text-white hover:text-blue-200">
                        <i class="fab fa-instagram"></i>
                    </a>
                </div>
            </div>
            <div class="border-t border-blue-400 mt-6 pt-6 text-sm text-center text-blue-100">
                <p>© 2023 English-Wolof Dictionary. All rights reserved.</p>
            </div>
        </div>
    </footer>

    <script>
        // Dictionary data - loaded from localStorage or initialized with default words
        let dictionary = JSON.parse(localStorage.getItem('wolofDictionary')) || [
            {
                english: "hello",
                wolof: "Nanga def",
                type: "phrase",
                pronunciation: "Nahn-gah def",
                examples: [
                    "Hello, how are you? - Nanga def, na nga def?",
                    "Hello my friend - Nanga def samay xarit"
                ]
            },
            {
                english: "thank you",
                wolof: "Jërëjëf",
                type: "phrase",
                pronunciation: "Jeh-reh-jef",
                examples: [
                    "Thank you very much - Jërëjëf bu baax",
                    "I thank you - Damay jërëjëf"
                ]
            },
            {
                english: "water",
                wolof: "Ndox",
                type: "noun",
                pronunciation: "Ndoh",
                examples: [
                    "I need water - Damay soxla ndox",
                    "The water is cold - Ndox mi di nawn"
                ]
            },
            {
                english: "food",
                wolof: "Lekk",
                type: "noun",
                pronunciation: "Leck",
                examples: [
                    "The food is delicious - Lekk mi leex na",
                    "I want food - Damay bëgg lekk"
                ]
            },
            {
                english: "good",
                wolof: "Baax",
                type: "adjective",
                pronunciation: "Bahkh",
                examples: [
                    "Good morning - Suba ak siwil",
                    "That's very good - Dafay baax lool"
                ]
            },
            {
                english: "go",
                wolof: "Dem",
                type: "verb",
                pronunciation: "Dem",
                examples: [
                    "I go to school - Damay dem ca daara bi",
                    "Let's go! - Annà dem!"
                ]
            },
            {
                english: "house",
                wolof: "Kër",
                type: "noun",
                pronunciation: "Kehr",
                examples: [
                    "My house is big - Kër ga ma am dafa metti",
                    "We're going home - Nunuy dem kër"
                ]
            },
            {
                english: "love",
                wolof: "Nopalu",
                type: "verb",
                pronunciation: "Noh-pah-loo",
                examples: [
                    "I love you - Damay la nopalu",
                    "Love is beautiful - Nopalu dafa rafet"
                ]
            },
            {
                english: "money",
                wolof: "Xaalis",
                type: "noun",
                pronunciation: "Khah-lis",
                examples: [
                    "I don't have money - Amuma xaalis",
                    "Money is important - Xaalis moo gën a am solo"
                ]
            },
            {
                english: "work",
                wolof: "Jëf",
                type: "noun",
                pronunciation: "Jef",
                examples: [
                    "I'm going to work - Damay dem jëf",
                    "The work is hard - Jëf ji dafa am solo"
                ]
            }
        ];

        // Save dictionary to localStorage
        function saveDictionary() {
            localStorage.setItem('wolofDictionary', JSON.stringify(dictionary));
        }

        // DOM elements
        const searchInput = document.getElementById('searchInput');
        const searchBtn = document.getElementById('searchBtn');
        const searchResults = document.getElementById('searchResults');
        const popularWordsContainer = document.getElementById('popularWords');
        const showAllWordsBtn = document.getElementById('showAllWords');
        const addWordBtn = document.getElementById('addWordBtn');
        const addWordModal = document.getElementById('addWordModal');
        const closeModal = document.getElementsByClassName('close')[0];
        const cancelAddWord = document.getElementById('cancelAddWord');
        const addWordForm = document.getElementById('addWordForm');

        // Search function
        function searchDictionary(query) {
            if (!query) return [];
            
            return dictionary.filter(item => 
                item.english.toLowerCase().includes(query.toLowerCase()) || 
                item.wolof.toLowerCase().includes(query.toLowerCase())
            );
        }

        // Display results
        function displayResults(results) {
            searchResults.innerHTML = '';
            
            if (results.length === 0) {
                searchResults.innerHTML = `
                    <div class="bg-white rounded-lg shadow-md p-6 text-center">
                        <i class="fas fa-search text-4xl text-gray-400 mb-4"></i>
                        <h3 class="text-xl font-semibold text-gray-700">No results found</h3>
                        <p class="text-gray-500 mt-2">Try searching for another word</p>
                    </div>
                `;
                return;
            }
            
            results.forEach(result => {
                const resultElement = document.createElement('div');
                resultElement.className = 'word-card fade-in bg-white rounded-lg shadow-md p-6';
                resultElement.innerHTML = `
                    <div class="flex justify-between items-start mb-4">
                        <div>
                            <h3 class="text-2xl font-bold text-gray-800">${capitalizeFirstLetter(result.english)}</h3>
                            <p class="wolof-text text-xl mt-1">${result.wolof}</p>
                        </div>
                        <span class="type-badge ${result.type}">${capitalizeFirstLetter(result.type)}</span>
                    </div>
                    ${result.pronunciation ? `
                    <div class="mb-4">
                        <p class="text-gray-600"><span class="font-medium">Pronunciation:</span> ${result.pronunciation}</p>
                    </div>` : ''}
                    ${result.examples && result.examples.length > 0 ? `
                    <div>
                        <h4 class="font-medium text-gray-700 mb-2">Examples:</h4>
                        <ul class="list-disc list-inside space-y-2 text-gray-600">
                            ${result.examples.map(example => `<li>${example}</li>`).join('')}
                        </ul>
                    </div>` : ''}
                    <div class="mt-4 flex justify-between items-center">
                        <button class="text-blue-500 hover:text-blue-700 flex items-center" onclick="speakWord('${result.wolof}')">
                            <i class="fas fa-volume-up mr-2"></i> Pronounce
                        </button>
                        <button class="text-gray-500 hover:text-gray-700 text-sm" onclick="saveWord('${result.english}')">
                            <i class="fas fa-bookmark mr-1"></i> Save
                        </button>
                    </div>
                `;
                searchResults.appendChild(resultElement);
            });
        }

        // Display popular words
        function displayPopularWords() {
            popularWordsContainer.innerHTML = '';
            
            // Show first 6 words as popular words
            const popularWords = dictionary.slice(0, 6);
            
            popularWords.forEach(word => {
                const wordElement = document.createElement('div');
                wordElement.className = 'word-card bg-white rounded-lg p-4 hover:shadow-lg cursor-pointer';
                wordElement.onclick = () => searchWord(word.english);
                wordElement.innerHTML = `
                    <div class="flex justify-between items-start">
                        <h4 class="font-bold text-lg">${capitalizeFirstLetter(word.english)}</h4>
                        <span class="type-badge ${word.type}">${capitalizeFirstLetter(word.type)}</span>
                    </div>
                    <p class="wolof-text mt-2">${word.wolof}</p>
                    <button class="mt-2 text-blue-500 hover:text-blue-700 text-sm flex items-center" onclick="event.stopPropagation(); speakWord('${word.wolof}')">
                        <i class="fas fa-volume-up mr-1"></i> Pronounce
                    </button>
                `;
                popularWordsContainer.appendChild(wordElement);
            });
        }

        // Display all words
        function displayAllWords() {
            searchResults.innerHTML = '';
            
            if (dictionary.length === 0) {
                searchResults.innerHTML = `
                    <div class="bg-white rounded-lg shadow-md p-6 text-center">
                        <i class="fas fa-book text-4xl text-gray-400 mb-4"></i>
                        <h3 class="text-xl font-semibold text-gray-700">No words in dictionary</h3>
                        <p class="text-gray-500 mt-2">Add some words to get started</p>
                    </div>
                `;
                return;
            }
            
            // Group words by first letter
            const groupedWords = {};
            dictionary.forEach(word => {
                const firstLetter = word.english.charAt(0).toUpperCase();
                if (!groupedWords[firstLetter]) {
                    groupedWords[firstLetter] = [];
                }
                groupedWords[firstLetter].push(word);
            });
            
            // Sort letters alphabetically
            const sortedLetters = Object.keys(groupedWords).sort();
            
            // Create sections for each letter
            sortedLetters.forEach(letter => {
                const section = document.createElement('div');
                section.className = 'mb-8';
                section.innerHTML = `
                    <h3 class="text-xl font-bold mb-4 text-gray-800 border-b pb-2">${letter}</h3>
                    <div class="grid grid-cols-1 sm:grid-cols-2 gap-4" id="letter-${letter}">
                        <!-- Words for this letter will be added here -->
                    </div>
                `;
                searchResults.appendChild(section);
                
                const wordsContainer = document.getElementById(`letter-${letter}`);
                groupedWords[letter].forEach(word => {
                    const wordElement = document.createElement('div');
                    wordElement.className = 'word-card bg-white rounded-lg p-4 hover:shadow-lg cursor-pointer';
                    wordElement.onclick = () => searchWord(word.english);
                    wordElement.innerHTML = `
                        <div class="flex justify-between items-start">
                            <h4 class="font-bold text-lg">${capitalizeFirstLetter(word.english)}</h4>
                            <span class="type-badge ${word.type}">${capitalizeFirstLetter(word.type)}</span>
                        </div>
                        <p class="wolof-text mt-2">${word.wolof}</p>
                        <button class="mt-2 text-blue-500 hover:text-blue-700 text-sm flex items-center" onclick="event.stopPropagation(); speakWord('${word.wolof}')">
                            <i class="fas fa-volume-up mr-1"></i> Pronounce
                        </button>
                    `;
                    wordsContainer.appendChild(wordElement);
                });
            });
        }

        // Helper functions
        function capitalizeFirstLetter(string) {
            return string.charAt(0).toUpperCase() + string.slice(1);
        }

        function speakWord(word) {
            const utterance = new SpeechSynthesisUtterance(word);
            utterance.lang = 'fr-FR'; // Using French as closest available for Wolof pronunciation
            speechSynthesis.speak(utterance);
        }

        function saveWord(word) {
            alert(`"${capitalizeFirstLetter(word)}" has been saved to your favorites!`);
            // In a real app, you would save this to localStorage or a database
        }

        function searchWord(word) {
            searchInput.value = word;
            performSearch();
        }

        function performSearch() {
            const query = searchInput.value.trim();
            if (query.length === 0) {
                searchResults.innerHTML = `
                    <div class="bg-white rounded-lg shadow-md p-6 text-center">
                        <i class="fas fa-language text-4xl text-blue-500 mb-4"></i>
                        <h3 class="text-xl font-semibold text-gray-700">Search for English or Wolof words</h3>
                        <p class="text-gray-500 mt-2">Type a word in the search box above</p>
                    </div>
                `;
                return;
            }
            
            const results = searchDictionary(query);
            displayResults(results);
        }

        // Add new word
        function addNewWord(event) {
            event.preventDefault();
            
            const englishWord = document.getElementById('englishWord').value.trim();
            const wolofWord = document.getElementById('wolofWord').value.trim();
            const wordType = document.getElementById('wordType').value;
            const pronunciation = document.getElementById('pronunciation').value.trim();
            const examplesText = document.getElementById('examples').value.trim();
            
            // Split examples by new lines and filter out empty lines
            const examples = examplesText.split('\n').filter(line => line.trim().length > 0);
            
            // Create new word object
            const newWord = {
                english: englishWord.toLowerCase(),
                wolof: wolofWord,
                type: wordType,
                pronunciation: pronunciation || undefined,
                examples: examples.length > 0 ? examples : undefined
            };
            
            // Add to dictionary
            dictionary.unshift(newWord); // Add at beginning so it shows up in popular words
            saveDictionary();
            
            // Close modal and reset form
            addWordModal.style.display = 'none';
            addWordForm.reset();
            
            // Update display
            displayPopularWords();
            performSearch();
            
            // Show success message
            alert(`"${capitalizeFirstLetter(englishWord)}" has been added to the dictionary!`);
        }

        // Event listeners
        searchBtn.addEventListener('click', performSearch);
        searchInput.addEventListener('keyup', (e) => {
            if (e.key === 'Enter') {
                performSearch();
            }
        });

        showAllWordsBtn.addEventListener('click', displayAllWords);
        
        // Modal open/close
        addWordBtn.addEventListener('click', () => {
            addWordModal.style.display = 'block';
        });
        
        closeModal.addEventListener('click', () => {
            addWordModal.style.display = 'none';
        });
        
        cancelAddWord.addEventListener('click', () => {
            addWordModal.style.display = 'none';
        });
        
        window.addEventListener('click', (event) => {
            if (event.target === addWordModal) {
                addWordModal.style.display = 'none';
            }
        });
        
        addWordForm.addEventListener('submit', addNewWord);

        // Initialize
        displayPopularWords();
        performSearch();
    </script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Djibson12/https-huggingface-co-djibson12" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>