Skip to content

Commit dbd20b6

Browse files
committed
Surprise me 5 times
1 parent d4fa591 commit dbd20b6

File tree

2 files changed

+80
-4
lines changed

2 files changed

+80
-4
lines changed

src/_includes/footer.njk

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,10 @@
3737

3838
</div>
3939
</footer>
40+
<div id="matrix-overlay" class="fixed inset-0 z-[100] hidden bg-black overflow-hidden">
41+
<canvas id="matrix-canvas"></canvas>
42+
<button onclick="closeMatrix()" class="fixed top-8 right-8 z-[101] bg-white/10 hover:bg-white/20 text-white px-6 py-3 rounded-full font-mono text-sm border border-white/30 backdrop-blur-md transition-all">
43+
[ESC] EXIT_SIMULATION
44+
</button>
45+
</div>
46+

src/assets/js/script.js

Lines changed: 73 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
/**
2-
* THEME LOGIC: Light -> Dark -> Random
3-
*/
41
function toggleTheme() {
52
const currentTheme = localStorage.getItem('theme') || 'light';
63
let nextTheme;
@@ -48,17 +45,89 @@ function updateIcon(theme) {
4845
else icon.innerText = '☀️'; // Next is Light
4946
}
5047

48+
// --- EASTER EGG STATE ---
49+
let surpriseClickCount = 0;
50+
let matrixActive = false;
51+
5152
/**
52-
* SURPRISE ME LOGIC
53+
* Updated Surprise Me Logic with Counter
5354
*/
5455
function scrollToRandomUser() {
56+
// Increment Easter Egg counter
57+
surpriseClickCount++;
58+
if (surpriseClickCount === 5) {
59+
initMatrix();
60+
}
61+
5562
const cards = document.querySelectorAll('.user-card');
63+
if (cards.length === 0) return;
64+
5665
cards.forEach(c => c.classList.remove('highlight-pulse'));
5766
const randomCard = cards[Math.floor(Math.random() * cards.length)];
5867
randomCard.scrollIntoView({ behavior: 'smooth', block: 'start' });
5968
randomCard.classList.add('highlight-pulse');
6069
setTimeout(() => randomCard.classList.remove('highlight-pulse'), 3500);
6170
}
6271

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+
63132
// Initial Run
64133
applyTheme(localStorage.getItem('theme') || 'light');

0 commit comments

Comments
 (0)