-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.JS
More file actions
100 lines (86 loc) · 2.98 KB
/
Copy pathscript.JS
File metadata and controls
100 lines (86 loc) · 2.98 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
// AOS Initialization
AOS.init({ duration: 800, once: true });
// Dark Mode Toggle
const toggle = document.getElementById('modeToggle');
const themeIcon = document.getElementById('themeIcon');
function setThemeIcon(isDark) {
themeIcon.className = isDark ? 'bi bi-moon-fill' : 'bi bi-sun-fill';
}
if (localStorage.getItem('darkMode') === 'enabled') {
document.body.classList.add('dark-mode');
toggle.checked = true;
setThemeIcon(true);
} else {
setThemeIcon(false);
}
toggle.addEventListener('change', () => {
const isDarkMode = toggle.checked;
document.body.classList.toggle('dark-mode', isDarkMode);
localStorage.setItem('darkMode', isDarkMode ? 'enabled' : 'disabled');
setThemeIcon(isDarkMode);
});
// Resume Modal Logic
function openResumeModal() {
document.getElementById('resumeModal').style.display = 'flex';
document.body.style.overflow = 'hidden';
}
function closeResumeModal() {
document.getElementById('resumeModal').style.display = 'none';
document.body.style.overflow = 'auto';
}
window.addEventListener('click', (e) => {
if (e.target.id === 'resumeModal') {
closeResumeModal();
}
});
// Smooth Scroll
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
const target = document.querySelector(this.getAttribute('href'));
if (target) {
e.preventDefault();
window.scrollTo({ top: target.offsetTop - 70, behavior: 'smooth' });
}
});
});
// View More Toggle in Projects
document.querySelectorAll('.view-more-btn').forEach(button => {
button.addEventListener('click', () => {
const extra = button.closest('.project-summary').querySelector('.extra-details');
const visible = extra.style.display === 'block';
extra.style.display = visible ? 'none' : 'block';
button.textContent = visible ? 'View More' : 'View Less';
});
});
// Project Carousel Logic (independent carousels per project card)
document.querySelectorAll('.project-carousel').forEach(carousel => {
const images = carousel.querySelectorAll('.carousel-img');
const prevBtn = carousel.querySelector('.prev');
const nextBtn = carousel.querySelector('.next');
let index = 0;
function showImage(i) {
images.forEach((img, idx) => {
img.classList.toggle('active', idx === i);
});
}
prevBtn.addEventListener('click', () => {
index = (index - 1 + images.length) % images.length;
showImage(index);
});
nextBtn.addEventListener('click', () => {
index = (index + 1) % images.length;
showImage(index);
});
// Optional: Auto-slide
setInterval(() => {
index = (index + 1) % images.length;
showImage(index);
}, 5000);
// Initial show
showImage(index);
});
// Navbar shadow on scroll
window.addEventListener('scroll', function () {
const navbar = document.querySelector('.navbar');
navbar.style.boxShadow = window.scrollY > 50 ? '0 4px 10px rgba(0, 0, 0, 0.1)' : 'none';
});