-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaccessibility.html
More file actions
842 lines (731 loc) · 33.8 KB
/
accessibility.html
File metadata and controls
842 lines (731 loc) · 33.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
840
841
842
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Accessibility Settings - EduMorph</title>
<link rel="stylesheet" href="styles.css">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
<style>
.accessibility-settings {
display: grid;
grid-template-columns: 1fr 2fr;
gap: 2rem;
}
.settings-panel {
display: flex;
flex-direction: column;
gap: 1.5rem;
}
.setting-group {
background: white;
padding: 1.5rem;
border-radius: 0.75rem;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.setting-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 1rem 0;
border-bottom: 1px solid #f3f4f6;
}
.setting-item:last-child {
border-bottom: none;
}
.setting-info h4 {
margin: 0 0 0.25rem 0;
color: #374151;
}
.setting-info p {
margin: 0;
font-size: 0.875rem;
color: #6b7280;
}
.switch {
position: relative;
width: 3rem;
height: 1.5rem;
background: #d1d5db;
border-radius: 0.75rem;
cursor: pointer;
transition: background 0.2s;
}
.switch.active {
background: #4f46e5;
}
.switch-thumb {
position: absolute;
top: 0.125rem;
left: 0.125rem;
width: 1.25rem;
height: 1.25rem;
background: white;
border-radius: 50%;
transition: transform 0.2s;
}
.switch.active .switch-thumb {
transform: translateX(1.5rem);
}
.slider-container {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.slider {
width: 100%;
height: 0.5rem;
background: #e5e7eb;
border-radius: 0.25rem;
outline: none;
cursor: pointer;
}
.slider::-webkit-slider-thumb {
appearance: none;
width: 1.25rem;
height: 1.25rem;
background: #4f46e5;
border-radius: 50%;
cursor: pointer;
}
.slider::-moz-range-thumb {
width: 1.25rem;
height: 1.25rem;
background: #4f46e5;
border-radius: 50%;
cursor: pointer;
border: none;
}
.demo-area {
display: flex;
flex-direction: column;
gap: 1.5rem;
}
.demo-card {
background: white;
padding: 1.5rem;
border-radius: 0.75rem;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.tts-demo {
background: #f8fafc;
padding: 1rem;
border-radius: 0.5rem;
margin-bottom: 1rem;
}
.tts-controls {
display: flex;
gap: 0.5rem;
align-items: center;
}
.sample-content {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 1rem;
margin-top: 1rem;
}
.content-box {
padding: 1rem;
border-radius: 0.5rem;
border: 1px solid;
}
.content-box.blue {
background: #eff6ff;
border-color: #bfdbfe;
}
.content-box.green {
background: #f0fdf4;
border-color: #bbf7d0;
}
.content-box.yellow {
background: #fefce8;
border-color: #fde047;
}
.keyboard-shortcuts {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 1rem;
}
.shortcut-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0.5rem 0;
}
.kbd {
background: #f3f4f6;
border: 1px solid #d1d5db;
border-radius: 0.25rem;
padding: 0.25rem 0.5rem;
font-size: 0.75rem;
font-family: monospace;
}
/* High contrast mode styles */
.high-contrast {
background: #000000 !important;
color: #ffffff !important;
}
.high-contrast .setting-group,
.high-contrast .demo-card {
background: #1a1a1a !important;
border: 1px solid #404040 !important;
}
.high-contrast .content-box {
background: #2a2a2a !important;
border-color: #606060 !important;
}
.high-contrast .tts-demo {
background: #2a2a2a !important;
}
/* Color blind filters */
.protanopia {
filter: sepia(100%) saturate(0%) hue-rotate(0deg);
}
.deuteranopia {
filter: sepia(100%) saturate(50%) hue-rotate(90deg);
}
.tritanopia {
filter: sepia(100%) saturate(200%) hue-rotate(180deg);
}
/* Reduced motion */
.reduced-motion * {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
@media (max-width: 768px) {
.accessibility-settings {
grid-template-columns: 1fr;
}
.sample-content {
grid-template-columns: 1fr;
}
.keyboard-shortcuts {
grid-template-columns: 1fr;
}
}
</style>
</head>
<body id="pageBody">
<div class="dashboard-layout">
<!-- Sidebar -->
<aside class="sidebar">
<div class="sidebar-header">
<div class="sidebar-logo">
<i class="fas fa-graduation-cap"></i>
<span>EduMorph</span>
</div>
</div>
<nav class="sidebar-nav">
<a href="dashboard.html" class="nav-item">
<i class="fas fa-home"></i>
<span>Dashboard</span>
</a>
<a href="courses.html" class="nav-item">
<i class="fas fa-book"></i>
<span>Courses</span>
</a>
<a href="ai-assistant.html" class="nav-item">
<i class="fas fa-robot"></i>
<span>AI Assistant</span>
</a>
<a href="ai-recommendations.html" class="nav-item">
<i class="fas fa-lightbulb"></i>
<span>Recommendations</span>
</a>
<a href="ai-generator.html" class="nav-item">
<i class="fas fa-magic"></i>
<span>Content Generator</span>
</a>
<a href="feedback.html" class="nav-item">
<i class="fas fa-comment"></i>
<span>Feedback</span>
</a>
<a href="accessibility.html" class="nav-item active">
<i class="fas fa-universal-access"></i>
<span>Accessibility</span>
</a>
<a href="profile.html" class="nav-item">
<i class="fas fa-user"></i>
<span>Profile</span>
</a>
</nav>
<div class="sidebar-footer">
<button class="btn btn-outline btn-small" onclick="logout()">
<i class="fas fa-sign-out-alt"></i>
Logout
</button>
</div>
</aside>
<!-- Main Content -->
<main class="main-content">
<header class="page-header">
<h1>Accessibility Center ♿</h1>
<p>Customize your learning experience with our accessibility tools</p>
</header>
<div class="page-content">
<div class="accessibility-settings">
<!-- Settings Panel -->
<div class="settings-panel">
<!-- Visual Settings -->
<div class="setting-group">
<div class="card-header">
<h3><i class="fas fa-eye"></i> Visual Settings</h3>
<p>Adjust visual elements for better readability</p>
</div>
<div class="setting-item">
<div class="setting-info">
<h4>High Contrast Mode</h4>
<p>Increase contrast for better visibility</p>
</div>
<div class="switch" id="highContrastSwitch" onclick="toggleHighContrast()">
<div class="switch-thumb"></div>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<h4>Font Size: <span id="fontSizeValue">16px</span></h4>
<p>Adjust text size for better readability</p>
</div>
<div class="slider-container">
<input type="range" class="slider" id="fontSizeSlider" min="12" max="24" value="16" oninput="updateFontSize(this.value)">
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<h4>Dyslexia-Friendly Font</h4>
<p>Use fonts designed for dyslexic readers</p>
</div>
<div class="switch" id="dyslexiaFontSwitch" onclick="toggleDyslexiaFont()">
<div class="switch-thumb"></div>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<h4>Color Blind Support</h4>
<p>Adjust colors for color vision deficiency</p>
</div>
<select id="colorBlindSelect" onchange="updateColorBlindMode(this.value)">
<option value="none">None</option>
<option value="protanopia">Protanopia</option>
<option value="deuteranopia">Deuteranopia</option>
<option value="tritanopia">Tritanopia</option>
</select>
</div>
<div class="setting-item">
<div class="setting-info">
<h4>Reduce Motion</h4>
<p>Minimize animations and transitions</p>
</div>
<div class="switch" id="reducedMotionSwitch" onclick="toggleReducedMotion()">
<div class="switch-thumb"></div>
</div>
</div>
</div>
<!-- Audio Settings -->
<div class="setting-group">
<div class="card-header">
<h3><i class="fas fa-volume-up"></i> Audio Settings</h3>
<p>Configure text-to-speech and audio features</p>
</div>
<div class="setting-item">
<div class="setting-info">
<h4>Text-to-Speech</h4>
<p>Enable voice reading of content</p>
</div>
<div class="switch" id="ttsSwitch" onclick="toggleTextToSpeech()">
<div class="switch-thumb"></div>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<h4>Voice Speed: <span id="voiceSpeedValue">1.0x</span></h4>
<p>Adjust speech rate</p>
</div>
<div class="slider-container">
<input type="range" class="slider" id="voiceSpeedSlider" min="0.5" max="2" step="0.1" value="1" oninput="updateVoiceSpeed(this.value)">
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<h4>Language</h4>
<p>Select voice language</p>
</div>
<select id="languageSelect" onchange="updateLanguage(this.value)">
<option value="en">English</option>
<option value="es">Español</option>
<option value="fr">Français</option>
<option value="de">Deutsch</option>
<option value="zh">中文</option>
<option value="ja">日本語</option>
</select>
</div>
</div>
<!-- Navigation Settings -->
<div class="setting-group">
<div class="card-header">
<h3><i class="fas fa-keyboard"></i> Navigation</h3>
<p>Keyboard and navigation preferences</p>
</div>
<div class="setting-item">
<div class="setting-info">
<h4>Enhanced Keyboard Navigation</h4>
<p>Improved keyboard shortcuts and focus</p>
</div>
<div class="switch active" id="keyboardNavSwitch" onclick="toggleKeyboardNav()">
<div class="switch-thumb"></div>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<h4>Screen Reader Optimization</h4>
<p>Enhanced compatibility with screen readers</p>
</div>
<div class="switch" id="screenReaderSwitch" onclick="toggleScreenReader()">
<div class="switch-thumb"></div>
</div>
</div>
</div>
</div>
<!-- Demo Area -->
<div class="demo-area">
<!-- Text-to-Speech Demo -->
<div class="demo-card">
<div class="card-header">
<h3><i class="fas fa-volume-up"></i> Text-to-Speech Demo</h3>
<p>Try out the text-to-speech functionality</p>
</div>
<div class="tts-demo" id="ttsDemo">
<p id="demoText">Welcome to EduMorph's accessibility features. These tools are designed to make learning accessible for everyone. You can adjust font sizes, enable high contrast mode, use text-to-speech, and customize many other settings to create the perfect learning environment for your needs.</p>
</div>
<div class="tts-controls">
<button class="btn btn-primary" id="playBtn" onclick="togglePlayback()" disabled>
<i class="fas fa-play" id="playIcon"></i>
<span id="playText">Play</span>
</button>
<button class="btn btn-outline" onclick="stopPlayback()" disabled id="stopBtn">
<i class="fas fa-stop"></i>
</button>
<button class="btn btn-outline" onclick="skipBackward()" disabled id="skipBackBtn">
<i class="fas fa-backward"></i>
</button>
<button class="btn btn-outline" onclick="skipForward()" disabled id="skipForwardBtn">
<i class="fas fa-forward"></i>
</button>
</div>
<div id="ttsDisabled" style="margin-top: 1rem; color: #6b7280; font-size: 0.875rem;">
Enable Text-to-Speech in the settings to use this feature
</div>
</div>
<!-- Sample Content -->
<div class="demo-card">
<div class="card-header">
<h3>Sample Learning Content</h3>
<p>See how your accessibility settings affect content display</p>
</div>
<div id="sampleContent">
<h3>The Water Cycle</h3>
<p>The water cycle is a continuous process that moves water throughout Earth's atmosphere, land, and oceans. This natural cycle is powered by energy from the sun and includes several key stages.</p>
<div class="sample-content">
<div class="content-box blue">
<h4>Evaporation</h4>
<p>Heat from the sun causes water in oceans, lakes, and rivers to change from liquid to vapor.</p>
</div>
<div class="content-box green">
<h4>Condensation</h4>
<p>Water vapor rises and cools, forming tiny droplets that create clouds.</p>
</div>
</div>
<div class="content-box yellow" style="margin-top: 1rem;">
<h4>💡 Quick Tip</h4>
<p>Remember the water cycle with this acronym: <strong>EPIC</strong> - Evaporation, Precipitation, Infiltration, Collection</p>
</div>
</div>
</div>
<!-- Keyboard Shortcuts -->
<div class="demo-card">
<div class="card-header">
<h3><i class="fas fa-keyboard"></i> Keyboard Shortcuts</h3>
<p>Navigate efficiently using keyboard shortcuts</p>
</div>
<div class="keyboard-shortcuts">
<div>
<div class="shortcut-item">
<span>Toggle Text-to-Speech</span>
<span class="kbd">Ctrl + T</span>
</div>
<div class="shortcut-item">
<span>Increase Font Size</span>
<span class="kbd">Ctrl + +</span>
</div>
<div class="shortcut-item">
<span>Decrease Font Size</span>
<span class="kbd">Ctrl + -</span>
</div>
</div>
<div>
<div class="shortcut-item">
<span>High Contrast Toggle</span>
<span class="kbd">Ctrl + H</span>
</div>
<div class="shortcut-item">
<span>Skip to Main Content</span>
<span class="kbd">Alt + M</span>
</div>
<div class="shortcut-item">
<span>Focus Search</span>
<span class="kbd">Ctrl + K</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
</div>
<script src="script.js"></script>
<script>
// Accessibility settings state
let accessibilitySettings = {
highContrast: false,
fontSize: 16,
textToSpeech: false,
voiceSpeed: 1.0,
language: 'en',
reducedMotion: false,
keyboardNav: true,
screenReader: false,
dyslexiaFont: false,
colorBlindMode: 'none'
};
let speechSynthesis = window.speechSynthesis;
let currentUtterance = null;
let isPlaying = false;
// Initialize page
document.addEventListener('DOMContentLoaded', function() {
loadSettings();
setupKeyboardShortcuts();
updateTTSControls();
});
function loadSettings() {
const saved = localStorage.getItem('edumorph_accessibility');
if (saved) {
accessibilitySettings = { ...accessibilitySettings, ...JSON.parse(saved) };
}
// Apply saved settings
applyAllSettings();
}
function saveSettings() {
localStorage.setItem('edumorph_accessibility', JSON.stringify(accessibilitySettings));
}
function applyAllSettings() {
// Update UI controls
document.getElementById('fontSizeSlider').value = accessibilitySettings.fontSize;
document.getElementById('fontSizeValue').textContent = accessibilitySettings.fontSize + 'px';
document.getElementById('voiceSpeedSlider').value = accessibilitySettings.voiceSpeed;
document.getElementById('voiceSpeedValue').textContent = accessibilitySettings.voiceSpeed + 'x';
document.getElementById('languageSelect').value = accessibilitySettings.language;
document.getElementById('colorBlindSelect').value = accessibilitySettings.colorBlindMode;
// Update switches
updateSwitch('highContrastSwitch', accessibilitySettings.highContrast);
updateSwitch('ttsSwitch', accessibilitySettings.textToSpeech);
updateSwitch('dyslexiaFontSwitch', accessibilitySettings.dyslexiaFont);
updateSwitch('reducedMotionSwitch', accessibilitySettings.reducedMotion);
updateSwitch('keyboardNavSwitch', accessibilitySettings.keyboardNav);
updateSwitch('screenReaderSwitch', accessibilitySettings.screenReader);
// Apply visual changes
updateFontSize(accessibilitySettings.fontSize);
if (accessibilitySettings.highContrast) toggleHighContrast();
if (accessibilitySettings.dyslexiaFont) toggleDyslexiaFont();
if (accessibilitySettings.reducedMotion) toggleReducedMotion();
updateColorBlindMode(accessibilitySettings.colorBlindMode);
updateTTSControls();
}
function updateSwitch(switchId, active) {
const switchEl = document.getElementById(switchId);
if (active) {
switchEl.classList.add('active');
} else {
switchEl.classList.remove('active');
}
}
function setupKeyboardShortcuts() {
document.addEventListener('keydown', function(e) {
if (e.ctrlKey || e.metaKey) {
switch(e.key) {
case 't':
e.preventDefault();
toggleTextToSpeech();
break;
case 'h':
e.preventDefault();
toggleHighContrast();
break;
case '=':
case '+':
e.preventDefault();
if (accessibilitySettings.fontSize < 24) {
updateFontSize(accessibilitySettings.fontSize + 1);
document.getElementById('fontSizeSlider').value = accessibilitySettings.fontSize;
}
break;
case '-':
e.preventDefault();
if (accessibilitySettings.fontSize > 12) {
updateFontSize(accessibilitySettings.fontSize - 1);
document.getElementById('fontSizeSlider').value = accessibilitySettings.fontSize;
}
break;
}
}
});
}
function toggleHighContrast() {
accessibilitySettings.highContrast = !accessibilitySettings.highContrast;
updateSwitch('highContrastSwitch', accessibilitySettings.highContrast);
const body = document.getElementById('pageBody');
if (accessibilitySettings.highContrast) {
body.classList.add('high-contrast');
} else {
body.classList.remove('high-contrast');
}
saveSettings();
}
function updateFontSize(size) {
accessibilitySettings.fontSize = parseInt(size);
document.getElementById('fontSizeValue').textContent = size + 'px';
// Apply font size to content areas
const contentAreas = document.querySelectorAll('#sampleContent, #ttsDemo');
contentAreas.forEach(area => {
area.style.fontSize = size + 'px';
});
saveSettings();
}
function toggleTextToSpeech() {
accessibilitySettings.textToSpeech = !accessibilitySettings.textToSpeech;
updateSwitch('ttsSwitch', accessibilitySettings.textToSpeech);
updateTTSControls();
saveSettings();
}
function updateVoiceSpeed(speed) {
accessibilitySettings.voiceSpeed = parseFloat(speed);
document.getElementById('voiceSpeedValue').textContent = speed + 'x';
saveSettings();
}
function updateLanguage(lang) {
accessibilitySettings.language = lang;
saveSettings();
}
function toggleDyslexiaFont() {
accessibilitySettings.dyslexiaFont = !accessibilitySettings.dyslexiaFont;
updateSwitch('dyslexiaFontSwitch', accessibilitySettings.dyslexiaFont);
const contentAreas = document.querySelectorAll('#sampleContent, #ttsDemo');
contentAreas.forEach(area => {
if (accessibilitySettings.dyslexiaFont) {
area.style.fontFamily = 'monospace';
} else {
area.style.fontFamily = '';
}
});
saveSettings();
}
function updateColorBlindMode(mode) {
accessibilitySettings.colorBlindMode = mode;
const body = document.getElementById('pageBody');
body.classList.remove('protanopia', 'deuteranopia', 'tritanopia');
if (mode !== 'none') {
body.classList.add(mode);
}
saveSettings();
}
function toggleReducedMotion() {
accessibilitySettings.reducedMotion = !accessibilitySettings.reducedMotion;
updateSwitch('reducedMotionSwitch', accessibilitySettings.reducedMotion);
const body = document.getElementById('pageBody');
if (accessibilitySettings.reducedMotion) {
body.classList.add('reduced-motion');
} else {
body.classList.remove('reduced-motion');
}
saveSettings();
}
function toggleKeyboardNav() {
accessibilitySettings.keyboardNav = !accessibilitySettings.keyboardNav;
updateSwitch('keyboardNavSwitch', accessibilitySettings.keyboardNav);
saveSettings();
}
function toggleScreenReader() {
accessibilitySettings.screenReader = !accessibilitySettings.screenReader;
updateSwitch('screenReaderSwitch', accessibilitySettings.screenReader);
saveSettings();
}
function updateTTSControls() {
const controls = ['playBtn', 'stopBtn', 'skipBackBtn', 'skipForwardBtn'];
const disabledMessage = document.getElementById('ttsDisabled');
controls.forEach(id => {
document.getElementById(id).disabled = !accessibilitySettings.textToSpeech;
});
disabledMessage.style.display = accessibilitySettings.textToSpeech ? 'none' : 'block';
}
function togglePlayback() {
if (!accessibilitySettings.textToSpeech) return;
if (isPlaying) {
pausePlayback();
} else {
startPlayback();
}
}
function startPlayback() {
const text = document.getElementById('demoText').textContent;
if (currentUtterance) {
speechSynthesis.cancel();
}
currentUtterance = new SpeechSynthesisUtterance(text);
currentUtterance.rate = accessibilitySettings.voiceSpeed;
currentUtterance.lang = accessibilitySettings.language;
currentUtterance.onstart = function() {
isPlaying = true;
document.getElementById('playIcon').className = 'fas fa-pause';
document.getElementById('playText').textContent = 'Pause';
};
currentUtterance.onend = function() {
isPlaying = false;
document.getElementById('playIcon').className = 'fas fa-play';
document.getElementById('playText').textContent = 'Play';
};
currentUtterance.onerror = function() {
isPlaying = false;
document.getElementById('playIcon').className = 'fas fa-play';
document.getElementById('playText').textContent = 'Play';
};
speechSynthesis.speak(currentUtterance);
}
function pausePlayback() {
speechSynthesis.pause();
isPlaying = false;
document.getElementById('playIcon').className = 'fas fa-play';
document.getElementById('playText').textContent = 'Resume';
}
function stopPlayback() {
speechSynthesis.cancel();
isPlaying = false;
document.getElementById('playIcon').className = 'fas fa-play';
document.getElementById('playText').textContent = 'Play';
}
function skipBackward() {
// In a real implementation, this would skip to previous sentence/paragraph
stopPlayback();
}
function skipForward() {
// In a real implementation, this would skip to next sentence/paragraph
stopPlayback();
}
function logout() {
localStorage.removeItem('edumorph_user');
localStorage.removeItem('edumorph_session');
window.location.href = 'index.html';
}
</script>
</body>
</html>