Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
298 lines (254 loc) · 9.41 KB
/
Copy pathscript.js
File metadata and controls
298 lines (254 loc) · 9.41 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
/* =====================================================
JaserVerse - Portfolio JavaScript
Handles animations, typing effect, and interactivity
===================================================== */
document.addEventListener('DOMContentLoaded', () => {
// Initialize all functionality
initTypingEffect();
initNavigation();
initScrollEffects();
initStatCounters();
initYear();
});
/* =====================================================
Typing Effect
===================================================== */
function initTypingEffect() {
const typingElement = document.getElementById('typing-text');
if (!typingElement) return;
const phrases = [
'Junior .NET Developer',
'ASP.NET Core Web API',
'REST API Builder',
'EF Core & SQL Server',
'Problem Solver'
];
let phraseIndex = 0;
let charIndex = 0;
let isDeleting = false;
const typingSpeed = 100;
const deletingSpeed = 50;
const pauseTime = 2000;
function type() {
const currentPhrase = phrases[phraseIndex];
if (isDeleting) {
// Deleting characters
typingElement.textContent = currentPhrase.substring(0, charIndex - 1);
charIndex--;
if (charIndex === 0) {
isDeleting = false;
phraseIndex = (phraseIndex + 1) % phrases.length;
setTimeout(type, 500);
return;
}
} else {
// Typing characters
typingElement.textContent = currentPhrase.substring(0, charIndex + 1);
charIndex++;
if (charIndex === currentPhrase.length) {
isDeleting = true;
setTimeout(type, pauseTime);
return;
}
}
setTimeout(type, isDeleting ? deletingSpeed : typingSpeed);
}
// Start typing
setTimeout(type, 1000);
}
/* =====================================================
Navigation
===================================================== */
function initNavigation() {
const navbar = document.getElementById('navbar');
const navToggle = document.getElementById('nav-toggle');
const navMenu = document.getElementById('nav-menu');
const navLinks = document.querySelectorAll('.nav-link');
// Scroll effect for navbar
window.addEventListener('scroll', () => {
if (window.scrollY > 50) {
navbar.classList.add('scrolled');
} else {
navbar.classList.remove('scrolled');
}
});
// Mobile menu toggle
if (navToggle && navMenu) {
navToggle.addEventListener('click', () => {
navToggle.classList.toggle('active');
navMenu.classList.toggle('active');
document.body.style.overflow = navMenu.classList.contains('active') ? 'hidden' : '';
});
}
// Close mobile menu on link click
navLinks.forEach(link => {
link.addEventListener('click', () => {
if (navMenu.classList.contains('active')) {
navToggle.classList.remove('active');
navMenu.classList.remove('active');
document.body.style.overflow = '';
}
});
});
// Active link on scroll
const sections = document.querySelectorAll('section[id]');
function highlightNavLink() {
const scrollY = window.scrollY;
sections.forEach(section => {
const sectionHeight = section.offsetHeight;
const sectionTop = section.offsetTop - 100;
const sectionId = section.getAttribute('id');
if (scrollY > sectionTop && scrollY <= sectionTop + sectionHeight) {
navLinks.forEach(link => {
link.classList.remove('active');
if (link.getAttribute('href') === `#${sectionId}`) {
link.classList.add('active');
}
});
}
});
}
window.addEventListener('scroll', highlightNavLink);
}
/* =====================================================
Scroll Effects
===================================================== */
function initScrollEffects() {
const backToTop = document.getElementById('backToTop');
// Back to top visibility
window.addEventListener('scroll', () => {
if (window.scrollY > 500) {
backToTop.classList.add('visible');
} else {
backToTop.classList.remove('visible');
}
});
// Back to top click
if (backToTop) {
backToTop.addEventListener('click', () => {
window.scrollTo({
top: 0,
behavior: 'smooth'
});
});
}
// Fade in elements on scroll
const fadeElements = document.querySelectorAll('.skill-category, .project-card, .contact-item');
const observerOptions = {
root: null,
rootMargin: '0px',
threshold: 0.1
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('fade-in', 'visible');
observer.unobserve(entry.target);
}
});
}, observerOptions);
fadeElements.forEach(el => {
el.classList.add('fade-in');
observer.observe(el);
});
}
/* =====================================================
Stat Counters Animation
===================================================== */
function initStatCounters() {
const statNumbers = document.querySelectorAll('.stat-number');
const countUp = (element) => {
const target = parseInt(element.getAttribute('data-target'));
const duration = 2000; // 2 seconds
const increment = target / (duration / 16); // 60fps
let current = 0;
const updateCount = () => {
current += increment;
if (current < target) {
element.textContent = Math.floor(current);
requestAnimationFrame(updateCount);
} else {
element.textContent = target;
}
};
updateCount();
};
// Observe stat numbers
const statObserver = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
countUp(entry.target);
statObserver.unobserve(entry.target);
}
});
}, { threshold: 0.5 });
statNumbers.forEach(stat => {
statObserver.observe(stat);
});
}
/* =====================================================
Update Footer Year
===================================================== */
function initYear() {
const yearElement = document.getElementById('year');
if (yearElement) {
yearElement.textContent = new Date().getFullYear();
}
}
/* =====================================================
Smooth Scroll Polyfill (for older browsers)
===================================================== */
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'
});
}
});
});
/* =====================================================
Parallax Effect for Hero (subtle)
===================================================== */
window.addEventListener('scroll', () => {
const scrolled = window.scrollY;
const hero = document.querySelector('.hero');
if (hero && scrolled < window.innerHeight) {
const imageWrapper = document.querySelector('.image-wrapper');
const heroContent = document.querySelector('.hero-content');
if (imageWrapper) {
imageWrapper.style.transform = `translateY(${scrolled * 0.1}px)`;
}
if (heroContent) {
heroContent.style.transform = `translateY(${scrolled * 0.05}px)`;
heroContent.style.opacity = 1 - (scrolled / (window.innerHeight * 0.8));
}
}
});
/* =====================================================
Project Card Tilt Effect (optional, subtle)
===================================================== */
document.querySelectorAll('.project-card').forEach(card => {
card.addEventListener('mousemove', (e) => {
const rect = card.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) / 20;
const rotateY = (centerX - x) / 20;
card.style.transform = `perspective(1000px) rotateX(${rotateX}deg) rotateY(${rotateY}deg) translateY(-10px)`;
});
card.addEventListener('mouseleave', () => {
card.style.transform = 'perspective(1000px) rotateX(0) rotateY(0) translateY(0)';
});
});
/* =====================================================
Console Easter Egg
===================================================== */
console.log('%c👋 Hey there, curious developer!', 'color: #667eea; font-size: 20px; font-weight: bold;');
console.log('%cWelcome to JaserVerse! Built with passion.', 'color: #764ba2; font-size: 14px;');
console.log('%cFeel free to check out my GitHub: https://github.com/Jaser1010', 'color: #00d4ff; font-size: 12px;');