-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
325 lines (289 loc) · 11.2 KB
/
Copy pathscript.js
File metadata and controls
325 lines (289 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
323
324
325
// Mobile Navigation Toggle
document.addEventListener('DOMContentLoaded', function() {
const hamburger = document.querySelector('.hamburger');
const navMenu = document.querySelector('.nav-menu');
const navLinks = document.querySelectorAll('.nav-link');
// Toggle mobile menu
if (hamburger && navMenu) {
hamburger.addEventListener('click', function() {
navMenu.classList.toggle('active');
hamburger.classList.toggle('active');
});
// Close mobile menu when clicking on a link
navLinks.forEach(link => {
link.addEventListener('click', function() {
navMenu.classList.remove('active');
hamburger.classList.remove('active');
});
});
}
// Smooth scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
target.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
});
});
// Project filtering functionality (for projects page)
const filterButtons = document.querySelectorAll('.filter-btn');
const projectCards = document.querySelectorAll('.project-card');
if (filterButtons.length > 0 && projectCards.length > 0) {
filterButtons.forEach(button => {
button.addEventListener('click', function() {
// Remove active class from all buttons
filterButtons.forEach(btn => btn.classList.remove('active'));
// Add active class to clicked button
this.classList.add('active');
const filter = this.getAttribute('data-filter');
projectCards.forEach(card => {
if (filter === 'all' || card.getAttribute('data-category') === filter) {
card.style.display = 'block';
card.style.animation = 'fadeInUp 0.6s ease';
} else {
card.style.display = 'none';
}
});
});
});
}
// Contact form handling
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 can replace this with actual form submission)
showNotification('Thank you for your message! I\'ll get back to you soon.', 'success');
// Reset form
this.reset();
});
}
// Navbar scroll effect
const navbar = document.querySelector('.navbar');
if (navbar) {
window.addEventListener('scroll', function() {
if (window.scrollY > 50) {
navbar.style.background = 'rgba(255, 255, 255, 0.98)';
navbar.style.boxShadow = '0 2px 20px rgba(0, 0, 0, 0.1)';
} else {
navbar.style.background = 'rgba(255, 255, 255, 0.95)';
navbar.style.boxShadow = 'none';
}
});
}
// Animate elements on scroll
const observeElements = document.querySelectorAll('.skill-category, .stat, .project-card');
if (observeElements.length > 0) {
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.animation = 'fadeInUp 0.6s ease forwards';
entry.target.style.opacity = '1';
}
});
}, {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
});
observeElements.forEach(element => {
element.style.opacity = '0';
observer.observe(element);
});
}
// Typewriter effect for hero title (optional enhancement)
const heroTitle = document.querySelector('.hero-title');
if (heroTitle && heroTitle.textContent.includes('Aniket Kumar')) {
typewriterEffect(heroTitle, "Hi, I'm Aniket Kumar", 100);
}
// Skills hover effect enhancement
const skillItems = document.querySelectorAll('.skill-item');
skillItems.forEach(item => {
item.addEventListener('mouseenter', function() {
this.style.transform = 'translateY(-3px) scale(1.05)';
});
item.addEventListener('mouseleave', function() {
this.style.transform = 'translateY(0) scale(1)';
});
});
// Social links tracking (for analytics)
const socialLinks = document.querySelectorAll('.hero-social a, .contact-method a');
socialLinks.forEach(link => {
link.addEventListener('click', function() {
const platform = this.href.includes('github') ? 'GitHub' :
this.href.includes('linkedin') ? 'LinkedIn' :
this.href.includes('twitter') ? 'Twitter' : 'Email';
// You can add analytics tracking here
console.log(`Clicked on ${platform} link`);
});
});
});
// Utility function to show notifications
function showNotification(message, type = 'info') {
const notification = document.createElement('div');
notification.className = `notification notification-${type}`;
notification.innerHTML = `
<div class="notification-content">
<span>${message}</span>
<button onclick="this.parentElement.parentElement.remove()" class="notification-close">×</button>
</div>
`;
// Add notification styles if not already present
if (!document.querySelector('#notification-styles')) {
const styles = document.createElement('style');
styles.id = 'notification-styles';
styles.textContent = `
.notification {
position: fixed;
top: 20px;
right: 20px;
padding: 1rem 1.5rem;
border-radius: 8px;
color: white;
font-weight: 500;
z-index: 10000;
animation: slideInRight 0.3s ease;
max-width: 400px;
}
.notification-success { background: #10b981; }
.notification-error { background: #ef4444; }
.notification-info { background: #3b82f6; }
.notification-content {
display: flex;
justify-content: space-between;
align-items: center;
}
.notification-close {
background: none;
border: none;
color: white;
font-size: 1.5rem;
cursor: pointer;
margin-left: 1rem;
}
@keyframes slideInRight {
from { transform: translateX(100%); opacity: 0; }
to { transform: translateX(0); opacity: 1; }
}
`;
document.head.appendChild(styles);
}
document.body.appendChild(notification);
// Auto remove after 5 seconds
setTimeout(() => {
if (notification.parentElement) {
notification.remove();
}
}, 5000);
}
// Typewriter effect function
function typewriterEffect(element, text, speed = 100) {
element.innerHTML = '';
let i = 0;
function type() {
if (i < text.length) {
if (text.charAt(i) === '<') {
// Handle HTML tags
let tagEnd = text.indexOf('>', i);
element.innerHTML += text.substring(i, tagEnd + 1);
i = tagEnd + 1;
} else {
element.innerHTML += text.charAt(i);
i++;
}
setTimeout(type, speed);
}
}
type();
}
// Scroll to top functionality
function addScrollToTop() {
const scrollButton = document.createElement('button');
scrollButton.innerHTML = '↑';
scrollButton.className = 'scroll-to-top';
scrollButton.onclick = () => window.scrollTo({ top: 0, behavior: 'smooth' });
// Add styles
const styles = document.createElement('style');
styles.textContent = `
.scroll-to-top {
position: fixed;
bottom: 30px;
right: 30px;
width: 50px;
height: 50px;
border-radius: 50%;
background: var(--primary-color);
color: white;
border: none;
font-size: 1.2rem;
cursor: pointer;
opacity: 0;
visibility: hidden;
transition: all 0.3s ease;
z-index: 1000;
}
.scroll-to-top.visible {
opacity: 1;
visibility: visible;
}
.scroll-to-top:hover {
background: var(--primary-dark);
transform: translateY(-2px);
}
`;
document.head.appendChild(styles);
document.body.appendChild(scrollButton);
// Show/hide scroll button based on scroll position
window.addEventListener('scroll', () => {
if (window.scrollY > 300) {
scrollButton.classList.add('visible');
} else {
scrollButton.classList.remove('visible');
}
});
}
// Initialize scroll to top button
addScrollToTop();
// Performance optimization: Lazy loading for images
if ('loading' in HTMLImageElement.prototype) {
const images = document.querySelectorAll('img[data-src]');
images.forEach(img => {
img.src = img.dataset.src;
});
} else {
// Fallback for browsers that don't support lazy loading
const script = document.createElement('script');
script.src = 'https://polyfill.io/v3/polyfill.min.js?features=IntersectionObserver';
document.head.appendChild(script);
}
// Theme detection and handling
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
document.body.classList.add('dark-theme');
}
// Listen for theme changes
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', e => {
if (e.matches) {
document.body.classList.add('dark-theme');
} else {
document.body.classList.remove('dark-theme');
}
});
// Console message for developers
console.log(`
🚀 Welcome to Aniket Kumar's Portfolio!
📧 Contact: contact@aniketkumar.dev
🔗 GitHub: https://github.com/aniketkumar
💼 LinkedIn: https://linkedin.com/in/aniketkumar
This website was built with vanilla HTML, CSS, and JavaScript.
Feel free to reach out if you have any questions!
`);