-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
839 lines (777 loc) · 37.8 KB
/
Copy pathindex.html
File metadata and controls
839 lines (777 loc) · 37.8 KB
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
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
<!doctype html>
<html lang="ml">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Independence Day Quiz Competition | സ്വാതന്ത്ര്യദിന ക്വിസ് മത്സരം</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Noto+Sans+Malayalam:wght@400;600;700&family=Outfit:wght@400;600;700&display=swap"
rel="stylesheet"
/>
<style>
* {
box-sizing: border-box;
margin: 0;
padding: 0;
font-family: 'Outfit', 'Noto Sans Malayalam', sans-serif;
}
body {
background: radial-gradient(circle at center, #1a2332 0%, #0d1117 100%);
color: #f0f6fc;
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
overflow: hidden;
}
.slide-container {
width: 90%;
max-width: 950px;
height: 580px;
background: #21262d;
border-radius: 20px;
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6), 0 0 1px rgba(255, 255, 255, 0.1);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
padding: 40px;
position: relative;
border: 1px solid #30363d;
}
.badge {
background: linear-gradient(135deg, #238636, #2ea043);
color: white;
padding: 6px 18px;
border-radius: 20px;
font-size: 0.95rem;
margin-bottom: 20px;
text-transform: uppercase;
letter-spacing: 1px;
font-weight: 600;
box-shadow: 0 4px 12px rgba(35, 134, 54, 0.3);
}
.speaking-badge {
background-color: #d29922;
color: #161b22;
padding: 6px 16px;
border-radius: 20px;
font-size: 0.9rem;
font-weight: 700;
margin-bottom: 15px;
display: inline-flex;
align-items: center;
gap: 8px;
animation: pulse 1.2s infinite;
}
h1 {
font-size: 2.6rem;
margin-bottom: 12px;
color: #58a6ff;
font-weight: 700;
letter-spacing: -0.5px;
}
.sub-title {
font-size: 1.8rem;
color: #8b949e;
margin-bottom: 24px;
font-family: 'Noto Sans Malayalam', sans-serif;
font-weight: 600;
}
.qn-eng {
font-size: 1.6rem;
color: #f0f6fc;
margin-bottom: 15px;
line-height: 1.4;
font-weight: 600;
}
.qn-mal {
font-size: 1.5rem;
color: #a5d6ff;
margin-bottom: 25px;
line-height: 1.6;
font-family: 'Noto Sans Malayalam', sans-serif;
font-weight: 400;
}
.ans-eng {
font-size: 1.65rem;
color: #3fb950;
font-weight: 700;
margin-bottom: 8px;
}
.ans-mal {
font-size: 1.55rem;
color: #7ee787;
font-family: 'Noto Sans Malayalam', sans-serif;
font-weight: 600;
}
.answer-box {
background-color: #161b22;
border-left: 5px solid #238636;
padding: 24px;
border-radius: 12px;
margin-top: 15px;
width: 100%;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}
.controls {
position: absolute;
bottom: 25px;
display: flex;
gap: 15px;
align-items: center;
}
button {
background-color: #238636;
color: white;
border: none;
padding: 12px 26px;
font-size: 1.05rem;
font-weight: 600;
border-radius: 10px;
cursor: pointer;
transition: all 0.2s ease;
font-family: 'Outfit', 'Noto Sans Malayalam', sans-serif;
box-shadow: 0 4px 12px rgba(35, 134, 54, 0.3);
}
button:hover {
background-color: #2ea043;
transform: translateY(-1px);
box-shadow: 0 6px 16px rgba(46, 160, 67, 0.4);
}
button:active {
transform: translateY(0);
}
button.secondary {
background-color: #30363d;
color: #c9d1d9;
box-shadow: none;
}
button.secondary:hover {
background-color: #484f58;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.pen-down {
font-size: 3.8rem;
color: #d29922;
animation: pulse 1.2s infinite;
font-weight: 700;
letter-spacing: 1px;
}
.kbd-hint {
position: absolute;
top: 20px;
right: 20px;
font-size: 0.85rem;
color: #8b949e;
background: #161b22;
padding: 6px 12px;
border-radius: 8px;
border: 1px solid #30363d;
user-select: none;
}
@keyframes pulse {
0% {
transform: scale(1);
}
50% {
transform: scale(1.06);
}
100% {
transform: scale(1);
}
}
</style>
</head>
<body>
<div class="slide-container" id="slide"></div>
<script>
let currentAudio = null
let availableVoices = []
let isReading = false
const audioCache = new Map()
// Background Preloading of all 40 audio files (20 English + 20 Malayalam)
function preloadAllAudio() {
for (let i = 1; i <= quizData.questions.length; i++) {
['eng', 'mal'].forEach((lang) => {
const url = `audio/q${i}_${lang}.wav`
fetch(url)
.then((res) => {
if (!res.ok) throw new Error(`HTTP ${res.status}`)
return res.blob()
})
.then((blob) => {
const objectUrl = URL.createObjectURL(blob)
audioCache.set(url, objectUrl)
})
.catch((e) => {
// Fallback to standard audio preload
const audio = new Audio()
audio.preload = 'auto'
audio.src = url
audioCache.set(url, url)
})
})
}
}
// Preload initialized after quizData definition
if ('speechSynthesis' in window) {
const loadVoices = () => {
try {
availableVoices = window.speechSynthesis.getVoices()
} catch (e) {}
}
loadVoices()
window.speechSynthesis.onvoiceschanged = loadVoices
}
const quizData = {
title_eng: 'Independence Day Quiz Competition',
title_mal: 'സ്വാതന്ത്ര്യദിന ക്വിസ് മത്സരം',
questions: [
{
"id": 1,
"question": "Which historic movement was launched by Mahatma Gandhi in 1942 demanding an immediate end to British rule?",
"malayalam_question": "ബ്രിട്ടീഷ് ഭരണം അവസാനിപ്പിക്കണം എന്ന് ആവശ്യപ്പെട്ട് 1942-ൽ ഗാന്ധിജി ആരംഭിച്ച ചരിത്രപ്രസിദ്ധമായ പ്രസ്ഥാനം ഏതാണ്?",
"answer": "Quit India Movement (1942)",
"malayalam_answer": "ക്വിറ്റ് ഇന്ത്യ പ്രസ്ഥാനം (1942)"
},
{
"id": 2,
"question": "Which leader served as the first Prime Minister of independent India and hoisted the national flag at the Red Fort in 1947?",
"malayalam_question": "1947-ൽ സ്വതന്ത്ര ഇന്ത്യയുടെ ആദ്യ പ്രധാനമന്ത്രിയായി ചെങ്കോട്ടയിൽ ദേശീയ പതാക ഉയർത്തിയ നേതാവ് ആരാണ്?",
"answer": "Jawaharlal Nehru",
"malayalam_answer": "ജവഹർലാൽ നെഹ്റു"
},
{
"id": 3,
"question": "In which year did Jawaharlal Nehru deliver his famous 'Tryst with Destiny' speech on the eve of independence?",
"malayalam_question": "ഏത് വർഷത്തിലാണ് ജവഹർലാൽ നെഹ്റു തന്റെ പ്രശസ്തമായ 'ട്രൈസ്റ്റ് വിത്ത് ഡെസ്റ്റിനി' പ്രസംഗം നടത്തിയത്?",
"answer": "1947",
"malayalam_answer": "1947"
},
{
"id": 4,
"question": "Which personality served as the first Education Minister of independent India (1947–1958) and was a prominent Muslim leader in the freedom struggle?",
"malayalam_question": "സ്വതന്ത്ര ഇന്ത്യയുടെ ആദ്യത്തെ വിദ്യാഭ്യാസ മന്ത്രിയായി (1947–1958) സേവനമനുഷ്ഠിച്ച പ്രമുഖ മുസ്ലീം സ്വാതന്ത്ര്യസമര സേനാനി ആരാണ്?",
"answer": "Maulana Abul Kalam Azad",
"malayalam_answer": "മൗലാനാ അബുൽ കലാം ആസാദ്"
},
{
"id": 5,
"question": "Which Swadeshi movement began in 1905 to protest the Partition of Bengal initiated by Lord Curzon?",
"malayalam_question": "1905-ൽ കർസൺ പ്രഭുവിന്റെ ബംഗാൾ വിഭജനത്തിൽ പ്രതിഷേധിച്ച് ആരംഭിച്ച പ്രസ്ഥാനം ഏതാണ്?",
"answer": "Swadeshi Movement (1905)",
"malayalam_answer": "സ്വദേശി പ്രസ്ഥാനം (1905)"
},
{
"id": 6,
"question": "Which revolutionary leader reorganized the Indian National Army (Azad Hind Fauj) in 1943 and gave the slogan 'Give me blood, and I shall give you freedom'?",
"malayalam_question": "1943-ൽ ആസാദ് ഹിന്ദ് ഫൗജ് പുനഃസംഘടിപ്പിക്കുകയും 'എനിക്ക് രക്തം തരൂ, ഞാൻ നിങ്ങൾക്ക് സ്വാതന്ത്ര്യം തരാം' എന്ന് ആഹ്വാനം ചെയ്യുകയും ചെയ്ത നേതാവ് ആരാണ്?",
"answer": "Netaji Subhas Chandra Bose",
"malayalam_answer": "നേതാജി സുഭാഷ് ചന്ദ്രബോസ്"
},
{
"id": 7,
"question": "In which year was the Non-Cooperation Movement launched by Mahatma Gandhi following the Rowlatt Act and Jallianwala Bagh massacre?",
"malayalam_question": "റൗലറ്റ് ആക്ടിനും ജാലിയൻവാലാബാഗ് കൂട്ടക്കൊലയ്ക്കും എതിരായി ഗാന്ധിജി നിസഹകരണ പ്രസ്ഥാനം ആരംഭിച്ച വർഷം ഏതാണ്?",
"answer": "1920",
"malayalam_answer": "1920"
},
{
"id": 8,
"question": "Which Muslim revolutionary leader was martyred alongside Ram Prasad Bismil in 1927 for his involvement in the Kakori Train Action of 1925?",
"malayalam_question": "1925-ലെ കക്കോരി ട്രെയിൻ കേസിൽ 1927-ൽ റാം പ്രസാദ് ബിസ്മില്ലിനൊപ്പം രക്തസാക്ഷിത്വം വരിച്ച മുസ്ലീം വിപ്ലവകാരി ആരാണ്?",
"answer": "Ashfaqulla Khan",
"malayalam_answer": "അഷ്ഫാഖുള്ള ഖാൻ"
},
{
"id": 9,
"question": "Which British personality served as the last Viceroy of India and presided over the Indian Independence Act of 1947?",
"malayalam_question": "1947-ൽ ഇന്ത്യയുടെ അവസാനത്തെ വൈസ്രോയിയായി സേവനമനുഷ്ഠിക്കുകയും സ്വാതന്ത്ര്യ നിയമത്തിന് മേൽനോട്ടം വഹിക്കുകയും ചെയ്ത ബ്രിട്ടീഷ് വ്യക്തിത്വം ആരാണ്?",
"answer": "Lord Louis Mountbatten",
"malayalam_answer": "മൗണ്ട്ബാറ്റൺ പ്രഭു"
},
{
"id": 10,
"question": "Which Nobel laureate composed the national anthem 'Jana Gana Mana' in 1911?",
"malayalam_question": "1911-ൽ 'ജനഗണ മന' എന്ന ദേശീയ ഗാനം രചിച്ച നോബൽ സമ്മാന ജേതാവായ വ്യക്തിത്വം ആരാണ്?",
"answer": "Rabindranath Tagore",
"malayalam_answer": "രവീന്ദ്രനാഥ ടാഗോർ"
},
{
"id": 11,
"question": "In which year did the Salt Satyagraha (Dandi March) take place under the leadership of Mahatma Gandhi?",
"malayalam_question": "ഗാന്ധിജിയുടെ നേതൃത്വത്തിൽ നടന്ന പ്രശസ്തമായ ഉപ്പുസത്യാഗ്രഹം (ദണ്ഡി യാത്ര) ഏത് വർഷത്തിലാണ് നടന്നത്?",
"answer": "1930",
"malayalam_answer": "1930"
},
{
"id": 12,
"question": "Which prominent Muslim leader from the North-West Frontier founded the Khudai Khidmatgar movement in 1929 and was known as 'Frontier Gandhi'?",
"malayalam_question": "1929-ൽ 'ഖുദായ് ഖിദ്മത്ഗാർ' പ്രസ്ഥാനം സ്ഥാപിക്കുകയും 'അതിർത്തി ഗാന്ധി' എന്നറിയപ്പെടുകയും ചെയ്ത മുസ്ലീം നേതാവ് ആരാണ്?",
"answer": "Khan Abdul Ghaffar Khan",
"malayalam_answer": "ഖാൻ അബ്ദുൽ ഗഫാർ ഖാൻ"
},
{
"id": 13,
"question": "Which British lawyer led the Boundary Commissions in 1947 to draw the international borders dividing British India into India and Pakistan?",
"malayalam_question": "1947-ൽ ഇന്ത്യയും പാകിസ്ഥാനും തമ്മിലുള്ള അതിർത്തി രേഖകൾ നിർണ്ണയിക്കാൻ ബൗണ്ടറി കമ്മീഷന് നേതൃത്വം നൽകിയ ബ്രിട്ടീഷ് അഭിഭാഷകൻ ആരാണ്?",
"answer": "Sir Cyril Radcliffe",
"malayalam_answer": "സർ സിറിൽ റെഡ്ക്ലിഫ്"
},
{
"id": 14,
"question": "Which leader, known as the 'Iron Man of India', spearheaded the political integration of over 500 princely states between 1947 and 1950?",
"malayalam_question": "1947-നും 1950-നും ഇടയിൽ 500-ലധികം നാട്ടുരാജ്യങ്ങളെ ഇന്ത്യയോട് കൂട്ടിച്ചേർക്കാൻ നേതൃത്വം നൽകിയ 'ഇന്ത്യയുടെ ഇരുമ്പ് മനുഷ്യൻ' ആരാണ്?",
"answer": "Sardar Vallabhbhai Patel",
"malayalam_answer": "സർദാർ വല്ലഭ്ഭായ് പട്ടേൽ"
},
{
"id": 15,
"question": "In which year did the tragic Jallianwala Bagh massacre occur in Amritsar under General Dyer?",
"malayalam_question": "ജനറൽ ഡയറിന്റെ നേതൃത്വത്തിൽ അമൃത്സറിലെ ജാലിയൻവാലാബാഗ് കൂട്ടക്കൊല നടന്ന ദാരുണമായ വർഷം ഏതാണ്?",
"answer": "1919",
"malayalam_answer": "1919"
},
{
"id": 16,
"question": "Which Muslim poet and politician coined the iconic revolutionary slogan 'Inquilab Zindabad' in 1921?",
"malayalam_question": "1921-ൽ 'ഇൻക്വിലാബ് സിന്ദാബാദ്' എന്ന വിപ്ലവ മുദ്രാവാക്യം ആദ്യമായി രചിച്ച മുസ്ലീം കവിയും നേതാവും ആരാണ്?",
"answer": "Maulana Hasrat Mohani",
"malayalam_answer": "മൗലാനാ ഹസ്രത്ത് മോഹാനി"
},
{
"id": 17,
"question": "In which year was the Lucknow Pact signed between the Indian National Congress and the Muslim League to unite against British rule?",
"malayalam_question": "ബ്രിട്ടീഷ് ഭരണത്തിനെതിരെ പോരാടാൻ കോൺഗ്രസും മുസ്ലീം ലീഗും തമ്മിൽ ചരിത്രപരമായ 'ലഖ്നൗ കരാർ' ഒപ്പുവെച്ച വർഷം ഏതാണ്?",
"answer": "1916",
"malayalam_answer": "1916"
},
{
"id": 18,
"question": "Which revolutionary founded the Hindustan Socialist Republican Association (HSRA) in 1928 along with Bhagat Singh and Chandrashekhar Azad?",
"malayalam_question": "1928-ൽ ഭഗത് സിംഗിനും ചന്ദ്രശേഖർ ആസാദിനുമൊപ്പം എച്ച്.എസ്.ആർ.എ (HSRA) രൂപീകരിക്കുന്നതിൽ പ്രധാന പങ്കുവഹിച്ച വിപ്ലവകാരി ആരാണ്?",
"answer": "Sukhdev Thapar / Bhagat Singh",
"malayalam_answer": "സുഖ്ദേവ് ഥാപ്പർ / ഭഗത് സിംഗ്"
},
{
"id": 19,
"question": "Which movement was launched in 1919 alongside the Non-Cooperation Movement to protect the Ottoman Caliphate and unite Muslims and Hindus?",
"malayalam_question": "1919-ൽ ഓട്ടോമൻ ഖിലാഫത്ത് സംരക്ഷിക്കുന്നതിനായി നിസഹകരണ പ്രസ്ഥാനത്തോടൊപ്പം നടന്ന പ്രസ്ഥാനം ഏതാണ്?",
"answer": "Khilafat Movement (1919)",
"malayalam_answer": "ഖിലാഫത്ത് പ്രസ്ഥാനം (1919)"
},
{
"id": 20,
"question": "Which Muslim queen and freedom fighter led the resistance against the British East India Company in Awadh during the 1857 Indian Rebellion?",
"malayalam_question": "1857-ലെ ഒന്നാം സ്വാതന്ത്ര്യസമരത്തിൽ അവധിൽ ബ്രിട്ടീഷുകാർക്കെതിരെ പോരാടിയ പ്രമുഖ മുസ്ലീം രാജ്ഞി ആരാണ്?",
"answer": "Begum Hazrat Mahal",
"malayalam_answer": "ബീഗം ഹസ്രത്ത് മഹൽ"
},
{
"id": 21,
"question": "In which year did the historic Champaran Satyagraha, Mahatma Gandhi's first civil disobedience movement in India, take place?",
"malayalam_question": "ഗാന്ധിജിയുടെ ഇന്ത്യയിലെ ആദ്യത്തെ സത്യാഗ്രഹ പ്രസ്ഥാനമായ 'ചമ്പാരൻ സത്യാഗ്രഹം' നടന്ന വർഷം ഏതാണ്?",
"answer": "1917",
"malayalam_answer": "1917"
},
{
"id": 22,
"question": "Which freedom fighter served as the President of the Indian National Congress during the transfer of power on August 15, 1947?",
"malayalam_question": "1947 ഓഗസ്റ്റ് 15-ന് ഇന്ത്യക്ക് സ്വാതന്ത്ര്യം ലഭിക്കുമ്പോൾ ഇന്ത്യൻ നാഷണൽ കോൺഗ്രസിന്റെ പ്രസിഡന്റായിരുന്ന നേതാവ് ആരാണ്?",
"answer": "Acharya J. B. Kripalani",
"malayalam_answer": "ആചാര്യ ജെ. ബി. കൃപലാനി"
},
{
"id": 23,
"question": "In which year did the Royal Indian Navy (RIN) Mutiny break out in Bombay, accelerating the British exit from India?",
"malayalam_question": "ബ്രിട്ടീഷ് ഭരണം അവസാനിപ്പിക്കാൻ കാരണമായ റോയൽ ഇന്ത്യൻ നേവി (RIN) പ്രക്ഷോഭം ബോംബെയിൽ പൊട്ടിപ്പുറപ്പെട്ട വർഷം ഏതാണ്?",
"answer": "1946",
"malayalam_answer": "1946"
},
{
"id": 24,
"question": "Which Muslim freedom fighter from Malabar led the anti-British armed uprising during the 1921 Malabar Rebellion?",
"malayalam_question": "1921-ലെ മലബാർ പ്രക്ഷോഭത്തിൽ ബ്രിട്ടീഷ് ഭരണത്തിനെതിരെ സായുധ പോരാട്ടത്തിന് നേതൃത്വം നൽകിയ മലബാറിലെ മുസ്ലീം നേതാവ് ആരാണ്?",
"answer": "Variyamkunnath Kunjahammed Haji",
"malayalam_answer": "വാരിയംകുന്നത്ത് കുഞ്ഞഹമ്മദ് ഹാജി"
},
{
"id": 25,
"question": "In which year was the Indian Independence Act passed by the British Parliament, officially ending British rule in India?",
"malayalam_question": "ഇന്ത്യയിലെ ബ്രിട്ടീഷ് ഭരണം അവസാനിപ്പിച്ചുകൊണ്ട് ബ്രിട്ടീഷ് പാർലമെന്റ് 'ഇന്ത്യൻ ഇൻഡിപെൻഡൻസ് ആക്ട്' പാസാക്കിയ വർഷം ഏതാണ്?",
"answer": "1947",
"malayalam_answer": "1947"
}
]
}
async function loadQuestionsData() {
try {
const res = await fetch('questions.json');
if (res.ok) {
const data = await res.json();
quizData.questions = data.map((item, idx) => ({
id: idx + 1,
question: item.question,
malayalam_question: item.malayalam_question,
answer: item.answer,
malayalam_answer: item.malayalam_answer
}));
preloadAllAudio();
renderSlide();
}
} catch (e) {}
}
loadQuestionsData();
let currentQuestionIndex = 0
let currentPhase = 0
const slideContainer = document.getElementById('slide')
preloadAllAudio()
function stopAudio() {
isReading = false
if ('speechSynthesis' in window) {
try {
window.speechSynthesis.cancel()
} catch (e) {}
}
if (currentAudio) {
try {
currentAudio.pause()
currentAudio.src = ''
currentAudio = null
} catch (e) {}
}
}
function playAudioUrl(url, timeoutMs = 25000, playbackRate = 1.0) {
return new Promise((resolve, reject) => {
stopAudio()
isReading = true
const targetSrc = audioCache.get(url) || url
const audio = new Audio()
currentAudio = audio
audio.crossOrigin = 'anonymous'
audio.src = targetSrc
audio.volume = 1.0
audio.playbackRate = playbackRate
try {
const AudioCtx = window.AudioContext || window.webkitAudioContext
if (AudioCtx) {
const audioCtx = new AudioCtx()
const source = audioCtx.createMediaElementSource(audio)
const gainNode = audioCtx.createGain()
gainNode.gain.value = 1.5
source.connect(gainNode)
gainNode.connect(audioCtx.destination)
}
} catch (e) {}
const timer = setTimeout(() => {
stopAudio()
reject(new Error('Audio playback timeout'))
}, timeoutMs)
audio.onended = () => {
clearTimeout(timer)
currentAudio = null
isReading = false
resolve()
}
audio.onerror = (e) => {
clearTimeout(timer)
currentAudio = null
isReading = false
reject(e)
}
audio.play().catch((e) => {
clearTimeout(timer)
currentAudio = null
isReading = false
reject(e)
})
})
}
function speakEnglishWebSpeech(text) {
return new Promise((resolve) => {
stopAudio()
isReading = true
if (!('speechSynthesis' in window)) return resolve()
const utterance = new SpeechSynthesisUtterance(text)
utterance.lang = 'en-IN'
utterance.rate = 0.8
utterance.volume = 1.0
utterance.onend = () => {
isReading = false
resolve()
}
utterance.onerror = () => {
isReading = false
resolve()
}
window.speechSynthesis.speak(utterance)
})
}
function speakMalayalamWebSpeech(text) {
return new Promise((resolve) => {
stopAudio()
isReading = true
if (!('speechSynthesis' in window)) return resolve()
const utterance = new SpeechSynthesisUtterance(text)
utterance.lang = 'ml-IN'
utterance.rate = 1.0
utterance.volume = 1.0
utterance.onend = () => {
isReading = false
resolve()
}
utterance.onerror = () => {
isReading = false
resolve()
}
window.speechSynthesis.speak(utterance)
})
}
async function speakQuestion(q) {
stopAudio()
isReading = true
try {
await playAudioUrl(`audio/q${q.id}_eng.wav`, 25000, 1.0)
} catch (e) {
await speakEnglishWebSpeech(`Question number ${q.id}. ${q.question}`)
}
if (!isReading && currentPhase !== 2.5) return
try {
await playAudioUrl(`audio/q${q.id}_mal.wav`, 25000, 1.0)
} catch (e) {
await speakMalayalamWebSpeech(`ചോദ്യം ${q.id}. ${q.malayalam_question}`)
}
}
let tieBreakerSkipped = false
function renderSlide() {
let html = `<div class="kbd-hint">⌨️ Nav: Space / Arrows | <a href="/pdf" target="_blank" style="color: #58a6ff; text-decoration: none; font-weight: 600;">📄 Printable PDF</a></div>`
if (currentPhase === 0) {
stopAudio()
html += `
<div class="badge">Quiz Competition</div>
<h1>${quizData.title_eng}</h1>
<div class="sub-title">${quizData.title_mal}</div>
<div class="controls">
<button onclick="window.nextPhase(event)">Start Quiz</button>
<button class="secondary" onclick="window.open('/pdf', '_blank')">📄 Printable PDF</button>
</div>
`
} else if (currentPhase === 0.5) {
stopAudio()
const tieCount = quizData.questions.length - 20
html += `
<div class="badge" style="background: linear-gradient(135deg, #d29922, #f0883e); color: #161b22; font-weight: 700;">🔥 Tie Breaker Round</div>
<h1>Tie Breaker Round</h1>
<div class="sub-title">ടൈ ബ്രേക്കർ റൗണ്ട്</div>
<p style="color: #8b949e; font-size: 1.2rem; margin-bottom: 25px; font-weight: 600;">${tieCount} Tie Breaker Questions | ${tieCount} ടൈ ബ്രേക്കർ ചോദ്യങ്ങൾ</p>
<div class="controls">
<button class="secondary" onclick="window.prevPhase(event)">Previous</button>
<button onclick="window.startTieBreaker(event)">Start Tie Breaker 🎯</button>
<button class="secondary" onclick="window.skipTieBreaker(event)">Skip ⏭️</button>
</div>
`
} else if (currentPhase === 1) {
stopAudio()
const isTieBreaker = currentQuestionIndex >= 20
const tieCount = quizData.questions.length - 20
const qNumDisplay = isTieBreaker
? `Tie Breaker - Question ${currentQuestionIndex - 19} of ${tieCount}`
: `Question ${currentQuestionIndex + 1} of 20`
const badgeStyle = isTieBreaker
? `style="background: linear-gradient(135deg, #d29922, #f0883e); color: #161b22; font-weight: 700;"`
: ``
html += `
<div class="badge" ${badgeStyle}>${qNumDisplay}</div>
<h1>Get Ready!</h1>
<div class="controls">
<button class="secondary" onclick="window.prevPhase(event)">Previous</button>
<button onclick="window.nextPhase(event)">Show Question</button>
</div>
`
} else if (currentPhase === 2) {
stopAudio()
const q = quizData.questions[currentQuestionIndex]
const isTieBreaker = currentQuestionIndex >= 20
const tieCount = quizData.questions.length - 20
const qNumDisplay = isTieBreaker
? `Tie Breaker - Question ${currentQuestionIndex - 19} of ${tieCount}`
: `Question ${currentQuestionIndex + 1} of 20`
const badgeStyle = isTieBreaker
? `style="background: linear-gradient(135deg, #d29922, #f0883e); color: #161b22; font-weight: 700;"`
: ``
html += `
<div class="badge" ${badgeStyle}>${qNumDisplay}</div>
<div class="qn-eng"><strong>Q${q.id}.</strong> ${q.question}</div>
<div class="qn-mal"><strong>ചോദ്യം ${q.id}.</strong> ${q.malayalam_question}</div>
<div class="controls">
<button class="secondary" onclick="window.prevPhase(event)">Previous</button>
<button onclick="window.nextPhase(event)">Read Question 🔊</button>
</div>
`
} else if (currentPhase === 2.5) {
const q = quizData.questions[currentQuestionIndex]
const isTieBreaker = currentQuestionIndex >= 20
const spkBadgeText = isTieBreaker ? '🔊 Reading Tie Breaker Question...' : '🔊 Reading Question...'
html += `
<div class="speaking-badge">${spkBadgeText}</div>
<div class="qn-eng"><strong>Q${q.id}.</strong> ${q.question}</div>
<div class="qn-mal"><strong>ചോദ്യം ${q.id}.</strong> ${q.malayalam_question}</div>
<div class="controls">
<button class="secondary" onclick="window.reSpeak(event)">Re-play 🔊</button>
<button onclick="window.nextPhase(event)">Pen Down</button>
</div>
`
speakQuestion(q)
} else if (currentPhase === 3) {
stopAudio()
html += `
<div class="pen-down">✏️ PEN DOWN!</div>
<div class="controls">
<button class="secondary" onclick="window.prevPhase(event)">Previous</button>
<button onclick="window.nextPhase(event)">Show Answer</button>
</div>
`
} else if (currentPhase === 4) {
stopAudio()
const q = quizData.questions[currentQuestionIndex]
const isLastQuestion = currentQuestionIndex + 1 === quizData.questions.length
const isQuestion20 = currentQuestionIndex === 19
const isTieBreaker = currentQuestionIndex >= 20
let nextBtnText = 'Next Question'
if (isQuestion20) {
nextBtnText = 'Tie Breaker Round ➔'
} else if (isLastQuestion) {
nextBtnText = 'Finish Quiz'
}
const badgeTitle = isTieBreaker ? `Tie Breaker - Answer Key` : `Answer Key`
const badgeStyle = isTieBreaker
? `style="background: linear-gradient(135deg, #d29922, #f0883e); color: #161b22; font-weight: 700;"`
: ``
html += `
<div class="badge" ${badgeStyle}>${badgeTitle}</div>
<div class="answer-box">
<div class="ans-eng">${q.answer}</div>
<div class="ans-mal">${q.malayalam_answer}</div>
</div>
<div class="controls">
<button class="secondary" onclick="window.prevPhase(event)">Previous</button>
<button onclick="window.nextPhase(event)">${nextBtnText}</button>
</div>
`
} else if (currentPhase === 5) {
stopAudio()
html += `
<div class="badge">Quiz Finished</div>
<h1>Congratulations! 🎉</h1>
<div class="sub-title">ക്വിസ് വിജയകരമായി പൂർത്തിയായി!</div>
<div class="controls">
<button class="secondary" onclick="window.prevPhase(event)">Previous</button>
<button class="secondary" onclick="window.open('/pdf', '_blank')">📄 Printable PDF</button>
<button onclick="window.restartQuiz(event)">Restart Quiz 🔄</button>
</div>
`
}
slideContainer.innerHTML = html
}
window.startTieBreaker = function (e) {
if (e && e.target && e.target.blur) e.target.blur()
tieBreakerSkipped = false
currentQuestionIndex = 20
currentPhase = 1
renderSlide()
}
window.skipTieBreaker = function (e) {
if (e && e.target && e.target.blur) e.target.blur()
tieBreakerSkipped = true
currentPhase = 5
renderSlide()
}
window.nextPhase = function (e) {
if (e && e.target && e.target.blur) e.target.blur()
if (currentPhase === 0) {
currentPhase = 1
} else if (currentPhase === 0.5) {
window.startTieBreaker()
return
} else if (currentPhase === 1) {
currentPhase = 2
} else if (currentPhase === 2) {
currentPhase = 2.5
} else if (currentPhase === 2.5) {
currentPhase = 3
} else if (currentPhase === 3) {
currentPhase = 4
} else if (currentPhase === 4) {
if (currentQuestionIndex === 19) {
currentPhase = 0.5
} else if (currentQuestionIndex + 1 < quizData.questions.length) {
currentQuestionIndex++
currentPhase = 1
} else {
currentPhase = 5
}
}
renderSlide()
}
window.prevPhase = function (e) {
if (e && e.target && e.target.blur) e.target.blur()
if (currentPhase === 5) {
if (tieBreakerSkipped) {
currentPhase = 0.5
} else {
currentQuestionIndex = quizData.questions.length - 1
currentPhase = 4
}
} else if (currentPhase === 4) {
currentPhase = 3
} else if (currentPhase === 3) {
currentPhase = 2.5
} else if (currentPhase === 2.5) {
currentPhase = 2
} else if (currentPhase === 2) {
currentPhase = 1
} else if (currentPhase === 1) {
if (currentQuestionIndex === 20) {
currentPhase = 0.5
} else if (currentQuestionIndex > 0) {
currentQuestionIndex--
currentPhase = 4
} else {
currentPhase = 0
}
} else if (currentPhase === 0.5) {
currentQuestionIndex = 19
currentPhase = 4
}
renderSlide()
}
window.reSpeak = function (e) {
if (e && e.target && e.target.blur) e.target.blur()
speakQuestion(quizData.questions[currentQuestionIndex])
}
window.restartQuiz = function (e) {
if (e && e.target && e.target.blur) e.target.blur()
stopAudio()
currentQuestionIndex = 0
currentPhase = 0
tieBreakerSkipped = false
renderSlide()
}
document.addEventListener('keydown', function (event) {
if (event.code === 'Space' || event.code === 'ArrowRight') {
event.preventDefault()
window.nextPhase()
} else if (event.code === 'ArrowLeft') {
event.preventDefault()
window.prevPhase()
}
})
renderSlide()
</script>
</body>
</html>