fix: remove party.js dep, add simulated count disclosure, deduplicate ambient body doubling code
All checks were successful
Build and Deploy / deploy (push) Successful in 11s

- Replace party.confetti() with existing confetti() helper (no external dep needed)
- Add tilde prefix to pill count and disclosure note in panel
- Remove duplicated ambient body doubling block from Unstuck IIFE (was registered twice)
This commit is contained in:
djg 2026-09-23 06:12:03 +00:00
parent b39f7fdb81
commit 0100c5040c
2 changed files with 3 additions and 113 deletions

View file

@ -30,10 +30,11 @@
</nav>
<div id="ambient-pill" class="ambient-pill" role="button" aria-expanded="false" tabindex="0">
<span class="pill-dot">🟢</span>
<span id="pill-count">..</span> with you
~<span id="pill-count">..</span> with you
</div>
<div id="ambient-panel" class="ambient-panel" hidden>
<p class="ambient-panel-head">You are not alone. Across the world, people with ADHD are taking on tasks just like you.</p>
<p class="ambient-panel-note" style="font-size:0.75rem;opacity:0.55;margin-top:0.25rem;">Count is a comforting estimate — real community presence coming soon.</p>
<ul id="ambient-feed" class="ambient-feed">
<!-- feed items added via JS -->
</ul>

View file

@ -956,7 +956,7 @@
cheerBtn.textContent = "Send a quiet cheer 🎉";
cheerBtn.style.pointerEvents = "auto";
}, 3000);
party.confetti(cheerBtn, { count: 15, spread: 30 });
confetti();
});
cheerBtn.addEventListener('keydown', function(e) {
if (e.key === 'Enter' || e.key === ' ') {
@ -1100,115 +1100,4 @@
if(timerTabBtn) timerTabBtn.click();
});
// ==========================================
// AMBIENT BODY DOUBLING (Feature C)
// ==========================================
var pill = $('#ambient-pill');
var panel = $('#ambient-panel');
var countEl = $('#pill-count');
var feedEl = $('#ambient-feed');
var cheerBtn = $('#ambient-cheer-btn');
var fakeBaseCount = 1400; // baseline
var feedEvents = [
"Someone just finished a 15m focus round",
"Someone broke down an intimidating task",
"Someone took a mindful breath",
"Someone swept their inbox clean",
"Someone just started a timer",
"Someone released a stale task to the universe",
"Someone decided to focus on just One Thing"
];
function getCircadianOffset() {
// Generate a smooth hour-based wave offset so the fake count feels organic
var hour = new Date().getHours();
var minute = new Date().getMinutes();
var time = hour + (minute/60);
// peak at noon and 8pm roughly
return Math.floor((Math.sin(time * 0.5) * 300) + (Math.cos(time * 0.8) * 150));
}
function updateCount() {
if (!countEl) return;
var base = fakeBaseCount + getCircadianOffset();
// small jitter
var jitter = Math.floor(Math.random() * 15) - 7;
var finalCount = base + jitter;
if (finalCount < 200) finalCount = 200; // min floor
countEl.textContent = finalCount.toLocaleString();
}
function addFeedItem(text) {
if (!feedEl) return;
var li = document.createElement('li');
li.className = 'feed-item';
li.textContent = text;
feedEl.prepend(li);
// keep only top 4
if (feedEl.children.length > 4) {
feedEl.removeChild(feedEl.lastChild);
}
}
function feedLoop() {
// random feed inject every 8-25 seconds
var delay = 8000 + Math.random() * 17000;
setTimeout(function() {
var evt = feedEvents[Math.floor(Math.random() * feedEvents.length)];
addFeedItem(evt);
updateCount();
feedLoop();
}, delay);
}
if (pill) {
updateCount();
addFeedItem("You joined the focus room");
feedLoop();
// click to toggle panel
pill.addEventListener('click', function(e) {
e.stopPropagation();
var expanded = pill.getAttribute('aria-expanded') === 'true';
pill.setAttribute('aria-expanded', !expanded);
panel.hidden = expanded;
});
// click outside to close
document.addEventListener('click', function(e) {
if (!panel.hidden && !panel.contains(e.target) && !pill.contains(e.target)) {
panel.hidden = true;
pill.setAttribute('aria-expanded', 'false');
}
});
pill.addEventListener('keydown', function(e) {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
pill.click();
}
});
}
if (cheerBtn) {
cheerBtn.addEventListener('click', function() {
addFeedItem("You sent a quiet cheer 🎉");
cheerBtn.textContent = "Sent!";
cheerBtn.style.pointerEvents = "none";
setTimeout(function() {
cheerBtn.textContent = "Send a quiet cheer 🎉";
cheerBtn.style.pointerEvents = "auto";
}, 3000);
party.confetti(cheerBtn, { count: 15, spread: 30 });
});
cheerBtn.addEventListener('keydown', function(e) {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
cheerBtn.click();
}
});
}
})();