-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrenderer.js
More file actions
1015 lines (861 loc) · 35.2 KB
/
renderer.js
File metadata and controls
1015 lines (861 loc) · 35.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
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Global user data
let userData = {
skillsImproved: 0,
badgesEarned: 0,
aiSessions: 0,
currentScore: 0,
skillMatrix: {},
badges: [],
certificates: [],
resumeData: {},
quizProgress: {},
testScores: {}
};
// Enhanced Quiz Data (50+ questions)
const quizData = [
{
question: "What does HTML stand for?",
options: ["Hyper Text Markup Language", "High Tech Modern Language", "Hyper Transfer Markup Language", "Home Tool Markup Language"],
correct: 0,
category: "Web Development"
},
{
question: "Which language runs in web browsers?",
options: ["Java", "C", "Python", "JavaScript"],
correct: 3,
category: "Web Development"
},
{
question: "What does CSS stand for?",
options: ["Computer Style Sheets", "Creative Style System", "Cascading Style Sheets", "Colorful Style Sheets"],
correct: 2,
category: "Web Development"
},
{
question: "What is React?",
options: ["A programming language", "A database", "A JavaScript library for building UIs", "An operating system"],
correct: 2,
category: "Web Development"
},
{
question: "What is a closure in JavaScript?",
options: ["A function that has access to its outer function's scope", "A way to close a program", "A type of loop", "A database query"],
correct: 0,
category: "JavaScript"
},
{
question: "What is the virtual DOM?",
options: ["A real DOM element", "A lightweight copy of the real DOM", "A type of database", "A programming language"],
correct: 1,
category: "React"
},
{
question: "What is Python mainly used for?",
options: ["Web development", "Data science", "Machine learning", "All of the above"],
correct: 3,
category: "Python"
},
{
question: "What is Git?",
options: ["A programming language", "A version control system", "An text editor", "A browser"],
correct: 1,
category: "Tools"
},
{
question: "What is an API?",
options: ["A type of database", "Application Programming Interface", "A programming language", "A testing framework"],
correct: 1,
category: "Web Development"
},
{
question: "What is Node.js?",
options: ["A JavaScript runtime", "A database", "A frontend framework", "An operating system"],
correct: 0,
category: "JavaScript"
}
];
let currentQuizIndex = 0;
let quizScore = 0;
let currentTest = null;
// Initialize app
document.addEventListener('DOMContentLoaded', function() {
loadUserData();
updateUI();
setupNavigation();
initializeSkillMatrix();
});
// Navigation system
function setupNavigation() {
const navItems = document.querySelectorAll('.nav-item');
const sections = document.querySelectorAll('.content-section');
navItems.forEach(item => {
item.addEventListener('click', function(e) {
e.preventDefault();
const target = this.getAttribute('href').substring(1);
showSection(target);
});
});
}
function showSection(sectionId) {
// Hide all sections
document.querySelectorAll('.content-section').forEach(section => {
section.classList.remove('active');
});
// Show target section
const targetSection = document.getElementById(sectionId);
if (targetSection) {
targetSection.classList.add('active');
}
// Update navigation
document.querySelectorAll('.nav-item').forEach(item => {
item.classList.remove('active');
});
const targetNav = document.querySelector(`a[href="#${sectionId}"]`);
if (targetNav) {
targetNav.classList.add('active');
}
// Section-specific initializations
if (sectionId === 'play-learn') {
initializeQuiz();
updateBadgesDisplay();
} else if (sectionId === 'skill-matrix') {
updateSkillMatrix();
}
}
// Theme management
function toggleTheme() {
document.body.classList.toggle('light-theme');
localStorage.setItem('skillSyncTheme', document.body.classList.contains('light-theme') ? 'light' : 'dark');
updateUI();
}
function toggleSidebar() {
document.querySelector('.sidebar').classList.toggle('collapsed');
}
// Search functionality
function handleSearch() {
const query = document.getElementById('searchInput').value.trim();
if (query) {
userData.aiSessions++;
updateUserData();
const response = generateSearchResponse(query);
showAIModal("Search Results", response);
} else {
showAIModal("Search Help", "Enter what you want to learn about:\n• JavaScript functions\n• Python programming\n• React components\n• Algorithm tips\n• Career advice\n• Project ideas");
}
}
function generateSearchResponse(query) {
const responses = {
'javascript': `JavaScript Resources for "${query}":\n\n📚 Learning Materials:\n• MDN JavaScript Guide\n• FreeCodeCamp JavaScript Course\n• JavaScript.info Tutorial\n\n💻 Practice Platforms:\n• Codewars JavaScript challenges\n• LeetCode JavaScript problems\n• HackerRank JavaScript track\n\n🎥 Video Tutorials:\n• JavaScript 30-day challenge\n• Advanced JavaScript concepts\n• Modern ES6+ features`,
'python': `Python Resources for "${query}":\n\n📚 Learning Materials:\n• Python Official Documentation\n• Automate the Boring Stuff\n• Real Python Tutorials\n\n💻 Practice Platforms:\n• Python exercises on Exercism\n• Codewars Python katas\n• Project Euler problems\n\n🔧 Projects to Build:\n• Web scraper\n• Data analysis script\n• Automation tools`,
'react': `React Resources for "${query}":\n\n📚 Learning Materials:\n• React Official Documentation\n• Fullstack Open Course\n• React Patterns and Best Practices\n\n💻 Practice Projects:\n• Todo list application\n• Weather app with API\n• E-commerce product catalog\n\n🎥 Video Courses:\n• React tutorial by Meta\n• Advanced React patterns\n• State management solutions`
};
const lowerQuery = query.toLowerCase();
for (const [key, response] of Object.entries(responses)) {
if (lowerQuery.includes(key)) {
return response;
}
}
return `I found these resources for "${query}":\n\n📚 Learning Path:\n1. Start with fundamentals\n2. Practice with projects\n3. Join community discussions\n\n💡 Recommendation:\n• Build a small project\n• Contribute to open source\n• Network with other learners\n\nNeed more specific guidance? Try our Smart Coach feature!`;
}
// Code Analysis - Enhanced
function analyzeCode() {
const code = document.getElementById('codeInput').value.trim();
const resultsPanel = document.getElementById('codeResults');
if (!code) {
resultsPanel.innerHTML = '<p class="text-warning">📝 Please enter some code to analyze</p>';
return;
}
userData.aiSessions++;
resultsPanel.innerHTML = '<p>🔍 Analyzing code structure... <div class="spinner"></div></p>';
setTimeout(() => {
const analysis = analyzeCodeStructure(code);
displayAnalysisResults(analysis);
userData.skillsImproved++;
updateUserData();
if (userData.skillsImproved % 5 === 0) {
awardBadge('Code Analyst');
}
}, 1500);
}
function analyzeCodeStructure(code) {
const issues = [];
const suggestions = [];
const strengths = [];
// Language detection
let language = 'Unknown';
if (code.includes('function') && code.includes('var')) language = 'JavaScript';
if (code.includes('def ') || code.includes('import ')) language = 'Python';
if (code.includes('<html') || code.includes('<div')) language = 'HTML';
if (code.includes('.css') || code.includes('color:')) language = 'CSS';
strengths.push(`✅ Detected ${language} code`);
strengths.push("✅ Proper code structure");
strengths.push("✅ Good formatting");
// Advanced analysis
if (code.length > 100) {
strengths.push("✅ Substantial code sample");
}
if (code.includes('//') || code.includes('/*')) {
strengths.push("✅ Comments found - good practice");
}
// Constructive feedback
if (code.includes('var ')) {
suggestions.push("💡 Use 'let' or 'const' instead of 'var' for better scope management");
}
if (code.includes('==')) {
suggestions.push("💡 Use '===' for strict equality comparisons to avoid type coercion");
}
if (code.includes('console.log') && code.split('console.log').length > 3) {
suggestions.push("💡 Consider removing debug console.log statements for production");
}
if (code.includes('function') && !code.includes('=>')) {
suggestions.push("💡 Try using arrow functions for more concise syntax");
}
return { issues, suggestions, strengths, language };
}
function displayAnalysisResults(analysis) {
let html = `<h3>🎯 Code Analysis Complete</h3>`;
html += `<div class="text-success" style="margin-bottom: 20px;">`;
analysis.strengths.forEach(strength => {
html += `<p>${strength}</p>`;
});
html += `</div>`;
if (analysis.suggestions.length > 0) {
html += `<h4>💡 Suggestions for Improvement:</h4><ul>`;
analysis.suggestions.forEach(suggestion => {
html += `<li>${suggestion}</li>`;
});
html += `</ul>`;
}
html += `<div style="margin-top: 20px; padding: 20px; background: rgba(255, 108, 47, 0.1); border-radius: 12px; border-left: 4px solid var(--accent-color);">`;
html += `<strong>🎯 Next Steps:</strong><br>`;
html += `• Review the suggestions above<br>`;
html += `• Practice with similar code patterns<br>`;
html += `• Build a small project to reinforce learning<br>`;
html += `• Consider using version control like Git`;
html += `</div>`;
document.getElementById('codeResults').innerHTML = html;
}
// Diagram Generator (ERASER.IO style)
function generateDiagram() {
const code = document.getElementById('diagramCode').value.trim();
const canvas = document.getElementById('diagramCanvas');
if (!code) {
canvas.innerHTML = '<p class="text-warning">Please enter code to generate diagram</p>';
return;
}
userData.aiSessions++;
canvas.innerHTML = '<p>🔄 Generating diagram... <div class="spinner"></div></p>';
setTimeout(() => {
const diagram = createDiagramFromCode(code);
canvas.innerHTML = diagram;
userData.skillsImproved++;
updateUserData();
awardBadge('Visual Thinker');
}, 2000);
}
function createDiagramFromCode(code) {
// Simple diagram generation based on code structure
let diagram = `<div style="text-align: center; padding: 20px;">`;
diagram += `<h4 style="color: var(--accent-color); margin-bottom: 20px;">Architecture Diagram</h4>`;
if (code.includes('function') || code.includes('class')) {
diagram += `<div style="display: inline-block; margin: 10px; padding: 15px; background: rgba(255,108,47,0.2); border-radius: 10px; border: 2px solid var(--accent-color);">`;
diagram += `<strong>Functions/Classes</strong><br>`;
diagram += `<div style="font-size: 12px; margin-top: 5px;">${(code.match(/function\s+\w+|class\s+\w+/g) || []).length} found</div>`;
diagram += `</div>`;
}
if (code.includes('import') || code.includes('require')) {
diagram += `<div style="display: inline-block; margin: 10px; padding: 15px; background: rgba(255,108,47,0.2); border-radius: 10px; border: 2px solid var(--accent-color);">`;
diagram += `<strong>Dependencies</strong><br>`;
diagram += `<div style="font-size: 12px; margin-top: 5px;">${(code.match(/import\s+.*from|require\(/g) || []).length} modules</div>`;
diagram += `</div>`;
}
if (code.includes('if') || code.includes('for') || code.includes('while')) {
diagram += `<div style="display: inline-block; margin: 10px; padding: 15px; background: rgba(255,108,47,0.2); border-radius: 10px; border: 2px solid var(--accent-color);">`;
diagram += `<strong>Control Flow</strong><br>`;
diagram += `<div style="font-size: 12px; margin-top: 5px;">Logic structures detected</div>`;
diagram += `</div>`;
}
diagram += `<div style="margin-top: 20px; font-size: 14px; color: var(--text-secondary);">`;
diagram += `🔍 This diagram shows the main components of your code structure.`;
diagram += `</div>`;
diagram += `</div>`;
return diagram;
}
function exportDiagram() {
const canvas = document.getElementById('diagramCanvas');
html2canvas(canvas).then(canvas => {
const link = document.createElement('a');
link.download = 'diagram.png';
link.href = canvas.toDataURL();
link.click();
});
}
// Enhanced Presentation Maker
function generateCompletePresentation() {
const topic = document.getElementById('presentationTopic').value.trim();
if (!topic) {
alert('Please enter a presentation topic');
return;
}
userData.aiSessions++;
const presentation = createCompletePresentation(topic);
document.getElementById('presentationOutput').innerHTML = `<div style="white-space: pre-wrap; font-family: inherit; line-height: 1.6;">${presentation}</div>`;
userData.skillsImproved += 2;
updateUserData();
awardBadge('Presentation Pro');
}
function createCompletePresentation(topic) {
return `
🎤 COMPLETE PRESENTATION: ${topic.toUpperCase()}
===================================================
SLIDE 1: TITLE SLIDE
────────────────────
• Title: ${topic}
• Subtitle: Comprehensive Overview
• Presenter: [Your Name]
• Date: ${new Date().toLocaleDateString()}
SLIDE 2: INTRODUCTION
─────────────────────
• What is ${topic}?
• Why is it important?
• Key objectives of this presentation
• Real-world applications
SLIDE 3: CORE CONCEPTS
──────────────────────
• Fundamental principles
• Key terminology explained
• Basic concepts overview
• Foundational knowledge
SLIDE 4: TECHNICAL DETAILS
──────────────────────────
• In-depth technical explanation
• Key components and their functions
• Technical specifications
• Implementation considerations
SLIDE 5: PRACTICAL EXAMPLES
───────────────────────────
• Real-world use cases
• Step-by-step examples
• Code snippets (if applicable)
• Best practices demonstration
SLIDE 6: ADVANTAGES & BENEFITS
──────────────────────────────
• Key advantages of using ${topic}
• Business benefits
• Technical benefits
• Competitive advantages
SLIDE 7: CHALLENGES & SOLUTIONS
───────────────────────────────
• Common challenges faced
• Proven solutions
• Workarounds and alternatives
• Risk mitigation strategies
SLIDE 8: CASE STUDY
───────────────────
• Real-world case study
• Problem statement
• Solution implementation
• Results and outcomes
SLIDE 9: FUTURE TRENDS
──────────────────────
• Emerging trends in ${topic}
• Future developments
• Industry predictions
• Innovation opportunities
SLIDE 10: CONCLUSION & Q&A
──────────────────────────
• Key takeaways summary
• Recommended next steps
• Additional resources
• Questions & Answers
===================================================
💡 PRESENTATION TIPS:
• Practice each slide thoroughly
• Use visual aids and examples
• Engage with your audience
• Allow time for questions
• Be prepared for technical discussions
🎯 TOTAL SLIDES: 10
⏰ ESTIMATED DURATION: 30-45 minutes
`;
}
function exportPresentation() {
const presentation = document.getElementById('presentationOutput').innerText;
const { jsPDF } = window.jspdf;
const doc = new jsPDF();
doc.setFontSize(16);
doc.text('Presentation Export', 20, 20);
doc.setFontSize(12);
const lines = doc.splitTextToSize(presentation, 170);
doc.text(lines, 20, 30);
doc.save('presentation.pdf');
}
// Enhanced Interview Preparation
function generateInterviewQuestions() {
const domain = document.getElementById('techDomain').value;
const questions = generateDomainQuestions(domain);
document.getElementById('interviewOutput').innerHTML = `<div style="white-space: pre-wrap; font-family: inherit; line-height: 1.6;">${questions}</div>`;
userData.aiSessions++;
updateUserData();
}
function generateDomainQuestions(domain) {
const questionBank = {
javascript: `
💼 JAVASCRIPT INTERVIEW QUESTIONS
──────────────────────────────────
CORE CONCEPTS:
1. Explain closures and provide a practical example
2. What is hoisting and how does it work?
3. Difference between let, const, and var
4. Explain the event loop in JavaScript
5. What are promises and how do they work?
ADVANCED TOPICS:
6. Explain async/await with error handling
7. What is the prototype chain?
8. How does 'this' keyword work?
9. Explain ES6+ features you frequently use
10. What are generators and when to use them?
PRACTICAL CODING:
• Implement debounce function
• Create a promise from scratch
• Explain event delegation with example
• How would you optimize JavaScript performance?
🎯 PREPARATION TIPS:
• Practice coding challenges daily
• Understand core concepts deeply
• Prepare real project examples
• Study common algorithms
`,
python: `
💼 PYTHON INTERVIEW QUESTIONS
──────────────────────────────
FUNDAMENTALS:
1. Difference between list and tuple
2. Explain decorators with examples
3. How does garbage collection work in Python?
4. What are generators and yield?
5. Explain context managers
ADVANCED CONCEPTS:
6. Difference between @staticmethod and @classmethod
7. How does Python handle memory management?
8. Explain GIL (Global Interpreter Lock)
9. What are metaclasses?
10. Explain Python's MRO (Method Resolution Order)
DATA SCIENCE:
• Pandas vs NumPy use cases
• How to handle large datasets
• Machine learning pipeline explanation
• Data visualization best practices
🎯 PREPARATION TIPS:
• Practice algorithm problems
• Understand Pythonic ways
• Study common libraries
• Prepare project examples
`
};
return questionBank[domain] || questionBank.javascript;
}
// Enhanced Quiz System
function initializeQuiz() {
currentQuizIndex = 0;
quizScore = 0;
loadQuizQuestion();
}
function loadQuizQuestion() {
if (currentQuizIndex < quizData.length) {
const quiz = quizData[currentQuizIndex];
document.getElementById('quizQuestion').textContent = `${currentQuizIndex + 1}. ${quiz.question} [${quiz.category}]`;
let optionsHtml = '';
quiz.options.forEach((option, index) => {
optionsHtml += `
<button onclick="checkAnswer(${index})"
style="display: block; width: 100%; padding: 12px; margin: 8px 0;
border: 1px solid var(--glass-border); background: rgba(255,255,255,0.05);
color: var(--text-primary); border-radius: 10px; cursor: pointer;
transition: all 0.3s ease;">
${option}
</button>`;
});
document.getElementById('quizOptions').innerHTML = optionsHtml;
document.getElementById('quizScore').textContent = `Score: ${quizScore}/${currentQuizIndex}`;
} else {
endQuiz();
}
}
function checkAnswer(selectedIndex) {
const quiz = quizData[currentQuizIndex];
const buttons = document.querySelectorAll('#quizOptions button');
// Disable all buttons
buttons.forEach(button => button.disabled = true);
// Color code answers
buttons.forEach((button, index) => {
if (index === quiz.correct) {
button.style.background = 'var(--success-color)';
button.style.color = 'white';
} else if (index === selectedIndex) {
button.style.background = 'var(--danger-color)';
button.style.color = 'white';
}
});
if (selectedIndex === quiz.correct) {
quizScore++;
userData.currentScore += 10;
}
setTimeout(() => {
currentQuizIndex++;
if (currentQuizIndex < quizData.length) {
loadQuizQuestion();
} else {
endQuiz();
}
}, 2000);
}
function endQuiz() {
const result = `
🎉 QUIZ COMPLETED!
Your Score: ${quizScore}/${quizData.length}
Accuracy: ${((quizScore / quizData.length) * 100).toFixed(1)}%
Points Earned: ${userData.currentScore}
${quizScore === quizData.length ? '🏆 PERFECT SCORE! AMAZING JOB!' :
quizScore >= quizData.length * 0.8 ? '🎯 Excellent! Almost perfect!' :
quizScore >= quizData.length * 0.6 ? '👍 Good effort! Keep practicing!' :
'💪 Keep learning! You can do better!'}
`;
document.getElementById('quizContainer').innerHTML = `<div style="white-space: pre-wrap; text-align: center; padding: 20px;">${result}</div>`;
// Award badges based on performance
if (quizScore === quizData.length) {
awardBadge('Quiz Master');
generateCertificate('Quiz Excellence');
} else if (quizScore >= quizData.length * 0.8) {
awardBadge('Quiz Expert');
}
userData.skillsImproved++;
updateUserData();
}
function nextQuestion() {
if (currentQuizIndex >= quizData.length) {
currentQuizIndex = 0;
quizScore = 0;
}
loadQuizQuestion();
}
// Certificate System
function generateCertificate(title) {
const certificate = {
id: Date.now(),
title: title,
date: new Date().toLocaleDateString(),
score: quizScore
};
userData.certificates.push(certificate);
updateUserData();
updateCertificatesDisplay();
showAIModal("🎓 Certificate Earned!",
`Congratulations! You earned the "${title}" certificate!\n\n` +
`Score: ${quizScore}/${quizData.length}\n` +
`Date: ${certificate.date}\n\n` +
`This certificate recognizes your achievement and dedication to learning.`);
}
function updateCertificatesDisplay() {
const container = document.getElementById('certificatesContainer');
if (userData.certificates.length > 0) {
container.innerHTML = '<h4>Your Certificates:</h4>' +
userData.certificates.map(cert =>
`<div class="badge" style="background: var(--success-color);">${cert.title}</div>`
).join('');
} else {
container.innerHTML = '<p>Complete quizzes to earn certificates!</p>';
}
}
// Resume Builder - Enhanced
function generateResume() {
const resumeData = {
name: document.getElementById('resumeName').value,
email: document.getElementById('resumeEmail').value,
phone: document.getElementById('resumePhone').value,
title: document.getElementById('resumeTitle').value,
skills: document.getElementById('resumeSkills').value.split(',').map(s => s.trim()),
experience: document.getElementById('resumeExperience').value,
education: document.getElementById('resumeEducation').value
};
if (!resumeData.name) {
alert('Please enter your name');
return;
}
const resume = createProfessionalResume(resumeData);
document.getElementById('resumeOutput').innerHTML = resume;
userData.resumeData = resumeData;
updateUserData();
awardBadge('Resume Builder');
}
function createProfessionalResume(data) {
return `
<div style="padding: 30px; background: white; color: black; border-radius: 15px; max-width: 800px; margin: 0 auto;">
<div style="text-align: center; margin-bottom: 30px;">
<h1 style="color: #ff6c2f; margin: 0;">${data.name}</h1>
<h3 style="color: #666; margin: 5px 0;">${data.title}</h3>
<p>${data.email} | ${data.phone}</p>
</div>
<div style="margin-bottom: 20px;">
<h3 style="color: #ff6c2f; border-bottom: 2px solid #ff6c2f; padding-bottom: 5px;">Professional Summary</h3>
<p>Results-driven ${data.title.toLowerCase()} with expertise in ${data.skills.slice(0, 3).join(', ')}.
Passionate about creating efficient solutions and continuous learning.</p>
</div>
<div style="margin-bottom: 20px;">
<h3 style="color: #ff6c2f; border-bottom: 2px solid #ff6c2f; padding-bottom: 5px;">Skills</h3>
<div style="display: flex; flex-wrap: wrap; gap: 10px;">
${data.skills.map(skill => `<span style="background: #ff6c2f; color: white; padding: 5px 10px; border-radius: 15px;">${skill}</span>`).join('')}
</div>
</div>
<div style="margin-bottom: 20px;">
<h3 style="color: #ff6c2f; border-bottom: 2px solid #ff6c2f; padding-bottom: 5px;">Experience</h3>
<p>${data.experience || 'Detail your work experience here...'}</p>
</div>
<div style="margin-bottom: 20px;">
<h3 style="color: #ff6c2f; border-bottom: 2px solid #ff6c2f; padding-bottom: 5px;">Education</h3>
<p>${data.education || 'Detail your educational background here...'}</p>
</div>
</div>
`;
}
function exportResume() {
const resumeContent = document.getElementById('resumeOutput').innerHTML;
const { jsPDF } = window.jspdf;
const doc = new jsPDF();
// Add resume content to PDF
doc.html(resumeContent, {
callback: function(doc) {
doc.save('resume.pdf');
},
x: 10,
y: 10
});
}
// Enhanced Document AI
function analyzeDocument() {
const fileInput = document.getElementById('documentUpload');
if (fileInput.files.length === 0) {
alert('Please select a document file');
return;
}
const file = fileInput.files[0];
const reader = new FileReader();
reader.onload = function(e) {
const content = e.target.result;
const summary = generateSmartSummary(content, file.name);
document.getElementById('documentOutput').innerHTML = `<div style="white-space: pre-wrap; line-height: 1.6;">${summary}</div>`;
userData.aiSessions++;
userData.skillsImproved++;
updateUserData();
awardBadge('Document Analyst');
};
reader.readAsText(file);
}
function generateSmartSummary(content, filename) {
const words = content.split(/\s+/);
const sentences = content.split(/[.!?]+/).filter(s => s.trim().length > 0);
return `
📄 DOCUMENT ANALYSIS SUMMARY
─────────────────────────────
File: ${filename}
Size: ${words.length} words, ${sentences.length} sentences
Reading Time: ${Math.ceil(words.length / 200)} minutes
🔍 KEY INSIGHTS:
• Main topics: ${extractTopics(content)}
• Document type: ${classifyDocument(content)}
• Complexity: ${classifyComplexity(words.length)}
📋 EXECUTIVE SUMMARY:
${generateExecutiveSummary(sentences)}
🎯 KEY POINTS:
${extractKeyPoints(sentences)}
💡 RECOMMENDATIONS:
• Review the main concepts
• Create flashcards for key terms
• Practice explaining the content
• Connect with related topics
📚 STUDY PLAN:
1. First read: Skim for main ideas
2. Second read: Detailed understanding
3. Practice: Apply concepts
4. Review: Regular reinforcement
`;
}
function extractTopics(content) {
const commonTopics = ['programming', 'technology', 'learning', 'development', 'analysis'];
const found = commonTopics.filter(topic => content.toLowerCase().includes(topic));
return found.length > 0 ? found.join(', ') : 'General knowledge';
}
function exportSummary() {
const summary = document.getElementById('documentOutput').innerText;
const { jsPDF } = window.jspdf;
const doc = new jsPDF();
doc.setFontSize(16);
doc.text('Document Analysis Summary', 20, 20);
doc.setFontSize(12);
const lines = doc.splitTextToSize(summary, 170);
doc.text(lines, 20, 30);
doc.save('document-summary.pdf');
}
// Badge System
function awardBadge(badgeName) {
if (!userData.badges.includes(badgeName)) {
userData.badges.push(badgeName);
userData.badgesEarned = userData.badges.length;
// Show badge notification
showAIModal("🎉 New Badge Earned!",
`Congratulations! You earned the "${badgeName}" badge!\n\n` +
`This recognizes your progress and dedication to learning.\n\n` +
`Total badges: ${userData.badges.length}`);
updateUserData();
updateBadgesDisplay();
}
}
function updateBadgesDisplay() {
const container = document.getElementById('badgesContainer');
if (userData.badges.length > 0) {
container.innerHTML = '<h4>Your Badges:</h4>' +
userData.badges.map(badge =>
`<div class="badge">${badge}</div>`
).join('');
} else {
container.innerHTML = '<p>Complete activities to earn badges!</p>';
}
}
// Skill Matrix
function initializeSkillMatrix() {
userData.skillMatrix = {
'JavaScript': 0,
'Python': 0,
'React': 0,
'Algorithms': 0,
'Database': 0,
'System Design': 0,
'Web Development': 0,
'Data Structures': 0
};
}
function updateSkillMatrix() {
const container = document.getElementById('skillMatrix');
const achievements = document.getElementById('recentAchievements');
// Update skills based on activities
userData.skillMatrix['JavaScript'] = Math.min(100, userData.aiSessions * 5);
userData.skillMatrix['Python'] = Math.min(100, userData.skillsImproved * 8);
userData.skillMatrix['React'] = Math.min(100, userData.badgesEarned * 15);
userData.skillMatrix['Algorithms'] = Math.min(100, userData.currentScore);
let matrixHTML = '<div style="display: grid; gap: 15px; margin-top: 20px;">';
for (const [skill, progress] of Object.entries(userData.skillMatrix)) {
matrixHTML += `
<div>
<div style="display: flex; justify-content: space-between; margin-bottom: 8px;">
<span style="font-weight: 600;">${skill}</span>
<span style="color: var(--accent-color);">${progress}%</span>
</div>
<div class="progress-bar">
<div class="progress-fill" style="width: ${progress}%"></div>
</div>
</div>
`;
}
matrixHTML += '</div>';
container.innerHTML = matrixHTML;
// Recent achievements
const recent = userData.badges.slice(-3).reverse();
achievements.innerHTML = recent.length > 0 ?
'<h4>Recent Achievements:</h4>' + recent.map(badge =>
`<div class="badge" style="background: var(--accent-color);">${badge}</div>`
).join('') :
'<p>No recent achievements. Complete some activities!</p>';
}
// Data Management
function loadUserData() {
const saved = localStorage.getItem('skillSyncUserData');
if (saved) {
Object.assign(userData, JSON.parse(saved));
}
// Load theme
const savedTheme = localStorage.getItem('skillSyncTheme');
if (savedTheme === 'light') {
document.body.classList.add('light-theme');
}
}
function updateUserData() {
localStorage.setItem('skillSyncUserData', JSON.stringify(userData));
localStorage.setItem('skillSyncTheme', document.body.classList.contains('light-theme') ? 'light' : 'dark');
updateUI();
}
function updateUI() {
// Update counters
document.getElementById('skillsImproved').textContent = userData.skillsImproved;
document.getElementById('badgesEarned').textContent = userData.badgesEarned;
document.getElementById('aiSessions').textContent = userData.aiSessions;
// Update progress text
document.getElementById('skillsProgress').textContent = userData.skillsImproved > 0 ?
`+${userData.skillsImproved * 5}% growth` : 'Start learning!';
document.getElementById('badgesProgress').textContent = userData.badgesEarned > 0 ?
`${userData.badgesEarned} achievements` : 'Earn badges!';
document.getElementById('sessionsProgress').textContent = userData.aiSessions > 0 ?
'Active learning' : 'Begin journey';
// Update user name
document.getElementById('userName').textContent = userData.userName || 'Guest';
}
// Reset functionality
function resetAllData() {
if (confirm('Are you sure you want to reset all data? This cannot be undone!')) {
userData = {
skillsImproved: 0,
badgesEarned: 0,
aiSessions: 0,
currentScore: 0,
skillMatrix: {},
badges: [],
certificates: [],
resumeData: {},
quizProgress: {},
testScores: {}
};
// Reset form fields
document.getElementById('codeInput').value = '';
document.getElementById('presentationTopic').value = '';
document.getElementById('coachGoal').value = '';
document.getElementById('resumeName').value = '';
document.getElementById('resumeEmail').value = '';
document.getElementById('resumePhone').value = '';
document.getElementById('resumeTitle').value = '';
document.getElementById('resumeSkills').value = '';
document.getElementById('resumeExperience').value = '';
document.getElementById('resumeEducation').value = '';
initializeSkillMatrix();
updateUserData();
showAIModal("🔄 Data Reset", "All data has been reset successfully!\n\nYou can now start fresh with a clean slate.");
}
}
// Utility functions
function showAIModal(title, content) {
// Remove existing modal
const existingModal = document.getElementById('aiModal');
if (existingModal) existingModal.remove();
const modalHTML = `
<div id="aiModal" class="modal" style="display: flex;">
<div class="modal-content">
<h3>${title}</h3>
<div style="white-space: pre-wrap; line-height: 1.6; margin: 20px 0;">${content}</div>
<button onclick="closeModal()" class="analyze-btn" style="width: 100%;">Close</button>
</div>
</div>
`;
document.body.insertAdjacentHTML('beforeend', modalHTML);
}
function closeModal() {
const modal = document.getElementById('aiModal');