Overlay: cassette redeems, emote effects, poll card, Hype Train bar, raid card
New overlay modules (taped-paper look, shared with the polaroid alerts): - cassette.js: redeems as a cassette tape; rarity = shell colour (Ultra Rare gold with glow, foil and sparkles), reels spin for the sound's length, sticker corner. - fx.js: Gigantify (viewer's emote grows giant), On-Screen Celebration (emote copies bounce around the screen), highlight / Message Effect (tall taped note). - poll.js: live poll card with bars, countdown and a WINNER stamp. - hypebar.js: persistent Hype Train strip (level, progress, time left). - raidcard.js: silent raid send-off card that stays during the raid countdown. - nowplaying.js: Feishin now-playing slip (not loaded yet, see overlay). polaroid.js: shared queue now also drives cassettes/effects; test alerts replace only other tests and never cut off real alerts; alerts stay up for the animation + 3 s or the sound's length; sound lengths measured in the browser for UI-picked sounds; tip and Hype Train alerts; optional ALERTS_BASE for offline test pages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
8c649c5bce
commit
1766e37336
14 changed files with 774 additions and 18 deletions
43
public/alerts/hypebar.js
Normal file
43
public/alerts/hypebar.js
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
Hype Train progress strip. Persistent while a train runs; not part of the alert queue.
|
||||
HypeBar.update(phase, train) phase: begin | progress | end
|
||||
train: { id, level, progress, goal, total, expires_at, golden, treasure }
|
||||
*/
|
||||
(function () {
|
||||
let el = null, timer = null, hideTimer = null, expires = 0, shownId = null;
|
||||
function root() {
|
||||
if (!el) { el = document.createElement('div'); el.id = 'hype-bar'; document.body.appendChild(el);
|
||||
el.innerHTML = '<div class="top"><span class="name"></span><span class="time"></span></div><div class="track"><div class="fill"></div></div>'; }
|
||||
return el;
|
||||
}
|
||||
function tick() {
|
||||
const s = Math.max(0, Math.round((expires - Date.now()) / 1000));
|
||||
el.querySelector('.time').textContent = s ? `${Math.floor(s / 60)}:${String(s % 60).padStart(2, '0')} left` : '';
|
||||
}
|
||||
function update(phase, t) {
|
||||
const el = root();
|
||||
clearTimeout(hideTimer);
|
||||
el.classList.toggle('golden', !!t.golden);
|
||||
const kind = t.golden ? 'GOLDEN KAPPA TRAIN' : t.treasure ? 'TREASURE TRAIN' : 'HYPE TRAIN';
|
||||
if (phase === 'end') {
|
||||
clearInterval(timer);
|
||||
el.querySelector('.name').innerHTML = `${kind} · <span class="lv">ENDED AT LV ${t.level}</span> ♡`;
|
||||
el.querySelector('.time').textContent = '';
|
||||
el.querySelector('.fill').style.width = '100%';
|
||||
hideTimer = setTimeout(() => el.animate([{ transform:'translateY(0)', opacity:1 }, { transform:'translateY(-90px)', opacity:0 }],
|
||||
{ duration:500, easing:'ease-in', fill:'forwards' }).finished.then(() => { el.style.visibility = 'hidden'; shownId = null; }).catch(() => {}), 5000);
|
||||
return;
|
||||
}
|
||||
if (shownId !== t.id || el.style.visibility !== 'visible') {
|
||||
el.getAnimations().forEach(a => a.cancel());
|
||||
el.style.visibility = 'visible'; shownId = t.id;
|
||||
el.animate([{ transform:'translateY(-90px) rotate(-3deg)', opacity:0 }, { transform:'translateY(4px) rotate(1deg)', opacity:1, offset:.75 },
|
||||
{ transform:'translateY(0) rotate(0)', opacity:1 }], { duration:550, easing:'cubic-bezier(.2,.8,.3,1)' });
|
||||
}
|
||||
el.querySelector('.name').innerHTML = `${kind} · <span class="lv">LV ${t.level}</span>`;
|
||||
const pct = t.goal ? Math.min(100, Math.round(100 * (t.progress || 0) / t.goal)) : 0;
|
||||
el.querySelector('.fill').style.width = `${Math.max(2, pct)}%`;
|
||||
if (t.expires_at) { expires = Date.parse(t.expires_at); clearInterval(timer); timer = setInterval(tick, 500); tick(); }
|
||||
}
|
||||
window.HypeBar = { update };
|
||||
})();
|
||||
Loading…
Add table
Add a link
Reference in a new issue