-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
444 lines (382 loc) · 14 KB
/
script.js
File metadata and controls
444 lines (382 loc) · 14 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
// Import and initialize Tubes Cursor
import TubesCursor from "https://cdn.jsdelivr.net/npm/threejs-components@0.0.19/build/cursors/tubes1.min.js"
// Initialize background effect
let app;
function initBackground() {
try {
const canvas = document.getElementById('canvas');
if (!canvas) {
console.warn('Canvas element not found');
return;
}
console.log('Initializing TubesCursor...');
app = TubesCursor(canvas, {
tubes: {
colors: ["#8b5cf6", "#667eea", "#764ba2"],
lights: {
intensity: 200,
colors: ["#667eea", "#8b5cf6", "#764ba2", "#a78bfa"]
}
}
});
console.log('TubesCursor initialized successfully');
// Change colors on click
document.body.addEventListener('click', () => {
const colors = randomColors(3);
const lightsColors = randomColors(4);
if (app && app.tubes) {
app.tubes.setColors(colors);
app.tubes.setLightsColors(lightsColors);
}
});
} catch (error) {
console.error('Error initializing background:', error);
}
}
function randomColors(count) {
return new Array(count)
.fill(0)
.map(() => "#" + Math.floor(Math.random() * 16777215).toString(16).padStart(6, '0'));
}
// Tab functionality with smooth fade transitions
function openTab(tabName) {
// Get all tab contents and find the currently active one
const tabContents = document.getElementsByClassName("tab-content");
const activeContent = document.querySelector('.tab-content.active');
const sectionTitle = document.getElementById('section-title');
// Remove active class from all navigation buttons IMMEDIATELY for smooth animation
const navButtons = document.querySelectorAll('.nav-button');
navButtons.forEach(button => {
button.classList.remove("active");
});
// Mark the corresponding navigation button as active IMMEDIATELY
const activeButton = document.querySelector(`.nav-button[data-tab="${tabName}"]`);
if (activeButton) {
activeButton.classList.add("active");
}
// Add fade-out class to current active content and title
if (activeContent) {
activeContent.classList.add('fade-out');
}
if (sectionTitle) {
sectionTitle.classList.add('fade-out');
}
// Wait for fade-out animation to complete
setTimeout(() => {
// Remove active class and fade-out class from all tabs
for (let i = 0; i < tabContents.length; i++) {
tabContents[i].classList.remove("active", "fade-out");
}
// Show the selected tab content
const newContent = document.getElementById(tabName);
if (newContent) {
newContent.classList.add("active");
}
// Update section title with fade-in
const sectionTitles = {
'about': 'Summary',
'experience': 'Professional Experience',
'education': 'Education',
'skills': 'Technical Skills',
'projects': 'Featured Projects',
'publications': 'Publications',
'blog': 'Blog Posts',
'interests': 'Interests'
};
if (sectionTitle && sectionTitles[tabName]) {
// Remove fade-out and update text
sectionTitle.classList.remove('fade-out');
sectionTitle.textContent = sectionTitles[tabName];
}
}, 300); // Match this with fade-out animation duration
}
// Initialize navigation
function initNavigation() {
const navButtons = document.querySelectorAll('.nav-button');
console.log(`Found ${navButtons.length} navigation buttons`);
navButtons.forEach(button => {
button.addEventListener('click', function(e) {
e.preventDefault();
const tabName = this.getAttribute('data-tab');
console.log(`Switching to tab: ${tabName}`);
// Use requestAnimationFrame for smoother transitions
requestAnimationFrame(() => {
openTab(tabName);
});
});
});
}
// Mobile menu toggle functionality
const menuToggle = document.getElementById('menuToggle');
const navLinksContainer = document.getElementById('navLinks');
if (menuToggle) {
menuToggle.addEventListener('click', (e) => {
e.stopPropagation();
navLinksContainer.classList.toggle('active');
});
}
// Handle nav link clicks
document.querySelectorAll('.nav-links a').forEach(link => {
link.addEventListener('click', (e) => {
e.preventDefault();
const tabName = link.getAttribute('data-tab');
if (tabName) {
openTab(tabName);
// Close mobile menu
navLinksContainer.classList.remove('active');
}
});
});
// Close mobile menu when clicking outside
document.addEventListener('click', (e) => {
if (menuToggle && navLinksContainer &&
!menuToggle.contains(e.target) &&
!navLinksContainer.contains(e.target)) {
navLinksContainer.classList.remove('active');
}
});
// Smooth scrolling and animations
function initAnimations() {
// Add smooth scroll behavior to external links
const externalLinks = document.querySelectorAll('a[target="_blank"]');
externalLinks.forEach(link => {
link.addEventListener('click', function(e) {
// Add a small delay to show the click feedback
setTimeout(() => {
// The browser will handle opening the external link
}, 100);
});
});
// Add animation classes for better UX
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.opacity = '1';
entry.target.style.transform = 'translateY(0)';
}
});
});
// Observe all job, degree, project, publication, and interest cards
const cards = document.querySelectorAll('.job, .degree, .project, .publication, .interest-card, .skill-category');
cards.forEach(card => {
card.style.opacity = '0';
card.style.transform = 'translateY(20px)';
card.style.transition = 'opacity 0.6s ease, transform 0.6s ease';
observer.observe(card);
});
}
// Add keyboard navigation for tabs
document.addEventListener('keydown', function(e) {
if (e.key === 'ArrowLeft' || e.key === 'ArrowRight') {
const activeTab = document.querySelector('.tab-button.active');
const tabs = Array.from(document.querySelectorAll('.tab-button'));
const currentIndex = tabs.indexOf(activeTab);
let newIndex;
if (e.key === 'ArrowLeft') {
newIndex = currentIndex > 0 ? currentIndex - 1 : tabs.length - 1;
} else {
newIndex = currentIndex < tabs.length - 1 ? currentIndex + 1 : 0;
}
tabs[newIndex].click();
tabs[newIndex].focus();
}
});
// Removed loading animation to prevent blinking
// Add search functionality (optional)
function initSearch() {
const searchInput = document.getElementById('search');
if (!searchInput) return;
searchInput.addEventListener('input', function(e) {
const searchTerm = e.target.value.toLowerCase();
const searchableElements = document.querySelectorAll('.job, .degree, .project, .publication, .interest-card, .skill-category');
searchableElements.forEach(element => {
const text = element.textContent.toLowerCase();
if (text.includes(searchTerm)) {
element.style.display = 'block';
element.style.opacity = '1';
} else {
element.style.display = 'none';
element.style.opacity = '0.5';
}
});
});
}
// Theme toggler (optional feature)
function initThemeToggler() {
const themeToggle = document.getElementById('theme-toggle');
if (!themeToggle) return;
themeToggle.addEventListener('click', function() {
document.body.classList.toggle('dark-theme');
localStorage.setItem('theme', document.body.classList.contains('dark-theme') ? 'dark' : 'light');
});
// Load saved theme
const savedTheme = localStorage.getItem('theme');
if (savedTheme === 'dark') {
document.body.classList.add('dark-theme');
}
}
// Print functionality
function printResume() {
window.print();
}
// Social media sharing (optional)
function shareResume(platform) {
const url = encodeURIComponent(window.location.href);
const title = encodeURIComponent('Ali Abbasi - Machine Learning Engineer');
let shareUrl;
switch(platform) {
case 'linkedin':
shareUrl = `https://www.linkedin.com/sharing/share-offsite/?url=${url}`;
break;
case 'twitter':
shareUrl = `https://twitter.com/intent/tweet?url=${url}&text=${title}`;
break;
case 'facebook':
shareUrl = `https://www.facebook.com/sharer/sharer.php?u=${url}`;
break;
default:
return;
}
window.open(shareUrl, '_blank', 'width=600,height=400');
}
// Add tooltips for skill tags
function initSkillTags() {
const skillTags = document.querySelectorAll('.skill-tag, .tech-tag');
skillTags.forEach(tag => {
tag.addEventListener('mouseenter', function() {
// You can add custom tooltips here if needed
this.style.transform = 'scale(1.05)';
});
tag.addEventListener('mouseleave', function() {
this.style.transform = 'scale(1)';
});
// Add transition for smooth hover effect
tag.style.transition = 'transform 0.2s ease';
});
}
// Copy email to clipboard
function copyEmail() {
const email = 'abbasialiar@gmail.com';
navigator.clipboard.writeText(email).then(function() {
// Show a temporary notification
const notification = document.createElement('div');
notification.textContent = 'Email copied to clipboard!';
notification.style.cssText = `
position: fixed;
top: 20px;
right: 20px;
background-color: #2ecc71;
color: white;
padding: 1rem 1.5rem;
border-radius: 5px;
z-index: 1000;
animation: slideIn 0.3s ease;
`;
document.body.appendChild(notification);
setTimeout(() => {
notification.remove();
}, 3000);
});
}
// Add slideIn animation
const style = document.createElement('style');
style.textContent = `
@keyframes slideIn {
from { transform: translateX(100%); opacity: 0; }
to { transform: translateX(0); opacity: 1; }
}
`;
document.head.appendChild(style);
// Glassmorphism glow effect - Mouse tracking for all panels and cards
function addGlowEffect(element) {
element.addEventListener('mousemove', (e) => {
const rect = element.getBoundingClientRect();
const x = e.clientX - rect.left;
const y = e.clientY - rect.top;
element.style.setProperty('--x', `${x}px`);
element.style.setProperty('--y', `${y}px`);
});
element.addEventListener('mouseleave', () => {
element.style.setProperty('--x', '50%');
element.style.setProperty('--y', '50%');
});
}
// Add 3D tilt effect
function add3DTilt(element, intensity = 5) {
element.addEventListener('mousemove', (e) => {
const rect = element.getBoundingClientRect();
const x = e.clientX - rect.left;
const y = e.clientY - rect.top;
const centerX = rect.width / 2;
const centerY = rect.height / 2;
const rotateX = ((y - centerY) / centerY) * intensity;
const rotateY = ((x - centerX) / centerX) * -intensity;
element.style.transform = `perspective(1000px) rotateX(${rotateX}deg) rotateY(${rotateY}deg)`;
});
element.addEventListener('mouseleave', () => {
element.style.transform = 'perspective(1000px) rotateX(0deg) rotateY(0deg)';
});
}
// Apply effects to all panels and cards
function initEffects() {
// Profile panel
const profilePanel = document.querySelector('.profile-panel');
if (profilePanel) {
addGlowEffect(profilePanel);
add3DTilt(profilePanel, 8);
}
// Updates panel
const updatesPanel = document.querySelector('.updates-panel');
if (updatesPanel) {
addGlowEffect(updatesPanel);
add3DTilt(updatesPanel, 8);
}
// Navigation buttons
const navButtons = document.querySelectorAll('.nav-button');
navButtons.forEach(button => {
addGlowEffect(button);
add3DTilt(button, 6);
});
// Section header card
const headerCard = document.querySelector('.section-header-card');
if (headerCard) {
addGlowEffect(headerCard);
add3DTilt(headerCard, 8);
}
// Section content card
const contentCard = document.querySelector('.section-content-card');
if (contentCard) {
addGlowEffect(contentCard);
add3DTilt(contentCard, 6);
}
}
// Blog post toggle functionality
function toggleBlogPost(button) {
const blogPost = button.closest('.blog-post');
const fullContent = blogPost.querySelector('.blog-full-content');
const isExpanded = fullContent.style.display !== 'none';
if (isExpanded) {
// Collapse
fullContent.style.display = 'none';
button.textContent = 'Show More';
} else {
// Expand
fullContent.style.display = 'block';
button.textContent = 'Show Less';
}
}
// Make toggleBlogPost available globally
window.toggleBlogPost = toggleBlogPost;
// Main initialization
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initAll);
} else {
initAll();
}
function initAll() {
initBackground();
initNavigation();
initEffects();
initAnimations();
initSkillTags();
}