Spaces:
Running
Running
File size: 15,016 Bytes
327b6f3 | 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 | /* ============================================
KBdmly Community - 2007 Retro Web JavaScript
Interactive Features & Animations
============================================ */
// ============================================
// HIT COUNTER - Classic 2007 Feature!
// ============================================
function initCounter() {
const counterEl = document.getElementById('counter');
if (!counterEl) return;
// Get or initialize counter
let count = localStorage.getItem('siteVisitorCount');
if (!count) {
// First visit ever - set a base number to look popular
count = Math.floor(Math.random() * 5000) + 10000; // Start between 10,000-15,000
localStorage.setItem('siteVisitorCount', count);
} else {
count = parseInt(count) + 1;
localStorage.setItem('siteVisitorCount', count);
}
// Animate counter counting up
animateCounter(counterEl, 0, count, 2000);
}
function animateCounter(element, start, end, duration) {
const startTime = performance.now();
function update(currentTime) {
const elapsed = currentTime - startTime;
const progress = Math.min(elapsed / duration, 1);
// Easing function for smooth animation
const easeOut = 1 - Math.pow(1 - progress, 3);
const current = Math.floor(start + (end - start) * easeOut);
element.textContent = current.toString().padStart(6, '0');
if (progress < 1) {
requestAnimationFrame(update);
}
}
requestAnimationFrame(update);
}
// ============================================
// SPARKLE CURSOR TRAIL
// ============================================
function initSparkles() {
const sparklesContainer = document.getElementById('sparkles');
if (!sparklesContainer) return;
const sparkleEmojis = ['β¨', 'β', 'π«', 'π', 'β¦', 'β
', 'β'];
document.addEventListener('mousemove', (e) => {
// Only create sparkle occasionally for performance
if (Math.random() > 0.85) {
createSparkle(e.clientX, e.clientY, sparklesContainer, sparkleEmojis);
}
});
}
function createSparkle(x, y, container, emojis) {
const sparkle = document.createElement('span');
sparkle.className = 'sparkle';
sparkle.textContent = emojis[Math.floor(Math.random() * emojis.length)];
sparkle.style.left = x + 'px';
sparkle.style.top = y + 'px';
container.appendChild(sparkle);
// Remove after animation
setTimeout(() => {
sparkle.remove();
}, 1000);
}
// ============================================
// SHOUTBOX / GUESTBOOK FUNCTIONALITY
// ============================================
function initShoutbox() {
const form = document.getElementById('shoutForm');
const messagesContainer = document.getElementById('messagesContainer');
if (!form || !messagesContainer) return;
// Load saved messages
loadMessages(messagesContainer);
form.addEventListener('submit', (e) => {
e.preventDefault();
const nameInput = document.getElementById('msgName');
const textInput = document.getElementById('msgText');
const name = nameInput.value.trim();
const text = textInput.value.trim();
if (!name || !text) return;
// Create new message
const message = {
name: name,
text: text,
time: new Date().toLocaleTimeString('id-ID', { hour: '2-digit', minute: '2-digit' }),
timestamp: Date.now()
};
// Save to localStorage
saveMessage(message);
// Add to DOM
addMessageToDOM(message, messagesContainer);
// Clear form
textInput.value = '';
// Scroll to bottom
messagesContainer.scrollTop = messagesContainer.scrollHeight;
// Show success effect
showPostSuccess(form);
});
}
function saveMessage(message) {
let messages = JSON.parse(localStorage.getItem('shoutboxMessages') || '[]');
messages.push(message);
// Keep only last 50 messages
if (messages.length > 50) {
messages = messages.slice(-50);
}
localStorage.setItem('shoutboxMessages', JSON.stringify(messages));
}
function loadMessages(container) {
const messages = JSON.parse(localStorage.getItem('shoutboxMessages') || '[]');
// Sort by timestamp
messages.sort((a, b) => a.timestamp - b.timestamp);
messages.forEach(msg => addMessageToDOM(msg, container));
}
function addMessageToDOM(message, container) {
const messageDiv = document.createElement('div');
messageDiv.className = 'message';
// Random color class for variety
const colors = ['member-name', 'new-member-name'];
const randomColor = colors[Math.floor(Math.random() * colors.length)];
messageDiv.innerHTML = `
<span class="msg-name ${randomColor}">${escapeHtml(message.name)}</span>
<span class="msg-time">${message.time}</span>
<p class="msg-text">${escapeHtml(message.text)}</p>
`;
container.appendChild(messageDiv);
}
function escapeHtml(text) {
const div = document.createElement('div');
div.textContent = text;
return div.innerHTML;
}
function showPostSuccess(form) {
const btn = form.querySelector('.submit-btn');
const originalText = btn.innerHTML;
btn.innerHTML = 'β
Posted!';
btn.style.background = 'linear-gradient(180deg, #00cc00 0%, #009900 100%)';
setTimeout(() => {
btn.innerHTML = originalText;
btn.style.background = '';
}, 1500);
}
// ============================================
// BACK TO TOP BUTTON
// ============================================
function initBackToTop() {
const btn = document.getElementById('backToTop');
if (!btn) return;
window.addEventListener('scroll', () => {
if (window.scrollY > 300) {
btn.classList.add('visible');
} else {
btn.classList.remove('visible');
}
});
btn.addEventListener('click', () => {
window.scrollTo({
top: 0,
behavior: 'smooth'
});
});
}
// ============================================
// SMOOTH SCROLL FOR NAV LINKS
// ============================================
function initSmoothScroll() {
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
const targetId = this.getAttribute('href');
const targetElement = document.querySelector(targetId);
if (targetElement) {
targetElement.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
// Update active nav state
document.querySelectorAll('.nav-btn').forEach(btn => btn.classList.remove('active'));
this.classList.add('active');
}
});
});
}
// ============================================
// MEMBER COUNT ANIMATION
// ============================================
function initMemberCountAnimation() {
const memberCountEl = document.getElementById('memberCount');
if (!memberCountEl) return;
const targetCount = 256 + Math.floor(Math.random() * 50); // Base + random
// Animate on scroll into view
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
animateNumber(memberCountEl, 0, targetCount, 1500);
observer.unobserve(entry.target);
}
});
}, { threshold: 0.5 });
observer.observe(memberCountEl);
}
function animateNumber(element, start, end, duration) {
const startTime = performance.now();
function update(currentTime) {
const elapsed = currentTime - startTime;
const progress = Math.min(elapsed / duration, 1);
const easeOut = 1 - Math.pow(1 - progress, 3);
const current = Math.floor(start + (end - start) * easeOut);
element.textContent = current;
if (progress < 1) {
requestAnimationFrame(update);
}
}
requestAnimationFrame(update);
}
// ============================================
// RANDOM MEMBER STATUS CHANGES
// ============================================
function initMemberStatusSimulation() {
const statuses = document.querySelectorAll('.member-status');
setInterval(() => {
statuses.forEach(status => {
if (Math.random() > 0.7) { // 30% chance to change
const options = ['online', 'away', 'offline'];
const weights = [0.5, 0.3, 0.2]; // More likely online
let random = Math.random();
let newIndex = 0;
for (let i = 0; i < weights.length; i++) {
random -= weights[i];
if (random <= 0) {
newIndex = i;
break;
}
}
status.className = 'member-status ' + options[newIndex];
status.textContent = options[newIndex] === 'online' ? 'β Online' :
options[newIndex] === 'away' ? 'β Away' : 'β Offline';
}
});
}, 5000); // Check every 5 seconds
}
// ============================================
// EASTER EGG - KONAMI CODE
// ============================================
function initEasterEgg() {
const konamiCode = ['ArrowUp', 'ArrowUp', 'ArrowDown', 'ArrowDown',
'ArrowLeft', 'ArrowRight', 'ArrowLeft', 'ArrowRight',
'b', 'a'];
let konamiIndex = 0;
document.addEventListener('keydown', (e) => {
if (e.key === konamiCode[konamiIndex]) {
konamiIndex++;
if (konamiIndex === konamiCode.length) {
activateEasterEgg();
konamiIndex = 0;
}
} else {
konamiIndex = 0;
}
});
}
function activateEasterEgg() {
// Rainbow mode!
document.body.style.animation = 'rainbow-bg 2s linear infinite';
// Add rainbow keyframes dynamically
const style = document.createElement('style');
style.textContent = `
@keyframes rainbow-bg {
0% { filter: hue-rotate(0deg); }
100% { filter: hue-rotate(360deg); }
}
`;
document.head.appendChild(style);
// Show alert in retro style
setTimeout(() => {
alert('π SECRET UNLOCKED! π\n\nYou found the Konami Code!\nYou are a TRUE 2007 web veteran!\n\nβ
ββ
CONGRATULATIONS! β
ββ
');
}, 100);
// Remove after 10 seconds
setTimeout(() => {
document.body.style.animation = '';
}, 10000);
}
// ============================================
// TYPING EFFECT FOR TAGLINE (Optional)
// ============================================
function initTypingEffect() {
const tagline = document.querySelector('.tagline');
if (!tagline) return;
const originalText = tagline.textContent;
tagline.textContent = '';
let charIndex = 0;
// Start typing after a short delay
setTimeout(() => {
typeCharacter();
}, 1000);
function typeCharacter() {
if (charIndex < originalText.length) {
tagline.textContent += originalText.charAt(charIndex);
charIndex++;
setTimeout(typeCharacter, 80);
}
}
}
// ============================================
// PARALLAX EFFECT ON HEADER
// ============================================
function initParallax() {
const header = document.querySelector('.logo-section');
if (!header) return;
window.addEventListener('scroll', () => {
const scrolled = window.scrollY;
if (scrolled < 400) {
header.style.backgroundPositionY = scrolled * 0.5 + 'px';
}
});
}
// ============================================
// INITIALIZE EVERYTHING ON DOM LOAD
// ============================================
document.addEventListener('DOMContentLoaded', () => {
console.log('%cβ¦ KBdmly Community Website β¦', 'color: #00ffff; font-size: 20px; font-weight: bold; text-shadow: 0 0 10px #00ffff;');
console.log('%cWelcome, fellow time traveler from 2007! π', 'color: #ff00ff; font-size: 14px;');
console.log('%cTry the Konami Code for a surprise! β¬οΈβ¬οΈβ¬οΈβ¬οΈβ¬
οΈβ‘οΈβ¬
οΈβ‘οΈBA', 'color: #ffcc00; font-size: 12px;');
// Initialize all features
initCounter();
initSparkles();
initShoutbox();
initBackToTop();
initSmoothScroll();
initMemberCountAnimation();
initMemberStatusSimulation();
initEasterEgg();
initTypingEffect();
initParallax();
// Add loaded class for entrance animations
document.body.classList.add('loaded');
});
// ============================================
// ADDITIONAL VISUAL EFFECTS
// ============================================
// Randomly twinkle stars in title
function initStarTwinkle() {
const stars = document.querySelectorAll('.star');
setInterval(() => {
stars.forEach(star => {
if (Math.random() > 0.7) {
star.style.transform = `scale(${1 + Math.random() * 0.5})`;
star.style.color = ['#ffcc00', '#ff6600', '#ff00ff', '#00ffff'][Math.floor(Math.random() * 4)];
setTimeout(() => {
star.style.transform = '';
star.style.color = '#ffcc00';
}, 300);
}
});
}, 800);
}
// Initialize star twinkle after load
setTimeout(initStarTwinkle, 2000);
// Hover sound effect simulation (visual feedback)
document.querySelectorAll('.nav-btn, .glossy-button, .big-join-btn').forEach(btn => {
btn.addEventListener('mouseenter', () => {
btn.style.transition = 'all 0.1s';
});
});
// Console welcome message with ASCII art
console.log(`
%cββββββββββββββββββββββββββββββββββββββββ
β β
β β¦ KBdmly Community β¦ β
β β
β ~* Est. 2024 *~ β
β β
β Welcome to our retro website! β
β β
ββββββββββββββββββββββββββββββββββββββββ
`, 'color: #00ff00; background: #001100; padding: 10px; font-family: monospace;');
|