File size: 11,039 Bytes
7d4ca9d 8281a77 7d4ca9d 8281a77 7d4ca9d 510e5a2 7d4ca9d 510e5a2 7d4ca9d 510e5a2 7d4ca9d 510e5a2 7d4ca9d 8281a77 7d4ca9d 510e5a2 7d4ca9d 510e5a2 7d4ca9d 510e5a2 7d4ca9d 510e5a2 7d4ca9d 8281a77 7d4ca9d 510e5a2 7d4ca9d 8281a77 7d4ca9d 8281a77 7d4ca9d 510e5a2 7d4ca9d 8281a77 7d4ca9d 8281a77 7d4ca9d d6a54fc 7d4ca9d 09310ed 7d4ca9d 09310ed 7d4ca9d 8281a77 7d4ca9d 8281a77 7d4ca9d 8281a77 7d4ca9d 8281a77 7d4ca9d 8281a77 7d4ca9d 8281a77 7d4ca9d 8281a77 7d4ca9d 8281a77 7d4ca9d 8281a77 7d4ca9d 8281a77 7d4ca9d 8281a77 7d4ca9d 8281a77 7d4ca9d 8281a77 7d4ca9d 8281a77 7d4ca9d | 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 | // Only run if we're on a page with the required elements
(function() {
'use strict';
// Mouse glow effect - only if element exists
const mouseGlow = document.getElementById('mouseGlow');
if (mouseGlow) {
document.addEventListener('mousemove', (e) => {
if (mouseGlow) {
mouseGlow.style.left = e.clientX + 'px';
mouseGlow.style.top = e.clientY + 'px';
}
});
}
// Text scramble effect - only initialize on pages with the element
const scrambleEl = document.getElementById('scrambleText');
if (scrambleEl && typeof scrambleEl.innerText === 'string') {
class TextScramble {
constructor(el) {
if (!el) throw new Error('Element required');
this.el = el;
this.chars = '!<>-_\\/[]{}—=+*^?#________';
this.update = this.update.bind(this);
this.frame = 0;
this.queue = [];
this.frameRequest = null;
this.resolve = null;
}
setText(newText) {
if (!this.el || typeof newText !== 'string') return Promise.resolve();
const oldText = this.el.innerText || '';
const length = Math.max(oldText.length, newText.length);
// Reset queue
this.queue = [];
for (let i = 0; i < length; i++) {
const from = oldText[i] || '';
const to = newText[i] || '';
const start = Math.floor(Math.random() * 40);
const end = start + Math.floor(Math.random() * 40);
this.queue.push({ from, to, start, end, char: '' });
}
if (this.frameRequest) {
cancelAnimationFrame(this.frameRequest);
}
this.frame = 0;
return new Promise((resolve) => {
this.resolve = resolve;
this.update();
});
}
update() {
if (!this.el || !this.queue || !Array.isArray(this.queue)) return;
let output = '';
let complete = 0;
for (let i = 0; i < this.queue.length; i++) {
const item = this.queue[i];
if (!item) continue;
const from = item.from || '';
const to = item.to || '';
const start = item.start || 0;
const end = item.end || 0;
let char = item.char || '';
if (this.frame >= end) {
complete++;
output += to;
} else if (this.frame >= start) {
if (!char || Math.random() < 0.28) {
char = this.randomChar() || '';
this.queue[i].char = char;
}
output += char;
} else {
output += from;
}
}
// Only set text if we have valid string content
if (typeof output === 'string') {
this.el.innerText = output;
}
if (complete === this.queue.length) {
if (this.resolve) this.resolve();
} else {
this.frameRequest = requestAnimationFrame(this.update);
this.frame++;
}
}
randomChar() {
if (!this.chars || this.chars.length === 0) return '';
return this.chars[Math.floor(Math.random() * this.chars.length)];
}
}
// Initialize scramble
const phrases = ['FUTURE', 'INTELLIGENCE', 'POSSIBILITIES', 'EVOLUTION', 'TOMORROW'];
let counter = 0;
try {
const fx = new TextScramble(scrambleEl);
const next = () => {
if (!fx.el) return;
const nextPhrase = phrases[counter];
if (typeof nextPhrase === 'string') {
fx.setText(nextPhrase).then(() => {
setTimeout(next, 3000);
});
}
counter = (counter + 1) % phrases.length;
};
setTimeout(next, 2000);
} catch (e) {
console.error('Scramble effect error:', e);
}
}
// Mobile menu toggle - only if both elements exist
const mobileMenuBtn = document.getElementById('mobileMenuBtn');
const mobileMenu = document.getElementById('mobileMenu');
if (mobileMenuBtn && mobileMenu) {
mobileMenuBtn.addEventListener('click', () => {
mobileMenu.classList.toggle('hidden');
});
// Close mobile menu when clicking links
mobileMenu.querySelectorAll('a').forEach(link => {
link.addEventListener('click', () => {
mobileMenu.classList.add('hidden');
});
});
}
// Newsletter form handling
const newsletterForm = document.getElementById('newsletterForm');
const submitBtn = document.getElementById('submitBtn');
if (newsletterForm && submitBtn) {
newsletterForm.addEventListener('submit', (e) => {
e.preventDefault();
const originalContent = submitBtn.innerHTML;
submitBtn.innerHTML = '<span class="animate-spin inline-block w-4 h-4 border-2 border-white border-t-transparent rounded-full mr-2"></span>Subscribing...';
submitBtn.disabled = true;
setTimeout(() => {
submitBtn.innerHTML = '<i data-lucide="check" class="w-4 h-4 mr-2"></i>Subscribed!';
submitBtn.classList.remove('btn-primary');
submitBtn.classList.add('bg-green-500');
if (typeof lucide !== 'undefined') {
lucide.createIcons();
}
setTimeout(() => {
submitBtn.innerHTML = originalContent;
submitBtn.classList.add('btn-primary');
submitBtn.classList.remove('bg-green-500');
submitBtn.disabled = false;
newsletterForm.reset();
if (typeof lucide !== 'undefined') {
lucide.createIcons();
}
}, 3000);
}, 1500);
});
}
// Counter animation - only if elements exist
const counters = document.querySelectorAll('.counter');
if (counters.length > 0) {
const animateCounter = (counter) => {
const target = parseInt(counter.getAttribute('data-target'));
if (isNaN(target)) return;
const duration = 2000;
const increment = target / (duration / 16);
let current = 0;
const updateCounter = () => {
current += increment;
if (current < target) {
counter.innerText = Math.floor(current).toLocaleString();
requestAnimationFrame(updateCounter);
} else {
counter.innerText = target.toLocaleString() + (target === 98 ? '%' : '+');
}
};
updateCounter();
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting && entry.target.classList.contains('counter')) {
animateCounter(entry.target);
observer.unobserve(entry.target);
}
});
}, { threshold: 0.5 });
counters.forEach(counter => observer.observe(counter));
}
// Smooth scroll for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
const href = this.getAttribute('href');
if (!href || href === '#') return;
const target = document.querySelector(href);
if (target) {
e.preventDefault();
target.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
// Close mobile menu if open
if (mobileMenu && !mobileMenu.classList.contains('hidden')) {
mobileMenu.classList.add('hidden');
}
}
});
});
// Scroll reveal animation
const revealElements = document.querySelectorAll('.resource-card');
if (revealElements.length > 0) {
const revealObserver = new IntersectionObserver((entries) => {
entries.forEach((entry, index) => {
if (entry.isIntersecting) {
setTimeout(() => {
entry.target.style.opacity = '1';
entry.target.style.transform = 'translateY(0)';
}, index * 100);
revealObserver.unobserve(entry.target);
}
});
}, { threshold: 0.1 });
revealElements.forEach((el) => {
el.style.opacity = '0';
el.style.transform = 'translateY(20px)';
el.style.transition = 'all 0.6s ease-out';
revealObserver.observe(el);
});
}
// Parallax effect for hero section - only if elements exist
const parallaxElements = document.querySelectorAll('.animate-float');
if (parallaxElements.length > 0) {
window.addEventListener('scroll', () => {
const scrolled = window.pageYOffset;
parallaxElements.forEach((el, index) => {
const speed = 0.5 + (index * 0.1);
el.style.transform = `translateY(${scrolled * speed}px)`;
});
});
}
// Add glow effect to cards on mouse move
document.querySelectorAll('.glass-card').forEach(card => {
card.addEventListener('mousemove', (e) => {
const rect = card.getBoundingClientRect();
const x = e.clientX - rect.left;
const y = e.clientY - rect.top;
card.style.background = `radial-gradient(circle at ${x}px ${y}px, rgba(139, 92, 246, 0.1), rgba(19, 19, 31, 0.6))`;
});
card.addEventListener('mouseleave', () => {
card.style.background = 'rgba(19, 19, 31, 0.6)';
});
});
})(); |