-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
1179 lines (1026 loc) · 41.6 KB
/
Copy pathscript.js
File metadata and controls
1179 lines (1026 loc) · 41.6 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
// Analog Tech Portfolio - Interactive JavaScript
class PortfolioController {
constructor() {
this.oscilloscopeCanvas = null;
this.oscilloscopeCtx = null;
this.animationFrame = null;
this.waveOffset = 0;
this.projects = [];
this.circuitBackground = null;
this.typewriterHasRun = false; // Flag to track if typewriter effect has run
this.init();
}
init() {
this.setupCircuitBackground();
this.setupProjectNavigation();
this.setupSkillBars();
this.setupOscilloscope();
this.setupAmbientEffects();
this.setupResponsiveHandling();
this.setupScrollAnimations();
this.setupBackButtonHandling();
// Initialize animations - typewriter effect will be triggered after content loads
// this.typewriterEffect();
// this.typewriterHasRun = true;
}
setupCircuitBackground() {
// Initialize the animated circuit background
if (window.CircuitBackground) {
this.circuitBackground = new CircuitBackground('circuit-canvas');
}
}
setupProjectNavigation() {
// Set up project card click handlers
document.addEventListener('click', (e) => {
// Real links inside cards navigate — don't hijack them into the modal
if (e.target.closest('a')) return;
// Handle regular project card clicks (thumbnail included — the whole
// card, hero image and all, opens the project page)
const projectCard = e.target.closest('.project-card');
if (projectCard) {
const projectId = projectCard.dataset.projectId;
if (projectId && projectId !== 'undefined') {
// Add mobile hover class for animation on mobile devices
projectCard.classList.add('mobile-hover');
// Keep hover animation for a moment, then open modal
setTimeout(() => {
this.navigateToProject(projectId);
// Keep hover class active until modal is closed
}, 250); // Delay to let animation play fully
}
}
});
}
openThumbnailImage(projectId) {
// Get project data and open just the hero/thumbnail image in fullscreen
if (window.PortfolioXMLParser) {
const parser = new window.PortfolioXMLParser();
parser.loadPortfolioData('portfolio-template/portfolio-data.xml')
.then(() => {
const projectData = parser.getProjectDetails(projectId);
if (projectData && projectData.images && projectData.images.length > 0) {
// Find the best image to show (hero > featured > first available)
const heroImage = projectData.images.find(img => img.rank === 'hero');
const featuredImage = projectData.images.find(img => img.rank === 'featured');
const imageToShow = heroImage || featuredImage || projectData.images[0];
this.openFullscreenImage(imageToShow.src, imageToShow.description || projectData.title);
}
})
.catch(error => {
console.error('Error loading project data for thumbnail:', error);
});
}
}
navigateToProject(projectId) {
// Always show project details as modal overlay for embeddable component
this.showProjectDetails(projectId);
}
showProjectDetails(projectId) {
// Get project data from XML parser if available
if (window.PortfolioXMLParser) {
// Create a temporary parser instance to get project data
const parser = new window.PortfolioXMLParser();
parser.loadPortfolioData('portfolio-template/portfolio-data.xml')
.then(() => {
const projectData = parser.getProjectDetails(projectId);
if (projectData) {
this.renderInlineProjectDetails(projectData);
} else {
this.showProjectNotFoundError(projectId);
}
})
.catch(error => {
console.error('Error loading project data:', error);
this.showProjectNotFoundError(projectId);
});
} else {
this.showProjectNotFoundError(projectId);
}
}
showProjectNotFoundError(projectId) {
// Create a simple error overlay
let overlay = document.getElementById('project-detail-overlay');
if (!overlay) {
overlay = this.createProjectDetailOverlay();
}
overlay.querySelector('.project-detail-title').textContent = 'Project Not Found';
overlay.querySelector('.project-detail-subtitle').textContent = `Project ID: ${projectId}`;
overlay.querySelector('.project-detail-content').innerHTML = `
<div class="project-detail-section">
<p style="color: var(--medium-gray-text);">
The requested project could not be loaded. This might be due to:
</p>
<ul style="color: var(--medium-gray-text); margin-left: 20px;">
<li>Invalid project ID</li>
<li>Missing project data</li>
<li>Network connectivity issues</li>
</ul>
<p style="color: var(--cathode-cyan); margin-top: 20px;">
Please try again or return to the main portfolio.
</p>
</div>
`;
overlay.style.display = 'flex';
document.body.style.overflow = 'hidden';
}
renderInlineProjectDetails(project) {
// Create or get project detail overlay
let overlay = document.getElementById('project-detail-overlay');
if (!overlay) {
overlay = this.createProjectDetailOverlay();
}
// Populate the overlay with project data
overlay.querySelector('.project-detail-title').textContent = project.title;
overlay.querySelector('.project-detail-subtitle').textContent = project.subtitle || '';
overlay.querySelector('.project-detail-description').textContent = project.description || '';
// Show timeframe and category
const metaInfo = overlay.querySelector('.project-detail-meta');
metaInfo.innerHTML = `
<div class="meta-item">
<span class="meta-label">TIMEFRAME:</span>
<span class="meta-value">${project.timeframe || 'N/A'}</span>
</div>
<div class="meta-item">
<span class="meta-label">CATEGORY:</span>
<span class="meta-value">${project.category || 'N/A'}</span>
</div>
`;
// Show image gallery
this.renderProjectGallery(project, overlay);
// Show highlights
const highlightsList = overlay.querySelector('.project-detail-highlights');
if (project.highlights && project.highlights.length > 0) {
highlightsList.innerHTML = project.highlights.map(highlight =>
`<li>${highlight.text || highlight}</li>`
).join('');
} else {
highlightsList.innerHTML = '<li>No highlights available</li>';
}
// Show skills
const skillsContainer = overlay.querySelector('.project-detail-skills');
if (project.skills) {
const skills = project.skills.split(',').map(s => s.trim());
skillsContainer.innerHTML = skills.map(skill =>
`<span class="tech-tag">${skill}</span>`
).join('');
}
// Show links
const linksContainer = overlay.querySelector('.project-detail-links');
if (project.links && project.links.length > 0) {
linksContainer.innerHTML = project.links.map(link =>
`<a href="${link.url}" target="_blank" class="project-link-detail">${link.label || link.type}</a>`
).join('');
} else {
linksContainer.innerHTML = '<p>No external links available</p>';
}
// Show the overlay
overlay.style.display = 'flex';
document.body.style.overflow = 'hidden'; // Prevent background scrolling
}
renderProjectGallery(project, overlay) {
const galleryContainer = overlay.querySelector('.project-detail-gallery');
if (!project.images || project.images.length === 0) {
galleryContainer.innerHTML = '<p class="no-images">No images available for this project.</p>';
return;
}
// Sort images by rank priority: hero > featured > standard
const rankOrder = { 'hero': 0, 'featured': 1, 'standard': 2 };
const sortedImages = [...project.images].sort((a, b) => {
const rankA = rankOrder[a.rank] || 3;
const rankB = rankOrder[b.rank] || 3;
return rankA - rankB;
});
// Find hero image
const heroImage = sortedImages.find(img => img.rank === 'hero');
const featuredImages = sortedImages.filter(img => img.rank === 'featured');
const standardImages = sortedImages.filter(img => img.rank === 'standard');
let galleryHTML = '';
// Hero image section (large, prominent display)
if (heroImage) {
galleryHTML += `
<div class="gallery-hero-section">
<div class="gallery-hero-image" onclick="portfolioController.openFullscreenImage('${heroImage.src}', '${heroImage.description}')">
<img src="${heroImage.src}" alt="${heroImage.description}" class="hero-image">
<div class="image-overlay">
<div class="image-rank-badge hero-badge">HERO</div>
<div class="image-description">${heroImage.description}</div>
<div class="fullscreen-hint">Click to view fullscreen</div>
</div>
</div>
</div>
`;
}
// Featured and standard images grid
const otherImages = [...featuredImages, ...standardImages];
if (otherImages.length > 0) {
galleryHTML += `
<div class="gallery-grid-section">
<div class="gallery-grid">
${otherImages.map(image => `
<div class="gallery-grid-item ${image.rank}" onclick="portfolioController.openFullscreenImage('${image.src}', '${image.description}')">
<img src="${image.src}" alt="${image.description}" class="grid-image">
<div class="image-overlay">
<div class="image-rank-badge ${image.rank}-badge">${image.rank.toUpperCase()}</div>
<div class="image-description">${image.description}</div>
<div class="fullscreen-hint">Click to enlarge</div>
</div>
</div>
`).join('')}
</div>
</div>
`;
}
galleryContainer.innerHTML = galleryHTML;
}
openFullscreenImage(imageSrc, description) {
console.log('🖼️ Opening fullscreen image:', imageSrc);
console.log('🖼️ Description:', description);
// Create fullscreen overlay with higher z-index than project modal
const fullscreenOverlay = document.createElement('div');
fullscreenOverlay.className = 'fullscreen-image-overlay';
fullscreenOverlay.style.display = 'flex'; // Ensure it's visible
fullscreenOverlay.style.zIndex = '999999'; // Force very high z-index
fullscreenOverlay.style.position = 'fixed'; // Ensure it's positioned correctly
fullscreenOverlay.innerHTML = `
<div class="fullscreen-image-container">
<button class="close-fullscreen" onclick="portfolioController.closeFullscreenImage()">×</button>
<img src="${imageSrc}" alt="${description}" class="fullscreen-image" onload="console.log('✅ Image loaded successfully')" onerror="console.error('❌ Image failed to load:', this.src)">
<div class="fullscreen-description">${description}</div>
</div>
`;
document.body.appendChild(fullscreenOverlay);
console.log('🖼️ Fullscreen overlay added to DOM');
// Animate in
setTimeout(() => {
fullscreenOverlay.classList.add('active');
console.log('🖼️ Active class added to fullscreen overlay');
}, 10);
// Close on background click
fullscreenOverlay.addEventListener('click', (e) => {
if (e.target === fullscreenOverlay) {
this.closeFullscreenImage();
}
});
// Close on escape key
const escapeHandler = (e) => {
if (e.key === 'Escape') {
this.closeFullscreenImage();
document.removeEventListener('keydown', escapeHandler);
}
};
document.addEventListener('keydown', escapeHandler);
}
closeFullscreenImage() {
const fullscreenOverlay = document.querySelector('.fullscreen-image-overlay');
if (fullscreenOverlay) {
fullscreenOverlay.classList.remove('active');
setTimeout(() => {
if (fullscreenOverlay.parentNode) {
fullscreenOverlay.parentNode.removeChild(fullscreenOverlay);
}
}, 300);
}
}
createProjectDetailOverlay() {
const overlay = document.createElement('div');
overlay.id = 'project-detail-overlay';
overlay.innerHTML = `
<div class="project-detail-modal">
<div class="project-detail-header">
<h2 class="project-detail-title">Loading...</h2>
<button class="close-project-detail" onclick="portfolioController.closeProjectDetails()">×</button>
</div>
<div class="project-detail-content">
<p class="project-detail-subtitle"></p>
<div class="project-detail-meta"></div>
<div class="project-detail-section">
<h3>Description</h3>
<p class="project-detail-description"></p>
</div>
<div class="project-detail-section">
<h3>Key Highlights</h3>
<ul class="project-detail-highlights"></ul>
</div>
<div class="project-detail-section">
<h3>Technologies</h3>
<div class="project-detail-skills"></div>
</div>
<div class="project-detail-section">
<h3>Links</h3>
<div class="project-detail-links"></div>
</div>
<div class="project-detail-section project-gallery-section">
<h3>Project Gallery</h3>
<div class="project-detail-gallery"></div>
</div>
</div>
</div>
`;
// Add overlay click-to-close functionality
overlay.addEventListener('click', (e) => {
// Only close if clicking on the overlay background, not the modal content
if (e.target === overlay) {
this.closeProjectDetails();
}
});
document.body.appendChild(overlay);
return overlay;
}
closeProjectDetails() {
const overlay = document.getElementById('project-detail-overlay');
if (overlay) {
overlay.style.display = 'none';
document.body.style.overflow = ''; // Restore scrolling
// Remove mobile-hover class from all project cards to reverse animation
const projectCards = document.querySelectorAll('.project-card.mobile-hover');
projectCards.forEach(card => {
card.classList.remove('mobile-hover');
});
// Remove the history state if it was added
if (this.modalHistoryState) {
history.back();
this.modalHistoryState = false;
}
}
}
setupBackButtonHandling() {
// Handle browser back button to close modal
window.addEventListener('popstate', (event) => {
const overlay = document.getElementById('project-detail-overlay');
if (overlay && overlay.style.display === 'flex') {
// Modal is open, close it instead of navigating
overlay.style.display = 'none';
document.body.style.overflow = ''; // Restore scrolling
// Remove mobile-hover class from all project cards to reverse animation
const projectCards = document.querySelectorAll('.project-card.mobile-hover');
projectCards.forEach(card => {
card.classList.remove('mobile-hover');
});
this.modalHistoryState = false;
}
});
}
setupScrollAnimations() {
// Intersection Observer for scroll-based animations
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
const sectionId = entry.target.id;
this.triggerSectionAnimation(sectionId);
}
});
}, observerOptions);
// Observe all sections
const sections = document.querySelectorAll('.content-section, .portfolio-header');
sections.forEach(section => {
observer.observe(section);
});
}
createRippleEffect(element) {
const ripple = document.createElement('div');
ripple.style.position = 'absolute';
ripple.style.width = '4px';
ripple.style.height = '4px';
ripple.style.background = 'var(--cathode-cyan)';
ripple.style.borderRadius = '50%';
ripple.style.filter = 'var(--glow-cyan)';
ripple.style.pointerEvents = 'none';
ripple.style.animation = 'ripple-expand 0.6s ease-out forwards';
const rect = element.getBoundingClientRect();
ripple.style.left = '10px';
ripple.style.top = '50%';
ripple.style.transform = 'translateY(-50%)';
element.style.position = 'relative';
element.appendChild(ripple);
setTimeout(() => {
if (ripple.parentNode) {
ripple.parentNode.removeChild(ripple);
}
}, 600);
}
setupSkillBars() {
const skillBars = document.querySelectorAll('.skill-progress');
// Animate skill bars when skills section is shown
const animateSkills = () => {
skillBars.forEach((bar, index) => {
setTimeout(() => {
const level = bar.dataset.level;
bar.style.width = level + '%';
// Add pulse effect
bar.style.animation = `skill-load 1.5s ease-out forwards, skill-pulse 2s ease-in-out infinite ${index * 0.2}s`;
}, index * 200);
});
};
// Store animation function for later use
this.animateSkills = animateSkills;
}
setupOscilloscope() {
this.oscilloscopeCanvas = document.getElementById('oscilloscope-canvas');
if (!this.oscilloscopeCanvas) return;
this.oscilloscopeCtx = this.oscilloscopeCanvas.getContext('2d');
this.startOscilloscope();
}
startOscilloscope() {
const canvas = this.oscilloscopeCanvas;
const ctx = this.oscilloscopeCtx;
const width = canvas.width;
const height = canvas.height;
const drawWave = () => {
// Clear canvas
ctx.fillStyle = '#1A1A1A'; // black
ctx.fillRect(0, 0, width, height);
// Draw grid
ctx.strokeStyle = '#404040'; // gray-dark
ctx.lineWidth = 0.5;
ctx.setLineDash([2, 2]);
// Vertical grid lines
for (let x = 0; x < width; x += 30) {
ctx.beginPath();
ctx.moveTo(x, 0);
ctx.lineTo(x, height);
ctx.stroke();
}
// Horizontal grid lines
for (let y = 0; y < height; y += 30) {
ctx.beginPath();
ctx.moveTo(0, y);
ctx.lineTo(width, y);
ctx.stroke();
}
ctx.setLineDash([]);
// Draw oscilloscope wave
ctx.strokeStyle = '#7FBF5F'; // phosphor-green
ctx.lineWidth = 2;
ctx.shadowColor = '#7FBF5F';
ctx.shadowBlur = 8;
ctx.beginPath();
for (let x = 0; x < width; x++) {
const frequency1 = 0.02;
const frequency2 = 0.05;
const amplitude1 = 30;
const amplitude2 = 15;
const y1 = Math.sin((x + this.waveOffset) * frequency1) * amplitude1;
const y2 = Math.sin((x + this.waveOffset * 1.5) * frequency2) * amplitude2;
const y = height / 2 + y1 + y2;
if (x === 0) {
ctx.moveTo(x, y);
} else {
ctx.lineTo(x, y);
}
}
ctx.stroke();
ctx.shadowBlur = 0;
this.waveOffset += 2;
this.animationFrame = requestAnimationFrame(drawWave);
};
drawWave();
}
setupAmbientEffects() {
// Create additional floating particles dynamically with circuit theme
const ambientContainer = document.querySelector('.ambient-effects');
const createParticle = () => {
const particle = document.createElement('div');
particle.className = 'floating-particle';
// Random starting position
particle.style.left = Math.random() * 100 + '%';
particle.style.setProperty('--delay', Math.random() * 3 + 's');
particle.style.setProperty('--duration', (6 + Math.random() * 6) + 's');
// Circuit-themed particle types
const particleTypes = [
{
color: 'var(--terminal-green)',
filter: 'var(--glow-terminal)',
size: '3px',
animation: 'circuit-float-1 10s linear infinite, particle-pulse-1 3s ease-in-out infinite'
},
{
color: 'var(--cathode-cyan)',
filter: 'var(--glow-cyan)',
size: '4px',
animation: 'circuit-float-2 14s linear infinite, particle-pulse-2 4s ease-in-out infinite'
},
{
color: 'var(--phosphor-green)',
filter: 'var(--glow-phosphor)',
size: '2px',
animation: 'circuit-float-3 8s linear infinite, particle-pulse-3 2s ease-in-out infinite'
},
{
color: 'var(--amber-glow)',
filter: 'var(--glow-amber)',
size: '2.5px',
animation: 'circuit-float-1 12s linear infinite, particle-pulse-1 4s ease-in-out infinite'
},
{
color: 'var(--mint-glow)',
filter: 'var(--glow-phosphor)',
size: '1.5px',
animation: 'circuit-float-3 6s linear infinite, particle-pulse-3 1.5s ease-in-out infinite'
}
];
const randomType = particleTypes[Math.floor(Math.random() * particleTypes.length)];
particle.style.background = randomType.color;
particle.style.filter = randomType.filter;
particle.style.width = randomType.size;
particle.style.height = randomType.size;
particle.style.animation = randomType.animation;
// Add slight random delay to animation
particle.style.animationDelay = (Math.random() * 2) + 's';
ambientContainer.appendChild(particle);
// Remove particle after animation completes
setTimeout(() => {
if (particle.parentNode) {
particle.parentNode.removeChild(particle);
}
}, 16000);
};
// Create circuit trace lighting effects
const createTraceEffect = () => {
const traces = document.querySelectorAll('.circuit-trace');
traces.forEach((trace, index) => {
setTimeout(() => {
trace.style.animationDelay = (Math.random() * 2) + 's';
}, index * 100);
});
};
// Create particles more frequently for richer effect
setInterval(createParticle, 2000);
// Randomize trace animations periodically
setInterval(createTraceEffect, 8000);
// Initial particles with staggered timing
for (let i = 0; i < 5; i++) {
setTimeout(createParticle, i * 800);
}
// Initial trace effect
setTimeout(createTraceEffect, 1000);
}
triggerSectionAnimation(sectionId) {
switch (sectionId) {
case 'intro':
// Only run typewriter effect once per page load
// The effect is triggered by XML parser after content loads
if (!this.typewriterHasRun) {
// Don't run here, let XML parser handle it
// this.typewriterEffect();
// this.typewriterHasRun = true;
}
break;
case 'projects':
this.animateProjectCards();
break;
case 'skills':
if (this.animateSkills) {
this.animateSkills();
}
break;
case 'contact':
this.pulseContactItems();
break;
}
}
typewriterEffect() {
const outputText = document.querySelector('.output-text');
if (!outputText) return;
const paragraphs = outputText.querySelectorAll('p');
paragraphs.forEach((p, index) => {
const text = p.textContent;
p.textContent = '';
p.style.opacity = '1';
setTimeout(() => {
let charIndex = 0;
const typeInterval = setInterval(() => {
p.textContent += text[charIndex];
charIndex++;
if (charIndex >= text.length) {
clearInterval(typeInterval);
}
}, 30);
}, index * 1000);
});
}
// Method to reset typewriter effect if needed (for dynamic content updates)
resetTypewriterEffect() {
this.typewriterHasRun = false;
}
animateProjectCards() {
const projectCards = document.querySelectorAll('.project-card');
projectCards.forEach((card, index) => {
card.style.opacity = '0';
card.style.transform = 'translateY(30px)';
setTimeout(() => {
card.style.transition = 'all 0.6s ease-out';
card.style.opacity = '1';
card.style.transform = 'translateY(0)';
}, index * 200);
});
}
pulseContactItems() {
const contactItems = document.querySelectorAll('.contact-item');
contactItems.forEach((item, index) => {
setTimeout(() => {
item.style.animation = 'pulse-glow 1s ease-in-out';
}, index * 300);
});
}
setupResponsiveHandling() {
let resizeTimeout;
window.addEventListener('resize', () => {
clearTimeout(resizeTimeout);
resizeTimeout = setTimeout(() => {
this.handleResize();
}, 250);
});
}
handleResize() {
// Restart oscilloscope with new dimensions
if (this.oscilloscopeCanvas) {
const rect = this.oscilloscopeCanvas.getBoundingClientRect();
if (rect.width > 0 && rect.height > 0) {
if (this.animationFrame) {
cancelAnimationFrame(this.animationFrame);
}
this.startOscilloscope();
}
}
}
// Public method to update portfolio content
updateContent(newContent) {
if (newContent.title) {
const titleElement = document.querySelector('.portfolio-title');
if (titleElement) {
titleElement.textContent = newContent.title;
}
}
if (newContent.about) {
const aboutSection = document.querySelector('#about .output-text');
if (aboutSection) {
aboutSection.innerHTML = newContent.about;
}
}
if (newContent.projects) {
this.updateProjects(newContent.projects);
}
if (newContent.skills) {
this.updateSkills(newContent.skills);
}
if (newContent.contact) {
this.updateContact(newContent.contact);
}
}
updateProjects(projects) {
const projectsGrid = document.querySelector('.projects-grid');
if (!projectsGrid) return;
projectsGrid.innerHTML = '';
this.projects = projects; // Store projects for navigation
projects.forEach(project => {
const projectCard = document.createElement('div');
projectCard.className = 'project-card';
projectCard.dataset.projectId = project.id;
projectCard.innerHTML = `
<div class="project-content">
<div class="image-thumbnail">
<img src="${project.thumbnail || 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIwIiBoZWlnaHQ9IjgwIiB2aWV3Qm94PSIwIDAgMTIwIDgwIiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxyZWN0IHdpZHRoPSIxMjAiIGhlaWdodD0iODAiIGZpbGw9IiM0MDQwNDAiLz48dGV4dCB4PSI2MCIgeT0iNDAiIGZpbGw9IiNGRkYiIHRleHQtYW5jaG9yPSJtaWRkbGUiIGR5PSIuM2VtIiBmb250LXNpemU9IjEyIj5ObyBJbWFnZTwvdGV4dD48L3N2Zz4='}" alt="${project.title}" class="project-thumbnail">
</div>
<div class="project-info">
<div class="project-header">
<h3 class="project-title">${project.title}</h3>
<div class="project-status">${project.status || 'FEATURED'}</div>
</div>
<div class="project-description">
${project.description}
</div>
<div class="project-tech">
${project.technologies ? project.technologies.map(tech => `<span class="tech-tag">${tech}</span>`).join('') : ''}
</div>
<div class="project-links">
${(() => {
const primary = (project.links || []).find(l => l.type === 'website') || (project.links || [])[0];
return primary ? `<a href="${primary.url}" target="_blank" rel="noopener" class="tile-link">${primary.label || primary.url.replace(/^https?:\/\//, '')} ↗</a>` : '';
})()}
<span class="project-link">EXPLORE PROJECT →</span>
</div>
</div>
</div>
`;
projectsGrid.appendChild(projectCard);
});
}
updateSkills(skills) {
const skillsMatrix = document.querySelector('.skills-matrix');
if (!skillsMatrix) return;
skillsMatrix.innerHTML = '';
Object.keys(skills).forEach(category => {
const skillCategory = document.createElement('div');
skillCategory.className = 'skill-category';
skillCategory.innerHTML = `
<h3 class="category-title">${category.toUpperCase()}</h3>
<div class="skill-bars">
${skills[category].map(skill => `
<div class="skill-item">
<span class="skill-name">${skill.name}</span>
<div class="skill-bar">
<div class="skill-progress" data-level="${skill.level}"></div>
</div>
</div>
`).join('')}
</div>
`;
skillsMatrix.appendChild(skillCategory);
});
this.setupSkillBars();
}
updateContact(contact) {
const contactMethods = document.querySelector('.contact-methods');
if (!contactMethods) return;
contactMethods.innerHTML = '';
Object.keys(contact).forEach(method => {
const contactItem = document.createElement('div');
contactItem.className = 'contact-item';
let contactValueHtml;
if (method === 'email') {
contactValueHtml = `<span class="contact-value">${contact[method]}</span>`;
} else if (method === 'github') {
contactValueHtml = `<a href="https://${contact[method]}" target="_blank" class="contact-value contact-link">${contact[method]}</a>`;
} else if (method === 'linkedin') {
const displayUrl = contact[method].replace('https://', '').replace('http://', '');
contactValueHtml = `<a href="${contact[method]}" target="_blank" class="contact-value contact-link">${displayUrl}</a>`;
} else {
contactValueHtml = `<span class="contact-value">${contact[method]}</span>`;
}
contactItem.innerHTML = `
<span class="contact-label">${method.toUpperCase()}:</span>
${contactValueHtml}
`;
contactMethods.appendChild(contactItem);
});
}
}
// Additional CSS animations via JavaScript
const additionalStyles = `
@keyframes ripple-expand {
0% {
width: 4px;
height: 4px;
opacity: 1;
}
100% {
width: 20px;
height: 20px;
opacity: 0;
}
}
@keyframes skill-pulse {
0%, 100% {
filter: var(--glow-cyan);
}
50% {
filter: var(--glow-cyan) brightness(1.3);
}
}
@keyframes pulse-glow {
0%, 100% {
filter: none;
}
50% {
filter: drop-shadow(0 0 2px rgba(153, 102, 51, 0.2)) drop-shadow(0 0 4px rgba(204, 136, 68, 0.2)) drop-shadow(0 0 8px rgba(255, 179, 102, 0.06));
}
}
/* Project Detail Overlay Styles */
#project-detail-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.9);
display: none;
justify-content: center;
align-items: center;
z-index: 10000;
padding: 20px;
box-sizing: border-box;
}
.project-detail-modal {
background: var(--black-pure);
border: 1px solid var(--cathode-cyan);
border-radius: 8px;
max-width: 800px;
max-height: 95vh;
width: 100%;
overflow-y: auto;
box-shadow: 0 8px 32px rgba(77, 217, 217, 0.3);
}
.project-detail-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20px;
border-bottom: 1px solid var(--brass);
background: var(--black);
}
.project-detail-title {
color: #F5F5F5;
font-weight: 300;
text-shadow:
0 0 2px rgba(255, 179, 102, 0.8),
0 0 4px rgba(255, 153, 102, 0.6),
0 0 6px rgba(204, 136, 68, 0.4),
0 1px 0 rgba(153, 102, 51, 0.3),
0 2px 3px rgba(0, 0, 0, 0.2);
font-family: var(--font-mono);
font-size: 1.5rem;
margin: 0;
filter: brightness(1.01);
}
.close-project-detail {
background: none;
border: 1px solid var(--cathode-cyan);
color: var(--cathode-cyan);
font-size: 1.5rem;
width: 40px;
height: 40px;
border-radius: 50%;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.3s ease;
filter: var(--glow-cyan);
}
.close-project-detail:hover {
background: rgba(77, 217, 217, 0.1);
transform: scale(1.1);
}
.project-detail-content {
padding: 20px;
}
.project-detail-subtitle {
color: var(--cathode-cyan);
font-family: var(--font-mono);
font-size: 1.1rem;
margin-bottom: 20px;
filter: var(--glow-cyan);
}
.project-detail-meta {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 15px;
margin-bottom: 20px;