-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathai-assistant.html
More file actions
958 lines (838 loc) · 36.2 KB
/
ai-assistant.html
File metadata and controls
958 lines (838 loc) · 36.2 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
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AI Assistant - 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>
.dashboard-layout {
display: flex;
height: 100vh;
}
.sidebar {
width: 250px;
background: #1f2937;
color: white;
padding: 20px;
box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
display: flex;
flex-direction: column;
}
.sidebar-header {
margin-bottom: 20px;
}
.sidebar-logo {
display: flex;
align-items: center;
gap: 8px;
font-size: 1.5rem;
font-weight: 700;
}
.sidebar-logo i {
color: #8b5cf6;
}
.sidebar-nav {
flex: 1;
margin-bottom: 20px;
}
.nav-item {
display: flex;
align-items: center;
gap: 8px;
padding: 12px 0;
color: white;
text-decoration: none;
transition: color 0.3s ease;
border-radius: 8px;
margin-bottom: 4px;
}
.nav-item:hover {
color: #8b5cf6;
background: rgba(139, 92, 246, 0.1);
padding-left: 8px;
}
.nav-item.active {
color: #8b5cf6;
background: rgba(139, 92, 246, 0.1);
padding-left: 8px;
}
.nav-item i {
width: 20px;
text-align: center;
}
.sidebar-footer {
text-align: center;
}
.main-content {
flex: 1;
background: #f8f9fa;
overflow-y: auto;
display: flex;
flex-direction: column;
}
.page-header {
background: white;
padding: 2rem;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
border-bottom: 1px solid #e5e7eb;
}
.page-header h1 {
font-size: 2rem;
font-weight: 700;
color: #1f2937;
margin-bottom: 0.5rem;
}
.page-header p {
color: #6b7280;
font-size: 1.125rem;
margin: 0;
}
.ai-content {
flex: 1;
padding: 2rem;
display: flex;
flex-direction: column;
gap: 2rem;
}
.ai-stats {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 1.5rem;
margin-bottom: 2rem;
}
.stat-card {
background: white;
padding: 1.5rem;
border-radius: 0.75rem;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
display: flex;
align-items: center;
gap: 1rem;
}
.stat-icon {
width: 3rem;
height: 3rem;
background: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
border-radius: 0.5rem;
display: flex;
align-items: center;
justify-content: center;
color: white;
font-size: 1.25rem;
}
.stat-content h3 {
font-size: 1.5rem;
color: #1f2937;
margin-bottom: 0.25rem;
}
.stat-content p {
color: #6b7280;
font-size: 0.875rem;
margin: 0;
}
.chat-container {
background: white;
border-radius: 0.75rem;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
display: flex;
flex-direction: column;
height: 600px;
overflow: hidden;
}
.chat-header {
background: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
color: white;
padding: 1.5rem;
display: flex;
align-items: center;
gap: 1rem;
}
.chat-avatar {
width: 3rem;
height: 3rem;
background: rgba(255, 255, 255, 0.2);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 1.25rem;
}
.chat-info h3 {
margin: 0 0 0.25rem 0;
font-size: 1.25rem;
}
.chat-info p {
margin: 0;
opacity: 0.9;
font-size: 0.875rem;
}
.chat-messages {
flex: 1;
padding: 1.5rem;
overflow-y: auto;
display: flex;
flex-direction: column;
gap: 1rem;
}
.message {
display: flex;
gap: 0.75rem;
max-width: 80%;
}
.message.user {
align-self: flex-end;
flex-direction: row-reverse;
}
.message-avatar {
width: 2.5rem;
height: 2.5rem;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 0.875rem;
font-weight: 600;
flex-shrink: 0;
}
.message.ai .message-avatar {
background: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
color: white;
}
.message.user .message-avatar {
background: #f3f4f6;
color: #374151;
}
.message-content {
background: #f8fafc;
padding: 0.75rem 1rem;
border-radius: 1rem;
border: 1px solid #e2e8f0;
line-height: 1.5;
}
.message.user .message-content {
background: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
color: white;
border-color: transparent;
}
.message-time {
font-size: 0.75rem;
color: #9ca3af;
margin-top: 0.25rem;
}
.message.user .message-time {
color: rgba(255, 255, 255, 0.8);
}
.typing-indicator {
display: flex;
gap: 0.75rem;
max-width: 80%;
}
.typing-dots {
background: #f8fafc;
padding: 0.75rem 1rem;
border-radius: 1rem;
border: 1px solid #e2e8f0;
display: flex;
gap: 0.25rem;
align-items: center;
}
.typing-dot {
width: 0.5rem;
height: 0.5rem;
background: #9ca3af;
border-radius: 50%;
animation: typing 1.4s infinite ease-in-out;
}
.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes typing {
0%, 80%, 100% {
transform: scale(0.8);
opacity: 0.5;
}
40% {
transform: scale(1);
opacity: 1;
}
}
.quick-actions {
padding: 1rem 1.5rem;
border-top: 1px solid #e5e7eb;
background: #f9fafb;
}
.quick-actions h4 {
margin: 0 0 0.75rem 0;
font-size: 0.875rem;
color: #6b7280;
font-weight: 600;
}
.action-buttons {
display: flex;
gap: 0.5rem;
flex-wrap: wrap;
}
.action-btn {
background: white;
border: 1px solid #d1d5db;
padding: 0.5rem 0.75rem;
border-radius: 0.5rem;
font-size: 0.875rem;
cursor: pointer;
transition: all 0.2s ease;
display: flex;
align-items: center;
gap: 0.25rem;
}
.action-btn:hover {
border-color: #8b5cf6;
color: #8b5cf6;
background: #f8f4ff;
}
.chat-input-area {
padding: 1.5rem;
border-top: 1px solid #e5e7eb;
background: white;
}
.input-container {
display: flex;
gap: 0.75rem;
align-items: flex-end;
}
.input-wrapper {
flex: 1;
position: relative;
}
.chat-input {
width: 100%;
min-height: 2.5rem;
max-height: 6rem;
padding: 0.75rem 1rem;
border: 2px solid #e5e7eb;
border-radius: 0.75rem;
font-size: 1rem;
resize: none;
outline: none;
transition: border-color 0.2s ease;
font-family: inherit;
}
.chat-input:focus {
border-color: #8b5cf6;
}
.send-btn {
width: 2.5rem;
height: 2.5rem;
background: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
color: white;
border: none;
border-radius: 0.75rem;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.2s ease;
flex-shrink: 0;
}
.send-btn:hover {
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}
.send-btn:disabled {
opacity: 0.5;
cursor: not-allowed;
transform: none;
box-shadow: none;
}
.ai-features {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 1.5rem;
}
.feature-card {
background: white;
padding: 1.5rem;
border-radius: 0.75rem;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
text-align: center;
transition: transform 0.2s ease;
}
.feature-card:hover {
transform: translateY(-2px);
}
.feature-icon {
width: 3rem;
height: 3rem;
background: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
color: white;
border-radius: 0.75rem;
display: flex;
align-items: center;
justify-content: center;
margin: 0 auto 1rem;
font-size: 1.25rem;
}
.feature-card h3 {
margin-bottom: 0.5rem;
color: #1f2937;
font-size: 1.125rem;
}
.feature-card p {
color: #6b7280;
font-size: 0.875rem;
margin: 0;
}
@media (max-width: 768px) {
.dashboard-layout {
flex-direction: column;
}
.sidebar {
width: 100%;
height: auto;
order: 2;
}
.main-content {
order: 1;
}
.ai-content {
padding: 1rem;
}
.chat-container {
height: 500px;
}
.message {
max-width: 90%;
}
.ai-stats {
grid-template-columns: 1fr;
}
.ai-features {
grid-template-columns: 1fr;
}
}
</style>
</head>
<body>
<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 active">
<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">
<i class="fas fa-universal-access"></i>
<span>Accessibility</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">
<!-- Page Header -->
<header class="page-header">
<h1>AI Learning Assistant</h1>
<p>Get personalized help, explanations, and study guidance powered by artificial intelligence</p>
</header>
<!-- AI Content -->
<div class="ai-content">
<!-- AI Stats -->
<div class="ai-stats">
<div class="stat-card">
<div class="stat-icon">
<i class="fas fa-comments"></i>
</div>
<div class="stat-content">
<h3 id="total-conversations">24</h3>
<p>Total Conversations</p>
</div>
</div>
<div class="stat-card">
<div class="stat-icon">
<i class="fas fa-question-circle"></i>
</div>
<div class="stat-content">
<h3 id="questions-answered">156</h3>
<p>Questions Answered</p>
</div>
</div>
<div class="stat-card">
<div class="stat-icon">
<i class="fas fa-clock"></i>
</div>
<div class="stat-content">
<h3 id="response-time">< 2s</h3>
<p>Avg Response Time</p>
</div>
</div>
<div class="stat-card">
<div class="stat-icon">
<i class="fas fa-star"></i>
</div>
<div class="stat-content">
<h3 id="satisfaction">98%</h3>
<p>Satisfaction Rate</p>
</div>
</div>
</div>
<!-- Chat Interface -->
<div class="chat-container">
<!-- Chat Header -->
<div class="chat-header">
<div class="chat-avatar">
<i class="fas fa-robot"></i>
</div>
<div class="chat-info">
<h3>EduMorph AI Assistant</h3>
<p>Ready to help with your learning journey</p>
</div>
</div>
<!-- Chat Messages -->
<div class="chat-messages" id="chatMessages">
<div class="message ai">
<div class="message-avatar">
<i class="fas fa-robot"></i>
</div>
<div class="message-content">
<p>Hello! I'm your AI learning assistant. I can help you with:</p>
<ul style="margin: 0.5rem 0; padding-left: 1.25rem;">
<li>Explaining complex concepts</li>
<li>Creating personalized study plans</li>
<li>Answering questions about any subject</li>
<li>Providing learning resources and tips</li>
<li>Helping with homework and assignments</li>
</ul>
<p>What would you like to learn about today?</p>
<div class="message-time">Just now</div>
</div>
</div>
</div>
<!-- Quick Actions -->
<div class="quick-actions" id="quickActions">
<h4>Quick Actions</h4>
<div class="action-buttons">
<button class="action-btn" onclick="sendQuickMessage('Explain machine learning basics')">
<i class="fas fa-brain"></i>
ML Basics
</button>
<button class="action-btn" onclick="sendQuickMessage('Create a study plan for JavaScript')">
<i class="fas fa-calendar"></i>
Study Plan
</button>
<button class="action-btn" onclick="sendQuickMessage('Help me with calculus problems')">
<i class="fas fa-calculator"></i>
Math Help
</button>
<button class="action-btn" onclick="sendQuickMessage('Recommend programming courses')">
<i class="fas fa-code"></i>
Course Tips
</button>
<button class="action-btn" onclick="sendQuickMessage('Explain data structures')">
<i class="fas fa-sitemap"></i>
Data Structures
</button>
<button class="action-btn" onclick="sendQuickMessage('Study tips for better retention')">
<i class="fas fa-graduation-cap"></i>
Study Tips
</button>
</div>
</div>
<!-- Chat Input -->
<div class="chat-input-area">
<div class="input-container">
<div class="input-wrapper">
<textarea
id="messageInput"
class="chat-input"
placeholder="Ask me anything about your learning..."
rows="1"
></textarea>
</div>
<button id="sendButton" class="send-btn" onclick="sendMessage()">
<i class="fas fa-paper-plane"></i>
</button>
</div>
</div>
</div>
<!-- AI Features -->
<div class="ai-features">
<div class="feature-card">
<div class="feature-icon">
<i class="fas fa-lightbulb"></i>
</div>
<h3>Smart Explanations</h3>
<p>Get clear, easy-to-understand explanations for complex topics tailored to your learning level</p>
</div>
<div class="feature-card">
<div class="feature-icon">
<i class="fas fa-tasks"></i>
</div>
<h3>Personalized Plans</h3>
<p>Create custom study plans and learning paths based on your goals and available time</p>
</div>
<div class="feature-card">
<div class="feature-icon">
<i class="fas fa-question-circle"></i>
</div>
<h3>Instant Answers</h3>
<p>Get immediate responses to your questions 24/7 across all subjects and topics</p>
</div>
<div class="feature-card">
<div class="feature-icon">
<i class="fas fa-chart-line"></i>
</div>
<h3>Progress Tracking</h3>
<p>Monitor your learning progress and get insights on areas for improvement</p>
</div>
</div>
</div>
</main>
</div>
<script src="script.js"></script>
<script>
let messageCount = 0;
let isTyping = false;
// Initialize when page loads
document.addEventListener('DOMContentLoaded', function() {
checkAuth();
setupEventListeners();
autoResizeTextarea();
updateUserName();
});
// Check authentication
function checkAuth() {
const user = getFromStorage('edumorph_user');
if (!user) {
window.location.href = 'login.html';
return;
}
}
// Update user name in welcome message
function updateUserName() {
const user = getFromStorage('edumorph_user');
if (user && user.name) {
// You can customize this if needed
}
}
// Setup event listeners
function setupEventListeners() {
const messageInput = document.getElementById('messageInput');
const sendButton = document.getElementById('sendButton');
// Enter to send message
messageInput.addEventListener('keydown', function(e) {
if (e.key === 'Enter' && !e.shiftKey) {
e.preventDefault();
sendMessage();
}
});
// Auto-resize textarea
messageInput.addEventListener('input', autoResizeTextarea);
}
// Auto-resize textarea
function autoResizeTextarea() {
const textarea = document.getElementById('messageInput');
textarea.style.height = 'auto';
textarea.style.height = Math.min(textarea.scrollHeight, 96) + 'px';
}
// Send message
function sendMessage() {
const messageInput = document.getElementById('messageInput');
const message = messageInput.value.trim();
if (!message || isTyping) return;
// Add user message
addMessage(message, 'user');
messageInput.value = '';
autoResizeTextarea();
// Hide quick actions after first message
if (messageCount === 1) {
document.getElementById('quickActions').style.display = 'none';
}
// Show typing indicator
showTypingIndicator();
// Generate AI response
setTimeout(() => {
hideTypingIndicator();
const response = generateAIResponse(message);
addMessage(response, 'ai');
updateStats();
}, 1500 + Math.random() * 1000);
}
// Send quick message
function sendQuickMessage(message) {
const messageInput = document.getElementById('messageInput');
messageInput.value = message;
sendMessage();
}
// Add message to chat
function addMessage(content, sender) {
const messagesContainer = document.getElementById('chatMessages');
const messageDiv = document.createElement('div');
messageDiv.className = `message ${sender}`;
const user = getFromStorage('edumorph_user') || { name: 'User' };
const userInitial = user.name ? user.name.charAt(0).toUpperCase() : 'U';
messageDiv.innerHTML = `
<div class="message-avatar">
${sender === 'ai' ? '<i class="fas fa-robot"></i>' : userInitial}
</div>
<div class="message-content">
${formatMessage(content)}
<div class="message-time">${new Date().toLocaleTimeString()}</div>
</div>
`;
messagesContainer.appendChild(messageDiv);
messagesContainer.scrollTop = messagesContainer.scrollHeight;
messageCount++;
}
// Format message content
function formatMessage(content) {
// Convert line breaks to <br>
content = content.replace(/\n/g, '<br>');
// Convert **bold** to <strong>
content = content.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>');
// Convert *italic* to <em>
content = content.replace(/\*(.*?)\*/g, '<em>$1</em>');
return content;
}
// Show typing indicator
function showTypingIndicator() {
if (isTyping) return;
isTyping = true;
const messagesContainer = document.getElementById('chatMessages');
const typingDiv = document.createElement('div');
typingDiv.className = 'typing-indicator';
typingDiv.id = 'typingIndicator';
typingDiv.innerHTML = `
<div class="message-avatar">
<i class="fas fa-robot"></i>
</div>
<div class="typing-dots">
<div class="typing-dot"></div>
<div class="typing-dot"></div>
<div class="typing-dot"></div>
</div>
`;
messagesContainer.appendChild(typingDiv);
messagesContainer.scrollTop = messagesContainer.scrollHeight;
}
// Hide typing indicator
function hideTypingIndicator() {
isTyping = false;
const typingIndicator = document.getElementById('typingIndicator');
if (typingIndicator) {
typingIndicator.remove();
}
}
// Update stats
function updateStats() {
const conversations = document.getElementById('total-conversations');
const questions = document.getElementById('questions-answered');
if (conversations) {
const current = parseInt(conversations.textContent) || 24;
conversations.textContent = current + 1;
}
if (questions) {
const current = parseInt(questions.textContent) || 156;
questions.textContent = current + 1;
}
}
// Generate AI response
function generateAIResponse(userMessage) {
const message = userMessage.toLowerCase();
// Greeting responses
if (message.includes('hello') || message.includes('hi') || message.includes('hey')) {
return "Hello! I'm excited to help you learn today. What subject or topic would you like to explore?";
}
// JavaScript help
if (message.includes('javascript') || message.includes('js')) {
return "JavaScript is a fantastic language to learn! Here are the key areas to focus on:\n\n**Fundamentals:**\n• Variables (let, const, var)\n• Data types and operators\n• Functions and scope\n\n**DOM Manipulation:**\n• Selecting elements\n• Event handling\n• Modifying content\n\n**Modern Features:**\n• Arrow functions\n• Promises and async/await\n• ES6+ features\n\nWhat specific JavaScript topic would you like me to explain?";
}
// Python help
if (message.includes('python')) {
return "Python is perfect for beginners! Here's your learning roadmap:\n\n**Start Here:**\n• Basic syntax and variables\n• Data types (strings, numbers, lists)\n• Control flow (if/else, loops)\n\n**Next Steps:**\n• Functions and modules\n• File handling\n• Error handling\n\n**Advanced Topics:**\n• Object-oriented programming\n• Libraries (NumPy, Pandas)\n• Web frameworks (Django, Flask)\n\nWhich Python concept would you like help with?";
}
// Machine Learning
if (message.includes('machine learning') || message.includes('ml')) {
return "Machine Learning is an exciting field! Here's how to get started:\n\n**Prerequisites:**\n• Python programming\n• Basic statistics\n• Linear algebra basics\n\n**Core Concepts:**\n• Supervised vs Unsupervised learning\n• Training and testing data\n• Model evaluation\n\n**Popular Algorithms:**\n• Linear Regression\n• Decision Trees\n• Neural Networks\n\n**Tools to Learn:**\n• Scikit-learn\n• TensorFlow\n• Pandas for data manipulation\n\nWhat aspect of ML interests you most?";
}
// Study plans
if (message.includes('study plan') || message.includes('schedule')) {
return "I'd love to help you create an effective study plan! Here's my approach:\n\n**Step 1: Goal Setting**\n• What do you want to achieve?\n• By when do you want to achieve it?\n\n**Step 2: Time Assessment**\n• How many hours per week can you study?\n• What's your preferred study time?\n\n**Step 3: Break It Down**\n• Divide topics into manageable chunks\n• Set weekly milestones\n\n**Step 4: Stay Consistent**\n• 30-45 minutes daily beats long cramming sessions\n• Include regular review sessions\n\nWhat subject would you like to create a study plan for?";
}
// Math help
if (message.includes('math') || message.includes('mathematics') || message.includes('calculus') || message.includes('algebra')) {
return "Math can be challenging but very rewarding! Here's how I can help:\n\n**Problem-Solving Strategy:**\n• Break complex problems into steps\n• Identify what you know vs. what you need to find\n• Choose the right formula or method\n\n**Common Areas:**\n• **Algebra:** Equations, functions, graphing\n• **Calculus:** Limits, derivatives, integrals\n• **Statistics:** Probability, distributions\n• **Geometry:** Shapes, angles, proofs\n\nWhat specific math topic are you working on? I can walk you through problems step by step!";
}
// Data structures
if (message.includes('data structure')) {
return "Data structures are fundamental to programming! Here's what you should know:\n\n**Basic Structures:**\n• **Arrays:** Fixed-size collections\n• **Lists:** Dynamic collections\n• **Stacks:** Last-in, first-out (LIFO)\n• **Queues:** First-in, first-out (FIFO)\n\n**Advanced Structures:**\n• **Trees:** Hierarchical data\n• **Graphs:** Connected nodes\n• **Hash Tables:** Key-value pairs\n• **Heaps:** Priority-based structures\n\n**When to Use Each:**\n• Arrays for fixed data\n• Lists for dynamic data\n• Trees for hierarchical relationships\n• Graphs for network relationships\n\nWhich data structure would you like me to explain in detail?";
}
// Course recommendations
if (message.includes('course') || message.includes('recommend')) {
return "I'd be happy to recommend courses! Here are some popular learning paths:\n\n**Programming:**\n• JavaScript Fundamentals → React → Full-Stack Development\n• Python Basics → Data Science → Machine Learning\n\n**Design:**\n• HTML/CSS → UI/UX Design → Advanced Design Systems\n\n**Business:**\n• Digital Marketing → Analytics → Strategy\n\n**Data Science:**\n• Statistics → Python/R → Machine Learning → AI\n\nWhat field interests you most? I can provide a detailed learning path with specific course recommendations!";
}
// Study tips
if (message.includes('study tips') || message.includes('retention')) {
return "Here are proven study techniques for better retention:\n\n**Active Learning:**\n• **Spaced Repetition:** Review material at increasing intervals\n• **Active Recall:** Test yourself without looking at notes\n• **Feynman Technique:** Explain concepts in simple terms\n\n**Environment & Habits:**\n• Find a quiet, dedicated study space\n• Use the Pomodoro Technique (25 min study, 5 min break)\n• Eliminate distractions (phone, social media)\n\n**Memory Techniques:**\n• Create mind maps for visual learning\n• Use mnemonics for memorization\n• Connect new info to existing knowledge\n\n**Health & Wellness:**\n• Get adequate sleep (7-9 hours)\n• Exercise regularly for better brain function\n• Stay hydrated and eat brain-healthy foods\n\nWhich study technique would you like me to explain further?";
}
// General help
if (message.includes('help') || message.includes('stuck') || message.includes('confused')) {
return "I'm here to help you overcome any learning challenge! When you're stuck, try this approach:\n\n**1. Identify the Problem**\n• What specifically is confusing?\n• Where did you get stuck?\n\n**2. Break It Down**\n• Can you solve a simpler version?\n• What parts do you understand?\n\n**3. Find Patterns**\n• Have you seen similar problems?\n• What strategies worked before?\n\n**4. Ask Specific Questions**\n• The more specific, the better I can help!\n\nWhat particular topic or problem would you like me to help you with?";
}
// Thank you responses
if (message.includes('thank') || message.includes('thanks')) {
return "You're very welcome! I'm always here to support your learning journey. Remember, every expert was once a beginner, and asking questions is how we grow. Keep up the great work! 🌟\n\nIs there anything else you'd like to learn about?";
}
// Default response
return "That's an interesting question! I'm here to help you learn and grow. I can assist with:\n\n• **Programming** (JavaScript, Python, etc.)\n• **Mathematics** and problem-solving\n• **Study strategies** and time management\n• **Course recommendations** for your goals\n• **Concept explanations** in simple terms\n\nCould you tell me more about what you'd like to learn? The more specific you are, the better I can help you!";
}
// Logout function
function logout() {
localStorage.removeItem('edumorph_user');
localStorage.removeItem('edumorph_session');
window.location.href = 'index.html';
}
// Utility functions
function getFromStorage(key) {
try {
const data = localStorage.getItem(key);
return data ? JSON.parse(data) : null;
} catch (error) {
console.error('Error reading from storage:', error);
return null;
}
}
</script>
</body>
</html>