Repository navigation
Expand file tree
/
Copy pathapp.js
More file actions
322 lines (278 loc) · 11.2 KB
/
Copy pathapp.js
File metadata and controls
322 lines (278 loc) · 11.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
// Modern Portfolio JavaScript - Enhanced Version
(function () {
// Navigation Controls
const controls = [...document.querySelectorAll(".control")];
const sections = [...document.querySelectorAll(".container")];
controls.forEach(button => {
button.addEventListener("click", function() {
// Remove active class from current button
document.querySelector(".active-btn").classList.remove("active-btn");
// Add active class to clicked button
this.classList.add("active-btn");
// Remove active class from current section
document.querySelector(".active").classList.remove("active");
// Add active class to target section
document.getElementById(button.dataset.id).classList.add("active");
// Update URL hash without scrolling
history.pushState(null, null, `#${button.dataset.id}`);
});
});
// Theme Toggle with LocalStorage
const themeBtn = document.querySelector(".theme-btn");
const body = document.body;
// Check for saved theme preference or default to dark mode
const currentTheme = localStorage.getItem("theme");
if (currentTheme === "light") {
body.classList.add("light-mode");
}
themeBtn.addEventListener("click", () => {
body.classList.toggle("light-mode");
// Save theme preference
if (body.classList.contains("light-mode")) {
localStorage.setItem("theme", "light");
} else {
localStorage.setItem("theme", "dark");
}
// Animate theme button
themeBtn.style.transform = "rotate(360deg)";
setTimeout(() => {
themeBtn.style.transform = "rotate(0deg)";
}, 300);
});
// Initialize AOS (Animate On Scroll)
AOS.init({
duration: 1000,
easing: 'ease-in-out',
once: true,
mirror: false
});
// Smooth Scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
const href = this.getAttribute('href');
if (href !== '#' && href !== '#contact') {
e.preventDefault();
const targetId = href.substring(1);
const targetSection = document.getElementById(targetId);
if (targetSection) {
// Find and click the corresponding control button
const targetControl = document.querySelector(`[data-id="${targetId}"]`);
if (targetControl) {
targetControl.click();
}
}
}
});
});
// Typing Animation for Name
const nameElement = document.querySelector('.name');
if (nameElement) {
const originalText = nameElement.innerHTML;
nameElement.innerHTML = '';
let index = 0;
function typeWriter() {
if (index < originalText.length) {
nameElement.innerHTML = originalText.slice(0, index + 1);
index++;
setTimeout(typeWriter, 50);
}
}
// Start typing animation after a short delay
setTimeout(typeWriter, 500);
}
// Parallax Effect on Hero Section
const heroSection = document.querySelector('.header-content');
if (heroSection) {
window.addEventListener('scroll', () => {
const scrolled = window.pageYOffset;
const parallax = -scrolled * 0.5;
heroSection.style.transform = `translateY(${parallax}px)`;
});
}
// Dynamic Project Image Loading with Lazy Loading
const projectImages = document.querySelectorAll('.project-image img');
const imageOptions = {
threshold: 0,
rootMargin: "0px 0px 50px 0px"
};
const imageObserver = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
const img = entry.target;
img.classList.add('fade-in');
observer.unobserve(img);
}
});
}, imageOptions);
projectImages.forEach(image => {
imageObserver.observe(image);
});
// Contact Form Enhancement
const contactForm = document.querySelector('.contact-form');
if (contactForm) {
contactForm.addEventListener('submit', function(e) {
e.preventDefault();
// Get form data
const formData = new FormData(this);
const formObject = {};
formData.forEach((value, key) => {
formObject[key] = value;
});
// Show success message (you would normally send this to a server)
const submitBtn = this.querySelector('.btn-submit');
const originalText = submitBtn.innerHTML;
submitBtn.innerHTML = '<span>Message Sent!</span> <i class="fas fa-check"></i>';
submitBtn.style.background = 'linear-gradient(135deg, #00d4ff 0%, #00ff88 100%)';
// Reset form
this.reset();
// Reset button after 3 seconds
setTimeout(() => {
submitBtn.innerHTML = originalText;
submitBtn.style.background = '';
}, 3000);
});
}
// Skill Tags Animation on Hover
const skillTags = document.querySelectorAll('.skill-tag');
skillTags.forEach(tag => {
tag.addEventListener('mouseenter', function() {
this.style.transform = 'scale(1.1) rotate(5deg)';
});
tag.addEventListener('mouseleave', function() {
this.style.transform = 'scale(1) rotate(0deg)';
});
});
// Counter Animation for Stats
const stats = document.querySelectorAll('.stat-item h3');
const statsObserver = new IntersectionObserver(
(entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
const target = entry.target;
const finalValue = target.textContent;
// Only animate numbers
if (/\d/.test(finalValue)) {
let currentValue = 0;
const increment = 1;
const duration = 1000;
const stepTime = duration / parseInt(finalValue);
const counter = setInterval(() => {
currentValue += increment;
target.textContent = currentValue;
if (currentValue >= parseInt(finalValue)) {
clearInterval(counter);
target.textContent = finalValue;
}
}, stepTime);
}
statsObserver.unobserve(target);
}
});
},
{ threshold: 0.5 }
);
stats.forEach(stat => {
statsObserver.observe(stat);
});
// Mouse Follower Effect
const mouseFollower = document.createElement('div');
mouseFollower.className = 'mouse-follower';
mouseFollower.style.cssText = `
width: 20px;
height: 20px;
border: 2px solid var(--color-secondary);
border-radius: 50%;
position: fixed;
pointer-events: none;
transition: transform 0.1s ease;
z-index: 9999;
opacity: 0.5;
`;
document.body.appendChild(mouseFollower);
document.addEventListener('mousemove', (e) => {
mouseFollower.style.left = e.clientX - 10 + 'px';
mouseFollower.style.top = e.clientY - 10 + 'px';
});
// Enhance hover effects for links and buttons
const interactiveElements = document.querySelectorAll('a, button, .control, .btn');
interactiveElements.forEach(element => {
element.addEventListener('mouseenter', () => {
mouseFollower.style.transform = 'scale(2)';
mouseFollower.style.borderColor = 'var(--color-accent)';
});
element.addEventListener('mouseleave', () => {
mouseFollower.style.transform = 'scale(1)';
mouseFollower.style.borderColor = 'var(--color-secondary)';
});
});
// Handle URL hash on page load
window.addEventListener('load', () => {
const hash = window.location.hash;
if (hash) {
const targetId = hash.substring(1);
const targetControl = document.querySelector(`[data-id="${targetId}"]`);
if (targetControl) {
setTimeout(() => {
targetControl.click();
}, 100);
}
}
});
// Add ripple effect to buttons
const buttons = document.querySelectorAll('.btn, .control');
buttons.forEach(button => {
button.addEventListener('click', function(e) {
const ripple = document.createElement('span');
ripple.className = 'ripple';
ripple.style.cssText = `
position: absolute;
border-radius: 50%;
background: rgba(255, 255, 255, 0.5);
transform: scale(0);
animation: ripple-animation 0.6s ease-out;
pointer-events: none;
`;
const rect = this.getBoundingClientRect();
const size = Math.max(rect.width, rect.height);
const x = e.clientX - rect.left - size / 2;
const y = e.clientY - rect.top - size / 2;
ripple.style.width = ripple.style.height = size + 'px';
ripple.style.left = x + 'px';
ripple.style.top = y + 'px';
this.style.position = 'relative';
this.style.overflow = 'hidden';
this.appendChild(ripple);
setTimeout(() => {
ripple.remove();
}, 600);
});
});
// Add CSS for ripple animation
const style = document.createElement('style');
style.textContent = `
@keyframes ripple-animation {
to {
transform: scale(4);
opacity: 0;
}
}
.fade-in {
animation: fadeIn 0.6s ease-in-out;
}
@keyframes fadeIn {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
`;
document.head.appendChild(style);
// Console Easter Egg
console.log('%c Welcome to James Niere\'s Portfolio! ', 'background: linear-gradient(135deg, #00d4ff 0%, #0066ff 100%); color: white; font-size: 20px; padding: 10px; border-radius: 5px;');
console.log('%c Looking for opportunities? Let\'s connect! ', 'color: #00d4ff; font-size: 14px;');
console.log('%c Email: jayniere@berkeley.edu ', 'color: #888; font-size: 12px;');
})();