-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
397 lines (347 loc) · 13.6 KB
/
script.js
File metadata and controls
397 lines (347 loc) · 13.6 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
document.addEventListener('DOMContentLoaded', function() {
initializeMobileMenu();
initializePremiumFeatures();
initializeTypingAnimation();
initializeSkillsAnimation();
initializeTechnologiesFilter();
initializeMouseTrail();
initializeAOS();
});
// ===== MOBILE MENU =====
function initializeMobileMenu() {
const hamburgerBtn = document.getElementById('menu-btn');
const mobileNav = document.getElementById('mobile-menu');
const mobileLinks = document.querySelectorAll('#mobile-menu a');
if (hamburgerBtn && mobileNav) {
// Toggle mobile menu
hamburgerBtn.addEventListener('click', function(e) {
e.stopPropagation();
this.classList.toggle('active');
mobileNav.classList.toggle('hidden');
// Change icon from bars to X
const icon = this.querySelector('i');
if (mobileNav.classList.contains('hidden')) {
icon.className = 'fas fa-bars text-xl';
} else {
icon.className = 'fas fa-times text-xl';
}
// Prevent body scroll when menu is open
if (!mobileNav.classList.contains('hidden')) {
document.body.style.overflow = 'hidden';
} else {
document.body.style.overflow = '';
}
});
// Close menu when clicking on links
mobileLinks.forEach(link => {
link.addEventListener('click', function() {
hamburgerBtn.classList.remove('active');
mobileNav.classList.add('hidden');
const icon = hamburgerBtn.querySelector('i');
icon.className = 'fas fa-bars text-xl';
document.body.style.overflow = '';
});
});
// Close menu when clicking outside
document.addEventListener('click', function(e) {
if (!mobileNav.contains(e.target) && !hamburgerBtn.contains(e.target)) {
hamburgerBtn.classList.remove('active');
mobileNav.classList.add('hidden');
const icon = hamburgerBtn.querySelector('i');
icon.className = 'fas fa-bars text-xl';
document.body.style.overflow = '';
}
});
// Close menu on escape key
document.addEventListener('keydown', function(e) {
if (e.key === 'Escape') {
hamburgerBtn.classList.remove('active');
mobileNav.classList.add('hidden');
const icon = hamburgerBtn.querySelector('i');
icon.className = 'fas fa-bars text-xl';
document.body.style.overflow = '';
}
});
}
}
// ===== STYLISH LOADING SCREEN =====
// ===== PREMIUM FEATURES =====
function initializePremiumFeatures() {
setupThemeToggle();
setupScrollProgress();
setupFloatingNav();
setupNavigation();
createParticles();
setupHeaderScroll();
}
function setupHeaderScroll() {
const header = document.querySelector('.glass-header');
if (header) {
window.addEventListener('scroll', function() {
if (window.scrollY > 100) {
header.classList.add('scrolled');
} else {
header.classList.remove('scrolled');
}
});
}
}
function createParticles() {
const particlesContainer = document.getElementById('particles-container');
if (!particlesContainer) return;
const particleCount = 30;
for (let i = 0; i < particleCount; i++) {
const particle = document.createElement('div');
particle.className = 'particle';
particle.style.left = Math.random() * 100 + '%';
particle.style.top = Math.random() * 100 + '%';
particle.style.animationDelay = Math.random() * 6 + 's';
particle.style.animationDuration = Math.random() * 3 + 3 + 's';
particlesContainer.appendChild(particle);
}
}
function setupThemeToggle() {
const themeToggle = document.getElementById('theme-toggle');
if (!themeToggle) return;
themeToggle.addEventListener('click', () => {
const icon = themeToggle.querySelector('i');
if (icon) {
if (icon.classList.contains('fa-moon')) {
icon.className = 'fas fa-sun';
} else {
icon.className = 'fas fa-moon';
}
}
themeToggle.style.transform = 'rotate(360deg)';
setTimeout(() => {
themeToggle.style.transform = 'rotate(0deg)';
}, 400);
});
}
function setupScrollProgress() {
const progressBar = document.getElementById('scroll-progress');
if (!progressBar) return;
window.addEventListener('scroll', () => {
const scrollTop = window.pageYOffset;
const docHeight = document.documentElement.scrollHeight - window.innerHeight;
const scrollPercent = (scrollTop / docHeight) * 100;
progressBar.style.width = scrollPercent + '%';
});
}
function setupFloatingNav() {
const floatingNav = document.getElementById('floating-nav');
if (!floatingNav) return;
const navItems = floatingNav.querySelectorAll('.nav-item');
navItems.forEach((item) => {
item.addEventListener('click', function(e) {
e.preventDefault();
const section = this.getAttribute('data-section');
scrollToSection(section);
navItems.forEach((nav) => nav.classList.remove('active'));
this.classList.add('active');
});
});
window.addEventListener('scroll', updateFloatingNav);
}
function setupNavigation() {
const navLinks = document.querySelectorAll('.nav-link, .mobile-nav-link');
navLinks.forEach((link) => {
link.addEventListener('click', function(e) {
e.preventDefault();
navLinks.forEach((l) => l.classList.remove('active'));
this.classList.add('active');
const targetId = this.getAttribute('href').substring(1);
scrollToSection(targetId);
});
});
window.addEventListener('scroll', updateActiveNav);
}
function scrollToSection(sectionId) {
const targetSection = document.getElementById(sectionId);
if (targetSection) {
const offsetTop = targetSection.offsetTop - 80;
window.scrollTo({
top: offsetTop,
behavior: 'smooth'
});
}
}
function updateFloatingNav() {
const sections = document.querySelectorAll('section[id]');
const navItems = document.querySelectorAll('.nav-item');
let current = '';
sections.forEach((section) => {
const sectionTop = section.offsetTop;
if (window.pageYOffset >= sectionTop - 150) {
current = section.getAttribute('id');
}
});
navItems.forEach((item) => {
item.classList.remove('active');
if (item.getAttribute('data-section') === current) {
item.classList.add('active');
}
});
}
function updateActiveNav() {
const sections = document.querySelectorAll('section[id]');
const navLinks = document.querySelectorAll('.nav-link, .mobile-nav-link');
let current = '';
sections.forEach((section) => {
const sectionTop = section.offsetTop;
if (window.pageYOffset >= sectionTop - 150) {
current = section.getAttribute('id');
}
});
navLinks.forEach((link) => {
link.classList.remove('active');
if (link.getAttribute('href').substring(1) === current) {
link.classList.add('active');
}
});
}
// ===== TYPING ANIMATION =====
function initializeTypingAnimation() {
const typedRole = document.getElementById("typed-role");
if (!typedRole) return;
const roles = [
"Web Developer",
"Web Penetration tester",
"Wordpress Developer",
"WebFlow Expert",
"Cyber Security Specialist",
"Laravel Expert"
];
let roleIndex = 0;
let charIndex = 0;
let deleting = false;
function type() {
const current = roles[roleIndex];
if (!deleting) {
typedRole.textContent = current.substring(0, charIndex + 1);
charIndex++;
if (charIndex === current.length) {
deleting = true;
setTimeout(type, 1500);
return;
}
} else {
if (charIndex > 0) {
typedRole.textContent = current.substring(0, charIndex - 1);
}
charIndex--;
if (charIndex === 0) {
deleting = false;
roleIndex = (roleIndex + 1) % roles.length;
}
}
setTimeout(type, deleting ? 60 : 120);
}
type();
}
// ===== SKILLS ANIMATION =====
function initializeSkillsAnimation() {
const skillSection = document.getElementById('skills');
const skillLines = document.querySelectorAll('.skill-line');
let animated = false;
function animateSkills() {
if (animated) return;
const sectionTop = skillSection.getBoundingClientRect().top;
const screenHeight = window.innerHeight;
if (sectionTop < screenHeight - 100) {
skillLines.forEach((line, index) => {
setTimeout(() => {
const bar = line.querySelector('.skill-bar');
const width = line.getAttribute('data-width');
const color = line.getAttribute('data-color');
bar.className = `skill-bar h-3 w-0 rounded-full bg-gradient-to-r ${color}`;
bar.style.transition = 'width 2s ease-in-out';
bar.style.width = width;
}, index * 500);
});
animated = true;
}
}
window.addEventListener('scroll', animateSkills);
animateSkills();
}
// ===== TECHNOLOGIES FILTER =====
function initializeTechnologiesFilter() {
let currentFilter = 'all';
let currentSearch = '';
window.filterTechnologies = function(category) {
currentFilter = category;
const techItems = document.querySelectorAll('.tech-item');
const filterBtns = document.querySelectorAll('.filter-btn');
const mobileFilter = document.getElementById('mobile-filter');
// Update desktop buttons
filterBtns.forEach(btn => {
btn.classList.remove('active', 'text-white', 'border', 'border-gray-500/50');
btn.classList.add('text-gray-300');
// Reset gradient backgrounds
btn.classList.remove('from-blue-600', 'to-blue-700', 'from-green-600', 'to-green-700', 'from-purple-600', 'to-purple-700', 'from-yellow-600', 'to-yellow-700', 'from-red-600', 'to-red-700');
btn.classList.add('from-gray-700', 'to-gray-800');
});
// Update mobile dropdown
if (mobileFilter) {
mobileFilter.value = category;
}
// Highlight active button
if (event && event.currentTarget.classList.contains('filter-btn')) {
const clickedButton = event.currentTarget;
clickedButton.classList.add('active', 'text-white', 'border', 'border-gray-500/50');
clickedButton.classList.remove('text-gray-300');
// Add specific gradient for active state
if (category === 'frontend') {
clickedButton.classList.add('from-blue-600', 'to-blue-700');
} else if (category === 'backend') {
clickedButton.classList.add('from-green-600', 'to-green-700');
} else if (category === 'mobile') {
clickedButton.classList.add('from-purple-600', 'to-purple-700');
} else if (category === 'db') {
clickedButton.classList.add('from-yellow-600', 'to-yellow-700');
} else if (category === 'tools') {
clickedButton.classList.add('from-red-600', 'to-red-700');
}
}
// Apply both filter and search
applyFilters();
}
window.searchTechnologies = function() {
currentSearch = document.getElementById('tech-search').value.toLowerCase();
applyFilters();
}
function applyFilters() {
const techItems = document.querySelectorAll('.tech-item');
techItems.forEach(item => {
const techName = item.querySelector('h4').textContent.toLowerCase();
const category = item.dataset.category;
const matchesFilter = currentFilter === 'all' || category === currentFilter;
const matchesSearch = currentSearch === '' || techName.includes(currentSearch);
if (matchesFilter && matchesSearch) {
item.style.display = 'block';
// Add animation when showing
item.style.animation = 'fadeInUp 0.5s ease-out';
} else {
item.style.display = 'none';
}
});
}
// Add search event listener
const searchInput = document.getElementById('tech-search');
if (searchInput) {
searchInput.addEventListener('input', window.searchTechnologies);
}
// Initialize with all technologies visible
applyFilters();
}
// ===== AOS INITIALIZATION =====
function initializeAOS() {
if (typeof AOS !== 'undefined') {
AOS.init({
duration: 1000,
once: true,
mirror: false
});
}
}