|
1 | | -/** |
2 | | - * THEME LOGIC: Light -> Dark -> Random |
3 | | - */ |
4 | 1 | function toggleTheme() { |
5 | 2 | const currentTheme = localStorage.getItem('theme') || 'light'; |
6 | 3 | let nextTheme; |
@@ -48,17 +45,89 @@ function updateIcon(theme) { |
48 | 45 | else icon.innerText = '☀️'; // Next is Light |
49 | 46 | } |
50 | 47 |
|
| 48 | +// --- EASTER EGG STATE --- |
| 49 | +let surpriseClickCount = 0; |
| 50 | +let matrixActive = false; |
| 51 | + |
51 | 52 | /** |
52 | | - * SURPRISE ME LOGIC |
| 53 | + * Updated Surprise Me Logic with Counter |
53 | 54 | */ |
54 | 55 | function scrollToRandomUser() { |
| 56 | + // Increment Easter Egg counter |
| 57 | + surpriseClickCount++; |
| 58 | + if (surpriseClickCount === 5) { |
| 59 | + initMatrix(); |
| 60 | + } |
| 61 | + |
55 | 62 | const cards = document.querySelectorAll('.user-card'); |
| 63 | + if (cards.length === 0) return; |
| 64 | + |
56 | 65 | cards.forEach(c => c.classList.remove('highlight-pulse')); |
57 | 66 | const randomCard = cards[Math.floor(Math.random() * cards.length)]; |
58 | 67 | randomCard.scrollIntoView({ behavior: 'smooth', block: 'start' }); |
59 | 68 | randomCard.classList.add('highlight-pulse'); |
60 | 69 | setTimeout(() => randomCard.classList.remove('highlight-pulse'), 3500); |
61 | 70 | } |
62 | 71 |
|
| 72 | +// --- THE MATRIX ENGINE --- |
| 73 | +function initMatrix() { |
| 74 | + matrixActive = true; |
| 75 | + const overlay = document.getElementById('matrix-overlay'); |
| 76 | + const canvas = document.getElementById('matrix-canvas'); |
| 77 | + const ctx = canvas.getContext('2d'); |
| 78 | + |
| 79 | + overlay.classList.remove('hidden'); |
| 80 | + |
| 81 | + // Set canvas to full screen |
| 82 | + canvas.width = window.innerWidth; |
| 83 | + canvas.height = window.innerHeight; |
| 84 | + |
| 85 | + const katakana = 'アァカサタナハマヤャラワガザダバパイィキシチニヒミリヰギジヂビピウゥクスツヌフムユュルグズブヅプエェケセテネヘメレヱゲゼデベペオォコソトノホモヨョロヲゴゾドボポヴッン'; |
| 86 | + const latin = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; |
| 87 | + const nums = '0123456789'; |
| 88 | + const alphabet = katakana + latin + nums; |
| 89 | + |
| 90 | + const fontSize = 16; |
| 91 | + const columns = canvas.width / fontSize; |
| 92 | + const rainDrops = Array.from({ length: columns }).fill(1); |
| 93 | + |
| 94 | + const render = () => { |
| 95 | + // Subtle fade effect to create trails |
| 96 | + ctx.fillStyle = 'rgba(0, 0, 0, 0.05)'; |
| 97 | + ctx.fillRect(0, 0, canvas.width, canvas.height); |
| 98 | + |
| 99 | + ctx.fillStyle = '#0F0'; // Matrix Green |
| 100 | + ctx.font = fontSize + 'px monospace'; |
| 101 | + |
| 102 | + for (let i = 0; i < rainDrops.length; i++) { |
| 103 | + const text = alphabet.charAt(Math.floor(Math.random() * alphabet.length)); |
| 104 | + ctx.fillText(text, i * fontSize, rainDrops[i] * fontSize); |
| 105 | + |
| 106 | + if (rainDrops[i] * fontSize > canvas.height && Math.random() > 0.975) { |
| 107 | + rainDrops[i] = 0; |
| 108 | + } |
| 109 | + rainDrops[i]++; |
| 110 | + } |
| 111 | + |
| 112 | + if (matrixActive) requestAnimationFrame(render); |
| 113 | + }; |
| 114 | + |
| 115 | + render(); |
| 116 | + |
| 117 | + // Listen for Escape key to exit |
| 118 | + window.addEventListener('keydown', handleEsc); |
| 119 | +} |
| 120 | + |
| 121 | +function closeMatrix() { |
| 122 | + matrixActive = false; |
| 123 | + surpriseClickCount = 0; // Reset counter |
| 124 | + document.getElementById('matrix-overlay').classList.add('hidden'); |
| 125 | + window.removeEventListener('keydown', handleEsc); |
| 126 | +} |
| 127 | + |
| 128 | +function handleEsc(e) { |
| 129 | + if (e.key === 'Escape') closeMatrix(); |
| 130 | +} |
| 131 | + |
63 | 132 | // Initial Run |
64 | 133 | applyTheme(localStorage.getItem('theme') || 'light'); |
0 commit comments