-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
204 lines (169 loc) · 7.02 KB
/
script.js
File metadata and controls
204 lines (169 loc) · 7.02 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
document.addEventListener('DOMContentLoaded', () => {
// Life Story scroll animations
const storyObserver = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
const sectionId = entry.target.id;
const sectionNumber = parseInt(sectionId.replace('story', ''));
// Update background layers
document.querySelectorAll('.background-layer').forEach((layer, index) => {
layer.style.opacity = index === (sectionNumber - 1) ? '1' : '0';
});
// Update active class and progress dots
document.querySelectorAll('.story-section').forEach(section => {
section.classList.toggle('active', section.id === sectionId);
});
document.querySelectorAll('.progress-dot').forEach(dot => {
dot.classList.toggle('active', dot.dataset.section === sectionId);
});
}
});
}, {
threshold: 0.5
});
// Observe all story sections
document.querySelectorAll('.story-section').forEach(section => {
storyObserver.observe(section);
});
// Progress dot click handlers
document.querySelectorAll('.progress-dot').forEach(dot => {
dot.addEventListener('click', () => {
const targetSection = document.getElementById(dot.dataset.section);
if (targetSection) {
targetSection.scrollIntoView({
behavior: 'smooth',
block: 'center'
});
}
});
});
// Mobile menu functionality
const mobileMenuBtn = document.querySelector('.mobile-menu-btn');
const navLinks = document.querySelector('.nav-links');
if (mobileMenuBtn && navLinks) {
mobileMenuBtn.addEventListener('click', () => {
navLinks.classList.toggle('active');
mobileMenuBtn.classList.toggle('active');
});
// Close mobile menu when clicking a link
document.querySelectorAll('nav a').forEach(link => {
link.addEventListener('click', () => {
mobileMenuBtn.classList.remove('active');
navLinks.classList.remove('active');
});
});
}
// Mobile Menu Toggle
function setupMobileMenu() {
const mobileMenuBtn = document.querySelector('.mobile-menu-btn');
const mobileMenu = document.querySelector('.mobile-menu');
const closeMenuBtn = document.querySelector('.close-menu');
if (mobileMenuBtn && mobileMenu && closeMenuBtn) {
mobileMenuBtn.addEventListener('click', () => {
mobileMenu.classList.add('active');
});
closeMenuBtn.addEventListener('click', () => {
mobileMenu.classList.remove('active');
});
// Close menu when clicking outside
document.addEventListener('click', (e) => {
if (!mobileMenu.contains(e.target) && !mobileMenuBtn.contains(e.target)) {
mobileMenu.classList.remove('active');
}
});
}
}
setupMobileMenu();
// Initialize EmailJS
(function() {
// Replace with your EmailJS public key
emailjs.init("WUjW3B84TRjApCOeT");
})();
// Contact form submission
document.getElementById('contact-form').addEventListener('submit', function(event) {
event.preventDefault();
const statusDiv = document.getElementById('form-status');
statusDiv.textContent = 'Sending...';
const templateParams = {
from_name: this.user_name.value,
message: this.message.value,
reply_to: this.user_email.value
};
emailjs.send('service_t7lzcz1', 'template_uaqhesd', templateParams)
.then(function() {
statusDiv.textContent = 'Message sent successfully!';
statusDiv.style.color = 'green';
event.target.reset();
}, function(error) {
statusDiv.textContent = 'Failed to send message. Please try again.';
statusDiv.style.color = 'red';
console.error('EmailJS error:', error);
});
});
// Typing effect for taglines
const phrases = [
"Full-Stack Developer",
"Systems Engineer",
"Problem Solver",
"Tech Innovator"
];
function typeText() {
const element = document.querySelector('.typing-text');
if (!element) return;
let phraseIndex = 0;
let charIndex = 0;
let isDeleting = false;
let typingSpeed = 100;
function type() {
const currentPhrase = phrases[phraseIndex];
if (isDeleting) {
element.textContent = currentPhrase.substring(0, charIndex - 1);
charIndex--;
typingSpeed = 50;
} else {
element.textContent = currentPhrase.substring(0, charIndex + 1);
charIndex++;
typingSpeed = 100;
}
if (!isDeleting && charIndex === currentPhrase.length) {
isDeleting = true;
typingSpeed = 1500; // Pause at end
} else if (isDeleting && charIndex === 0) {
isDeleting = false;
phraseIndex = (phraseIndex + 1) % phrases.length;
typingSpeed = 500; // Pause before next phrase
}
setTimeout(type, typingSpeed);
}
type();
}
typeText();
// Clean URL Navigation
function setupNavigation() {
const navLinks = document.querySelectorAll('nav a, .mobile-menu a');
navLinks.forEach(link => {
link.addEventListener('click', function(e) {
const href = this.getAttribute('href');
// Close mobile menu if open (for all links)
const mobileMenu = document.querySelector('.mobile-menu');
if (mobileMenu && mobileMenu.classList.contains('active')) {
mobileMenu.classList.remove('active');
}
// If it's a different page (doesn't start with #), let it navigate normally
if (!href.startsWith('#')) {
return;
}
e.preventDefault();
const section = href.split('#')[1];
const targetSection = document.getElementById(section);
if (targetSection) {
targetSection.scrollIntoView({ behavior: 'smooth' });
// Update URL without the hash
const baseUrl = window.location.href.split('#')[0];
window.history.pushState({}, '', baseUrl);
}
});
});
}
setupNavigation();
});