Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
469 lines (410 loc) · 17.1 KB
/
Copy pathscript.js
File metadata and controls
469 lines (410 loc) · 17.1 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
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
/* =============================================
PALORANT — Script
============================================= */
document.addEventListener('DOMContentLoaded', () => {
// ─── Cursor Glow ───
const glow = document.getElementById('cursor-glow');
if (glow) {
document.addEventListener('mousemove', (e) => {
glow.style.left = e.clientX + 'px';
glow.style.top = e.clientY + 'px';
});
}
// ─── Navbar Scroll Effect ───
const navbar = document.getElementById('navbar');
if (navbar) {
window.addEventListener('scroll', () => {
navbar.classList.toggle('scrolled', window.scrollY > 50);
});
// Initial check
if (window.scrollY > 50) navbar.classList.add('scrolled');
}
// ─── Hamburger Menu ───
const hamburger = document.getElementById('hamburger');
const navLinks = document.getElementById('navbar-links');
if (hamburger && navLinks) {
hamburger.addEventListener('click', () => {
hamburger.classList.toggle('active');
navLinks.classList.toggle('open');
});
// Close on link click
navLinks.querySelectorAll('a').forEach(link => {
link.addEventListener('click', () => {
hamburger.classList.remove('active');
navLinks.classList.remove('open');
});
});
}
// ─── Scroll Reveal (IntersectionObserver) ───
const revealElements = document.querySelectorAll('.reveal, .reveal-left, .reveal-right, .stagger-children');
if (revealElements.length > 0) {
const revealObserver = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
revealObserver.unobserve(entry.target);
}
});
}, { threshold: 0.15, rootMargin: '0px 0px -40px 0px' });
revealElements.forEach(el => revealObserver.observe(el));
}
// ─── Stats Counter Animation ───
const statNumbers = document.querySelectorAll('.stat-number[data-target]');
if (statNumbers.length > 0) {
const counterObserver = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
const el = entry.target;
const target = parseInt(el.getAttribute('data-target'));
animateCounter(el, target);
counterObserver.unobserve(el);
}
});
}, { threshold: 0.5 });
statNumbers.forEach(el => counterObserver.observe(el));
}
function animateCounter(el, target) {
let current = 0;
const duration = 1500;
const step = target / (duration / 16);
const timer = setInterval(() => {
current += step;
if (current >= target) {
current = target;
clearInterval(timer);
}
el.textContent = Math.round(current) + '+';
}, 16);
}
// ─── Agent Modal ───
const agentModal = document.getElementById('agent-modal');
const modalName = document.getElementById('agent-name');
const modalRole = document.getElementById('agent-role');
const modalDesc = document.getElementById('agent-desc');
const closeModal = document.getElementById('close-detail');
document.querySelectorAll('.view-details-btn').forEach(btn => {
btn.addEventListener('click', (e) => {
const card = e.target.closest('.agent-card');
if (!card || !agentModal) return;
modalName.textContent = card.dataset.name;
modalRole.textContent = card.dataset.role;
modalDesc.textContent = card.dataset.desc;
agentModal.classList.add('active');
document.body.style.overflow = 'hidden';
});
});
if (closeModal && agentModal) {
closeModal.addEventListener('click', () => {
agentModal.classList.remove('active');
document.body.style.overflow = '';
});
agentModal.addEventListener('click', (e) => {
if (e.target === agentModal) {
agentModal.classList.remove('active');
document.body.style.overflow = '';
}
});
}
// ─── Agent Role Filter & Stagger Animation ───
const filterBtns = document.querySelectorAll('#role-filters button');
const agentCards = document.querySelectorAll('#agents-grid .agent-card');
// Function to animate cards with staggered delay
const animateCards = (cards) => {
cards.forEach((card, index) => {
card.classList.remove('card-enter');
// Force reflow to restart animation
void card.offsetWidth;
card.style.animationDelay = `${index * 0.1}s`;
card.classList.add('card-enter');
});
};
if (filterBtns.length > 0 && agentCards.length > 0) {
// Initial animation on load
animateCards(Array.from(agentCards));
filterBtns.forEach(btn => {
btn.addEventListener('click', () => {
// Update active button
filterBtns.forEach(b => b.classList.remove('active'));
btn.classList.add('active');
const role = btn.dataset.role;
const visibleCards = [];
agentCards.forEach(card => {
if (role === 'all' || card.dataset.role === role) {
card.style.display = '';
visibleCards.push(card);
} else {
card.style.display = 'none';
card.classList.remove('card-enter');
}
});
// Trigger staggered animation for visible cards
animateCards(visibleCards);
});
});
}
// ─── Map Thumbnails ───
const mapThumbs = document.querySelectorAll('#map-thumbnails .map-thumb');
const mapMainImg = document.getElementById('map-main-img');
const mapName = document.getElementById('map-name');
const mapType = document.getElementById('map-type');
const mapDesc = document.getElementById('map-desc');
if (mapThumbs.length > 0 && mapMainImg) {
mapThumbs.forEach(thumb => {
thumb.addEventListener('click', () => {
// Update active state
mapThumbs.forEach(t => t.classList.remove('active'));
thumb.classList.add('active');
// Trigger Glitch Animation
mapMainImg.classList.remove('map-glitch');
void mapMainImg.offsetWidth; // Reflow
mapMainImg.classList.add('map-glitch');
// Update main image and info — use HD splash URL if available
const splashUrl = thumb.dataset.splash;
const img = thumb.querySelector('img');
// Small delay to let the glitch peak before changing image
setTimeout(() => {
mapMainImg.src = splashUrl || img.src;
if (mapName) mapName.textContent = thumb.dataset.name;
if (mapType) mapType.textContent = thumb.dataset.type;
if (mapDesc) mapDesc.textContent = thumb.dataset.desc;
}, 150);
});
});
}
// ─── Bug Report Form ───
const bugForm = document.getElementById('bug-form');
const formContainer = document.getElementById('form-container');
const formSuccess = document.getElementById('form-success');
const submitAnother = document.getElementById('submit-another');
if (bugForm) {
bugForm.addEventListener('submit', (e) => {
e.preventDefault();
clearErrors();
let valid = true;
// Username validation
const username = document.getElementById('username');
if (username && username.value.trim().length < 5) {
showError('username');
valid = false;
}
// Email validation
const email = document.getElementById('email');
if (email) {
const emailVal = email.value.trim();
if (!emailVal || !emailVal.includes('@') || !emailVal.includes('.')) {
showError('email');
valid = false;
}
}
// Server validation
const server = document.getElementById('server');
if (server && !server.value) {
showError('server');
valid = false;
}
// Priority validation
const priority = document.getElementById('priority');
if (priority && !priority.value) {
showError('priority');
valid = false;
}
// Description validation
const description = document.getElementById('description');
if (description && description.value.trim().length < 10) {
showError('description');
valid = false;
}
// Follow-up checkbox
const followup = document.getElementById('followup');
if (followup && !followup.checked) {
showError('followup');
valid = false;
}
if (valid) {
// Show success
if (formContainer) formContainer.style.display = 'none';
if (formSuccess) formSuccess.classList.add('show');
bugForm.reset();
}
});
}
if (submitAnother) {
submitAnother.addEventListener('click', () => {
if (formContainer) formContainer.style.display = '';
if (formSuccess) formSuccess.classList.remove('show');
});
}
function showError(fieldId) {
const group = document.getElementById(fieldId)?.closest('.form-group');
if (group) group.classList.add('error');
}
function clearErrors() {
document.querySelectorAll('.form-group.error').forEach(g => g.classList.remove('error'));
}
// ─── Add fadeIn keyframes dynamically ───
if (!document.getElementById('dynamic-keyframes')) {
const style = document.createElement('style');
style.id = 'dynamic-keyframes';
style.textContent = `
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
`;
document.head.appendChild(style);
}
// ─── Sova 3D Interactive Effect ───
const sovaContainer = document.getElementById('sova-3d-container');
const sovaCanvas = document.getElementById('sova-particles');
if (sovaContainer && sovaCanvas) {
const ctx = sovaCanvas.getContext('2d');
let particles = [];
let mouseInContainer = false;
let mouseX = 0.5;
let mouseY = 0.5;
let animId = null;
// Resize canvas to match container
function resizeCanvas() {
const rect = sovaContainer.getBoundingClientRect();
sovaCanvas.width = rect.width;
sovaCanvas.height = rect.height;
}
resizeCanvas();
window.addEventListener('resize', resizeCanvas);
// Particle class
class EnergyParticle {
constructor() {
this.reset();
}
reset() {
this.x = Math.random() * sovaCanvas.width;
this.y = Math.random() * sovaCanvas.height;
this.size = Math.random() * 3 + 1;
this.speedX = (Math.random() - 0.5) * 0.8;
this.speedY = (Math.random() - 0.5) * 0.8;
this.life = Math.random() * 100 + 60;
this.maxLife = this.life;
this.hue = Math.random() > 0.5 ? 220 : 270; // blue or violet
this.alpha = 0;
}
update() {
this.life--;
if (this.life <= 0) this.reset();
// Fade in/out
const lifeRatio = this.life / this.maxLife;
if (lifeRatio > 0.8) {
this.alpha = (1 - lifeRatio) * 5; // fade in
} else if (lifeRatio < 0.2) {
this.alpha = lifeRatio * 5; // fade out
} else {
this.alpha = 0.7 + Math.sin(Date.now() * 0.005 + this.x) * 0.3;
}
// Mouse attraction when hovering
if (mouseInContainer) {
const mx = mouseX * sovaCanvas.width;
const my = mouseY * sovaCanvas.height;
const dx = mx - this.x;
const dy = my - this.y;
const dist = Math.sqrt(dx * dx + dy * dy);
if (dist < 150) {
this.speedX += dx * 0.0003;
this.speedY += dy * 0.0003;
}
}
this.x += this.speedX;
this.y += this.speedY;
// Damping
this.speedX *= 0.99;
this.speedY *= 0.99;
// Wrap around
if (this.x < 0) this.x = sovaCanvas.width;
if (this.x > sovaCanvas.width) this.x = 0;
if (this.y < 0) this.y = sovaCanvas.height;
if (this.y > sovaCanvas.height) this.y = 0;
}
draw(ctx) {
ctx.save();
ctx.globalAlpha = this.alpha * 0.6;
ctx.fillStyle = `hsl(${this.hue}, 80%, 65%)`;
ctx.shadowColor = `hsl(${this.hue}, 90%, 60%)`;
ctx.shadowBlur = 12;
ctx.beginPath();
ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
ctx.fill();
ctx.restore();
}
}
// Create particles
for (let i = 0; i < 40; i++) {
particles.push(new EnergyParticle());
}
// Draw connection lines between nearby particles
function drawConnections() {
for (let i = 0; i < particles.length; i++) {
for (let j = i + 1; j < particles.length; j++) {
const dx = particles[i].x - particles[j].x;
const dy = particles[i].y - particles[j].y;
const dist = Math.sqrt(dx * dx + dy * dy);
if (dist < 80) {
ctx.save();
ctx.globalAlpha = (1 - dist / 80) * 0.15;
ctx.strokeStyle = 'rgba(139, 92, 246, 0.5)';
ctx.lineWidth = 0.5;
ctx.beginPath();
ctx.moveTo(particles[i].x, particles[i].y);
ctx.lineTo(particles[j].x, particles[j].y);
ctx.stroke();
ctx.restore();
}
}
}
}
// Animation loop
function animateParticles() {
ctx.clearRect(0, 0, sovaCanvas.width, sovaCanvas.height);
particles.forEach(p => {
p.update();
p.draw(ctx);
});
drawConnections();
animId = requestAnimationFrame(animateParticles);
}
// Start animation when section is visible
const sovaSection = sovaContainer.closest('.about-section');
if (sovaSection) {
const sovaObserver = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
resizeCanvas();
if (!animId) animateParticles();
} else {
if (animId) { cancelAnimationFrame(animId); animId = null; }
}
});
}, { threshold: 0.1 });
sovaObserver.observe(sovaSection);
} else {
animateParticles();
}
// ─── 3D Tilt on Mouse Move ───
sovaContainer.addEventListener('mousemove', (e) => {
const rect = sovaContainer.getBoundingClientRect();
mouseX = (e.clientX - rect.left) / rect.width;
mouseY = (e.clientY - rect.top) / rect.height;
mouseInContainer = true;
// Tilt calculation: -15deg to +15deg
const tiltX = (mouseY - 0.5) * -20;
const tiltY = (mouseX - 0.5) * 20;
sovaContainer.style.transform = `rotateX(${tiltX}deg) rotateY(${tiltY}deg)`;
});
sovaContainer.addEventListener('mouseenter', () => {
mouseInContainer = true;
sovaContainer.style.transition = 'transform 0.1s ease-out';
});
sovaContainer.addEventListener('mouseleave', () => {
mouseInContainer = false;
sovaContainer.style.transition = 'transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1)';
sovaContainer.style.transform = 'rotateX(0deg) rotateY(0deg)';
});
}
});