-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
361 lines (300 loc) · 10.4 KB
/
script.js
File metadata and controls
361 lines (300 loc) · 10.4 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
// B4DCATs Landing Page JavaScript
document.addEventListener('DOMContentLoaded', function() {
// Initialize all components
initNavigation();
initScrollAnimations();
initTerminalAnimation();
initSmoothScrolling();
initMobileMenu();
initTypewriterEffect();
initParallaxEffects();
});
// Navigation functionality
function initNavigation() {
const navbar = document.querySelector('.navbar');
const navLinks = document.querySelectorAll('.nav-link');
// Navbar background on scroll
window.addEventListener('scroll', () => {
if (window.scrollY > 50) {
navbar.style.background = 'rgba(10, 10, 10, 0.98)';
navbar.style.boxShadow = '0 2px 20px rgba(0, 0, 0, 0.3)';
} else {
navbar.style.background = 'rgba(10, 10, 10, 0.95)';
navbar.style.boxShadow = 'none';
}
});
// Active link highlighting
const sections = document.querySelectorAll('section[id]');
window.addEventListener('scroll', () => {
let current = '';
sections.forEach(section => {
const sectionTop = section.offsetTop;
const sectionHeight = section.clientHeight;
if (window.scrollY >= (sectionTop - 200)) {
current = section.getAttribute('id');
}
});
navLinks.forEach(link => {
link.classList.remove('active');
if (link.getAttribute('href') === `#${current}`) {
link.classList.add('active');
}
});
});
}
// Scroll animations
function initScrollAnimations() {
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('aos-animate');
}
});
}, observerOptions);
// Observe all elements with data-aos attribute
const animatedElements = document.querySelectorAll('[data-aos]');
animatedElements.forEach(el => observer.observe(el));
}
// Terminal animation
function initTerminalAnimation() {
const terminal = document.querySelector('.hero-terminal');
const typingElement = document.querySelector('.typing');
if (!typingElement) return;
const commands = [
'git status',
'npm install b4d-utils',
'b4d-chat --connect',
'b4d-infra deploy',
'echo "Welcome to B4DCATs!"'
];
let commandIndex = 0;
let charIndex = 0;
let isDeleting = false;
function typeCommand() {
const currentCommand = commands[commandIndex];
if (isDeleting) {
typingElement.textContent = currentCommand.substring(0, charIndex - 1);
charIndex--;
} else {
typingElement.textContent = currentCommand.substring(0, charIndex + 1);
charIndex++;
}
let typeSpeed = isDeleting ? 50 : 100;
if (!isDeleting && charIndex === currentCommand.length) {
typeSpeed = 2000; // Pause at end
isDeleting = true;
} else if (isDeleting && charIndex === 0) {
isDeleting = false;
commandIndex = (commandIndex + 1) % commands.length;
typeSpeed = 500; // Pause before next command
}
setTimeout(typeCommand, typeSpeed);
}
// Start typing animation after a delay
setTimeout(typeCommand, 2000);
}
// Smooth scrolling for navigation links
function initSmoothScrolling() {
const links = document.querySelectorAll('a[href^="#"]');
links.forEach(link => {
link.addEventListener('click', function(e) {
e.preventDefault();
const targetId = this.getAttribute('href');
const targetSection = document.querySelector(targetId);
if (targetSection) {
const offsetTop = targetSection.offsetTop - 70; // Account for fixed navbar
window.scrollTo({
top: offsetTop,
behavior: 'smooth'
});
}
});
});
}
// Mobile menu functionality
function initMobileMenu() {
const navToggle = document.querySelector('.nav-toggle');
const navLinks = document.querySelector('.nav-links');
if (!navToggle || !navLinks) return;
navToggle.addEventListener('click', () => {
navLinks.classList.toggle('active');
navToggle.classList.toggle('active');
});
// Close mobile menu when clicking on a link
const mobileLinks = navLinks.querySelectorAll('a');
mobileLinks.forEach(link => {
link.addEventListener('click', () => {
navLinks.classList.remove('active');
navToggle.classList.remove('active');
});
});
}
// Typewriter effect for hero title
function initTypewriterEffect() {
const titleElement = document.querySelector('.title-line');
if (!titleElement) return;
const text = titleElement.textContent;
titleElement.textContent = '';
let charIndex = 0;
function typeChar() {
if (charIndex < text.length) {
titleElement.textContent += text.charAt(charIndex);
charIndex++;
setTimeout(typeChar, 100);
}
}
// Start typing after page load
setTimeout(typeChar, 500);
}
// Parallax effects
function initParallaxEffects() {
const heroSection = document.querySelector('.hero');
const terminal = document.querySelector('.hero-terminal');
if (!heroSection || !terminal) return;
window.addEventListener('scroll', () => {
const scrolled = window.pageYOffset;
const rate = scrolled * -0.5;
if (scrolled < heroSection.offsetHeight) {
terminal.style.transform = `translateY(${rate}px)`;
}
});
}
// Button hover effects
document.addEventListener('DOMContentLoaded', function() {
const buttons = document.querySelectorAll('.btn');
buttons.forEach(button => {
button.addEventListener('mouseenter', function() {
this.style.transform = 'translateY(-2px) scale(1.02)';
});
button.addEventListener('mouseleave', function() {
this.style.transform = 'translateY(0) scale(1)';
});
});
});
// Card hover effects
document.addEventListener('DOMContentLoaded', function() {
const cards = document.querySelectorAll('.principle-card, .project-card, .contact-card');
cards.forEach(card => {
card.addEventListener('mouseenter', function() {
this.style.transform = 'translateY(-8px) scale(1.02)';
});
card.addEventListener('mouseleave', function() {
this.style.transform = 'translateY(0) scale(1)';
});
});
});
// Loading animation
window.addEventListener('load', function() {
document.body.classList.add('loaded');
// Animate hero elements on load
const heroElements = document.querySelectorAll('.hero-badge, .hero-title, .hero-description, .hero-cta');
heroElements.forEach((el, index) => {
setTimeout(() => {
el.style.opacity = '1';
el.style.transform = 'translateY(0)';
}, index * 200);
});
});
// Utility functions
function debounce(func, wait) {
let timeout;
return function executedFunction(...args) {
const later = () => {
clearTimeout(timeout);
func(...args);
};
clearTimeout(timeout);
timeout = setTimeout(later, wait);
};
}
// Performance optimization
const optimizedScrollHandler = debounce(() => {
// Scroll-based animations and effects
}, 16); // ~60fps
window.addEventListener('scroll', optimizedScrollHandler);
// Add CSS for mobile menu
const mobileMenuStyles = `
@media (max-width: 768px) {
.nav-links {
position: fixed;
top: 70px;
left: 0;
right: 0;
background: rgba(10, 10, 10, 0.98);
backdrop-filter: blur(10px);
flex-direction: column;
padding: 2rem;
transform: translateY(-100%);
opacity: 0;
transition: all 0.3s ease;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.nav-links.active {
transform: translateY(0);
opacity: 1;
}
.nav-toggle.active span:nth-child(1) {
transform: rotate(45deg) translate(5px, 5px);
}
.nav-toggle.active span:nth-child(2) {
opacity: 0;
}
.nav-toggle.active span:nth-child(3) {
transform: rotate(-45deg) translate(7px, -6px);
}
.language-switcher {
margin-left: 0;
padding-left: 0;
border-left: none;
margin-top: var(--spacing-lg);
padding-top: var(--spacing-lg);
border-top: 1px solid rgba(255, 255, 255, 0.2);
justify-content: center;
}
}
`;
// Inject mobile menu styles
const styleSheet = document.createElement('style');
styleSheet.textContent = mobileMenuStyles;
document.head.appendChild(styleSheet);
// Add loading animation styles
const loadingStyles = `
.hero-badge,
.hero-title,
.hero-description,
.hero-cta {
opacity: 0;
transform: translateY(30px);
transition: all 0.6s ease;
}
body.loaded .hero-badge,
body.loaded .hero-title,
body.loaded .hero-description,
body.loaded .hero-cta {
opacity: 1;
transform: translateY(0);
}
`;
const loadingStyleSheet = document.createElement('style');
loadingStyleSheet.textContent = loadingStyles;
document.head.appendChild(loadingStyleSheet);
// Console welcome message
console.log(`
%cB4DCATs Developer Community
%cWelcome to the underground! 🖤
%cJoin us in creating independent tools for digital infrastructure.
%cCLI-first approach • Underground aesthetics • Open source philosophy
%cGitHub: https://github.com/b4dcats
%cTelegram: https://t.me/b4dcats
`,
'color: #00ff41; font-size: 24px; font-weight: bold; font-family: monospace;',
'color: #ff006e; font-size: 16px; font-weight: bold;',
'color: #00d4ff; font-size: 14px;',
'color: #ffffff; font-size: 12px;',
'color: #00ff41; font-size: 12px;',
'color: #00d4ff; font-size: 12px;'
);