Add debug logging to easter egg trigger

This commit is contained in:
chris 2026-06-06 21:29:51 -04:00
parent 181195dbbc
commit 75b20e6ca2

View File

@ -41,29 +41,43 @@
var tapTimer = null; var tapTimer = null;
var lastTouch = 0; var lastTouch = 0;
function registerTap() { function registerTap(source, target) {
if (active) return; if (active) { console.log('[🎈 easter egg] already active, ignoring'); return; }
tapCount++; tapCount++;
clearTimeout(tapTimer); clearTimeout(tapTimer);
tapTimer = setTimeout(function () { tapCount = 0; }, 3000); tapTimer = setTimeout(function () {
console.log('[🎈 easter egg] tap window expired, resetting count');
tapCount = 0;
}, 3000);
console.log('[🎈 easter egg] tap ' + tapCount + '/5 via ' + source + ' on <' + (target.tagName || '?').toLowerCase() + '>');
if (tapCount >= 5) { if (tapCount >= 5) {
tapCount = 0; tapCount = 0;
console.log('[🎈 easter egg] launching!');
launch(); launch();
} }
} }
// touchstart for mobile (fires immediately, not affected by scroll) // touchstart for mobile (fires immediately, not affected by scroll)
document.addEventListener('touchstart', function (e) { document.addEventListener('touchstart', function (e) {
if (e.target.closest('input, select, textarea')) return; if (e.target.closest('input, select, textarea')) {
console.log('[🎈 easter egg] touchstart ignored — form element');
return;
}
lastTouch = Date.now(); lastTouch = Date.now();
registerTap(); registerTap('touch', e.target);
}, { passive: true }); }, { passive: true });
// click for desktop (deduplicated from touch events) // click for desktop (deduplicated from touch events)
document.addEventListener('click', function (e) { document.addEventListener('click', function (e) {
if (Date.now() - lastTouch < 500) return; // already counted via touchstart if (Date.now() - lastTouch < 500) {
if (e.target.closest('input, select, textarea')) return; console.log('[🎈 easter egg] click deduplicated (touch fired recently)');
registerTap(); return;
}
if (e.target.closest('input, select, textarea')) {
console.log('[🎈 easter egg] click ignored — form element');
return;
}
registerTap('click', e.target);
}); });
function launch() { function launch() {