@ywkrlerche/richardwho 1.0.35 → 1.0.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app.js +82 -1
- package/index.html +8 -0
- package/package.json +1 -1
- package/style.css +20 -1
package/app.js
CHANGED
|
@@ -526,6 +526,9 @@
|
|
|
526
526
|
// Newest first. Add an entry here with every publish; its version should match package.json.
|
|
527
527
|
// Each has: new (features), games (added/removed/fixed games), fixes (bugs). Leave a list out if empty.
|
|
528
528
|
const CHANGELOG = [
|
|
529
|
+
{ version: "1.0.36", date: "2026-10-28",
|
|
530
|
+
new: ["🎁 Send gifts during live streams: they pop up on the stream for everyone (one gift a minute)"],
|
|
531
|
+
fixes: ["Nickname and title boxes aren't cut off in the live chat anymore"] },
|
|
529
532
|
{ version: "1.0.35", date: "2026-10-28",
|
|
530
533
|
new: ["🔴 Live streams: watch Richard live, with its own chat beside the stream", "Quote of the day on the front page, and you can submit your own",
|
|
531
534
|
"📸 Take a photo with your camera right in the chat", "Full-screen chat", "Chat titles: add a title next to your name",
|
|
@@ -1893,6 +1896,8 @@
|
|
|
1893
1896
|
$("live-overlay").hidden = mine || !!live.viewer;
|
|
1894
1897
|
$("live-overlay-text").textContent = on ? "Richard is live" : "Not live right now";
|
|
1895
1898
|
$("live-watch").hidden = !on || mine;
|
|
1899
|
+
renderGifts();
|
|
1900
|
+
if (on) watchGifts();
|
|
1896
1901
|
updateViewerCount();
|
|
1897
1902
|
}
|
|
1898
1903
|
|
|
@@ -1952,7 +1957,7 @@
|
|
|
1952
1957
|
}
|
|
1953
1958
|
async function endLive() {
|
|
1954
1959
|
const db = (await getFirebase())?.database();
|
|
1955
|
-
if (db) { db.ref("live/viewers").off(); await db.ref("live/state").remove().catch(() => {}); await db.ref("live/viewers").remove().catch(() => {}); }
|
|
1960
|
+
if (db) { db.ref("live/viewers").off(); await db.ref("live/state").remove().catch(() => {}); await db.ref("live/viewers").remove().catch(() => {}); await db.ref("live/gifts").remove().catch(() => {}); }
|
|
1956
1961
|
live.peers.forEach((pc) => pc.close());
|
|
1957
1962
|
live.peers.clear();
|
|
1958
1963
|
live.streams?.raw.forEach((m) => m.getTracks().forEach((t) => t.stop()));
|
|
@@ -2018,6 +2023,81 @@
|
|
|
2018
2023
|
window.addEventListener("pagehide", () => { if (live.streams) endLive(); });
|
|
2019
2024
|
}
|
|
2020
2025
|
|
|
2026
|
+
// ---------- Live gifts (fake, free) ----------
|
|
2027
|
+
// Viewers tap a gift; it pops up over the stream for everyone ("Bob sent a 🚀 Rocket!").
|
|
2028
|
+
// One gift per person per minute (the database checks too), and pop-ups play one at a time.
|
|
2029
|
+
const GIFTS = [
|
|
2030
|
+
{ id: "heart", emoji: "❤️", name: "Heart" }, { id: "rose", emoji: "🌹", name: "Rose" },
|
|
2031
|
+
{ id: "pizza", emoji: "🍕", name: "Pizza" }, { id: "diamond", emoji: "💎", name: "Diamond" },
|
|
2032
|
+
{ id: "rocket", emoji: "🚀", name: "Rocket" }, { id: "crown", emoji: "👑", name: "Crown" },
|
|
2033
|
+
];
|
|
2034
|
+
const GIFT_GAP = 60000;
|
|
2035
|
+
const gifts = { sentAt: store.get("rug-gift-sent", 0), queue: [], playing: false, ref: null, timer: null };
|
|
2036
|
+
function renderGiftButtons() {
|
|
2037
|
+
$("gift-btns").innerHTML = GIFTS.map((g) => `<button class="gift-btn" type="button" data-gift="${g.id}" title="Send a ${g.name}"><span>${g.emoji}</span>${g.name}</button>`).join("");
|
|
2038
|
+
}
|
|
2039
|
+
function updateGiftWait() {
|
|
2040
|
+
const left = GIFT_GAP - (Date.now() - gifts.sentAt);
|
|
2041
|
+
const waiting = left > 0;
|
|
2042
|
+
$("gift-btns").querySelectorAll("button").forEach((b) => { b.disabled = waiting; });
|
|
2043
|
+
$("gift-wait").textContent = waiting ? `Next gift in ${Math.ceil(left / 1000)}s` : "";
|
|
2044
|
+
}
|
|
2045
|
+
async function sendGift(id) {
|
|
2046
|
+
const g = GIFTS.find((x) => x.id === id);
|
|
2047
|
+
if (!g || Date.now() - gifts.sentAt < GIFT_GAP || !live.state) return;
|
|
2048
|
+
if (chat.banned) { toast("You can't send gifts right now."); return; }
|
|
2049
|
+
const n = chat.admin ? { name: ADMIN_NAME } : cleanName($("chat-name").value);
|
|
2050
|
+
if (n.error) { toast("Type a nickname in the chat box first, so everyone knows who sent it."); $("chat-name").focus(); return; }
|
|
2051
|
+
const app = await getFirebase();
|
|
2052
|
+
if (!app || !chat.uid) return;
|
|
2053
|
+
const db = app.database(), TS = window.firebase.database.ServerValue.TIMESTAMP;
|
|
2054
|
+
try {
|
|
2055
|
+
await db.ref().update({
|
|
2056
|
+
[`live/gifts/${db.ref("live/gifts").push().key}`]: { name: n.name, gift: g.id, uid: chat.uid, ts: TS },
|
|
2057
|
+
[`live/giftLast/${chat.uid}`]: TS,
|
|
2058
|
+
});
|
|
2059
|
+
gifts.sentAt = Date.now();
|
|
2060
|
+
store.set("rug-gift-sent", gifts.sentAt);
|
|
2061
|
+
updateGiftWait();
|
|
2062
|
+
} catch {
|
|
2063
|
+
toast("That gift didn't send. You can send one gift a minute.");
|
|
2064
|
+
}
|
|
2065
|
+
}
|
|
2066
|
+
// Everyone watching the Live page sees new gifts pop up (not old ones)
|
|
2067
|
+
async function watchGifts() {
|
|
2068
|
+
const app = await getFirebase();
|
|
2069
|
+
if (!app || gifts.ref) return;
|
|
2070
|
+
gifts.ref = app.database().ref("live/gifts").orderByChild("ts").startAt(Date.now() - 5000);
|
|
2071
|
+
gifts.ref.on("child_added", (s) => {
|
|
2072
|
+
const v = s.val(), g = v && GIFTS.find((x) => x.id === v.gift);
|
|
2073
|
+
if (!g || typeof v.name !== "string") return;
|
|
2074
|
+
gifts.queue.push({ g, name: maskText(v.name).slice(0, 16) });
|
|
2075
|
+
if (gifts.queue.length > 20) gifts.queue.shift(); // a burst never builds an endless line
|
|
2076
|
+
playGifts();
|
|
2077
|
+
}, () => { gifts.ref = null; });
|
|
2078
|
+
}
|
|
2079
|
+
function playGifts() {
|
|
2080
|
+
if (gifts.playing || !gifts.queue.length) return;
|
|
2081
|
+
gifts.playing = true;
|
|
2082
|
+
const { g, name } = gifts.queue.shift();
|
|
2083
|
+
const pop = $("gift-pop");
|
|
2084
|
+
pop.innerHTML = `<span class="gift-emoji">${g.emoji}</span><span class="gift-text"><b>${escapeHtml(name)}</b> sent a ${g.name}!</span>`;
|
|
2085
|
+
pop.hidden = false;
|
|
2086
|
+
pop.classList.remove("show"); void pop.offsetWidth; pop.classList.add("show");
|
|
2087
|
+
setTimeout(() => { pop.hidden = true; pop.classList.remove("show"); gifts.playing = false; setTimeout(playGifts, 400); }, 4000);
|
|
2088
|
+
}
|
|
2089
|
+
function renderGifts() {
|
|
2090
|
+
// the gift row shows for viewers while someone is live (not for the streamer)
|
|
2091
|
+
$("live-gifts").hidden = !live.state || !!live.streams;
|
|
2092
|
+
if (!$("gift-btns").children.length) renderGiftButtons();
|
|
2093
|
+
updateGiftWait();
|
|
2094
|
+
clearInterval(gifts.timer);
|
|
2095
|
+
if (!$("live-gifts").hidden) gifts.timer = setInterval(updateGiftWait, 1000);
|
|
2096
|
+
}
|
|
2097
|
+
function bindGifts() {
|
|
2098
|
+
$("gift-btns").addEventListener("click", (e) => { const b = e.target.closest("[data-gift]"); if (b) sendGift(b.dataset.gift); });
|
|
2099
|
+
}
|
|
2100
|
+
|
|
2021
2101
|
// ---------- Emoji picker and stickers ----------
|
|
2022
2102
|
// Stickers are Google's Noto animated emoji (CC BY 4.0), sent by code so only these can ever appear.
|
|
2023
2103
|
// Grouped into tabs in the picker; every code here was checked to exist on Google's server
|
|
@@ -2566,6 +2646,7 @@
|
|
|
2566
2646
|
bindChatExtras();
|
|
2567
2647
|
bindQuotes();
|
|
2568
2648
|
bindLive();
|
|
2649
|
+
bindGifts();
|
|
2569
2650
|
bindReports();
|
|
2570
2651
|
startAnalytics();
|
|
2571
2652
|
startPresence();
|
package/index.html
CHANGED
|
@@ -233,9 +233,17 @@
|
|
|
233
233
|
<button class="pill-btn play" type="button" id="live-watch" hidden>▶ Watch live</button>
|
|
234
234
|
</div>
|
|
235
235
|
<button class="pill-btn live-unmute" type="button" id="live-unmute" hidden>🔊 Tap for sound</button>
|
|
236
|
+
<!-- gift pop-ups play here, one at a time -->
|
|
237
|
+
<div class="gift-pop" id="gift-pop" aria-live="polite" hidden></div>
|
|
236
238
|
</div>
|
|
237
239
|
<div class="live-chat" id="live-chat"></div>
|
|
238
240
|
</div>
|
|
241
|
+
<!-- fake gifts (free, just for fun): one per person per minute -->
|
|
242
|
+
<div class="live-gifts" id="live-gifts" hidden>
|
|
243
|
+
<span class="live-gifts-label">🎁 Send a gift</span>
|
|
244
|
+
<div class="gift-btns" id="gift-btns"></div>
|
|
245
|
+
<span class="gift-wait" id="gift-wait"></span>
|
|
246
|
+
</div>
|
|
239
247
|
<!-- owner only -->
|
|
240
248
|
<div class="set-group live-owner" id="live-owner" hidden>
|
|
241
249
|
<h2>Go live</h2>
|
package/package.json
CHANGED
package/style.css
CHANGED
|
@@ -392,7 +392,9 @@ body:has(#view-games:not([hidden])) .aurora { opacity: .7; }
|
|
|
392
392
|
/* Narrow chat (beside a game or the live stream): the message box gets its own full-width line on top */
|
|
393
393
|
.chat-dock .chat-form, .live-chat .chat-form { flex-wrap: wrap; }
|
|
394
394
|
.chat-dock .chat-text, .live-chat .chat-text { flex: 1 1 100%; order: -1; }
|
|
395
|
-
|
|
395
|
+
/* nickname and title share the second row (half each); the buttons wrap onto the row below */
|
|
396
|
+
.chat-dock .chat-name, .live-chat .chat-name { flex: 1 1 calc(50% - 4px); width: auto; min-width: 110px; }
|
|
397
|
+
.chat-dock .chat-box .pill-btn, .live-chat .chat-box .pill-btn { margin-left: auto; }
|
|
396
398
|
.chat-dock .chat-box .pill-btn, .live-chat .chat-box .pill-btn { padding: 0 14px; }
|
|
397
399
|
.chat-toggle[aria-pressed="true"] { background: #fff; color: #000; border-color: #fff; }
|
|
398
400
|
@media (max-width: 720px) { .chat-dock { position: absolute; right: 0; top: 49px; bottom: 0; width: min(340px, 100%); z-index: 2; } }
|
|
@@ -617,3 +619,20 @@ body:has(#view-live:not([hidden])) .corner-links { display: none; }
|
|
|
617
619
|
.cam-view { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: 6px; overflow: hidden; }
|
|
618
620
|
.cam-view video, .cam-view canvas { width: 100%; height: 100%; object-fit: cover; display: block; }
|
|
619
621
|
.cam-view video { transform: scaleX(-1); } /* mirror like a selfie camera */
|
|
622
|
+
|
|
623
|
+
/* ---------- Live gifts ---------- */
|
|
624
|
+
.live-gifts { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: 0 0 16px; padding: 10px 14px; border: 1px solid var(--line-2); border-radius: 6px; background: color-mix(in srgb, var(--panel) 85%, transparent); }
|
|
625
|
+
.live-gifts-label { font-weight: 800; font-size: 14px; }
|
|
626
|
+
.gift-btns { display: flex; flex-wrap: wrap; gap: 6px; }
|
|
627
|
+
.gift-btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 18px; background: var(--soft); color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer; transition: transform .15s, background .15s, border-color .15s; }
|
|
628
|
+
.gift-btn span { font-size: 18px; }
|
|
629
|
+
.gift-btn:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--glow-cyan, #22d3ee); background: color-mix(in srgb, var(--glow-cyan, #22d3ee) 15%, var(--soft)); }
|
|
630
|
+
.gift-btn:disabled { opacity: .4; cursor: not-allowed; }
|
|
631
|
+
.gift-wait { margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
|
|
632
|
+
.gift-pop { position: absolute; left: 50%; top: 16px; z-index: 3; display: flex; align-items: center; gap: 12px; padding: 10px 20px 10px 12px; transform: translateX(-50%); border-radius: 40px; background: linear-gradient(90deg, #7c3aed, #db2777); color: #fff; box-shadow: 0 12px 40px rgba(0,0,0,.6); font-size: 16px; white-space: nowrap; pointer-events: none; }
|
|
633
|
+
.gift-pop .gift-emoji { font-size: 40px; line-height: 1; }
|
|
634
|
+
.gift-pop.show { animation: gift-in 4s cubic-bezier(.2, .9, .3, 1.4) both; }
|
|
635
|
+
.gift-pop.show .gift-emoji { animation: gift-bob .6s ease-in-out 3 alternate; }
|
|
636
|
+
@keyframes gift-in { 0% { opacity: 0; transform: translate(-50%, -30px) scale(.6); } 10% { opacity: 1; transform: translate(-50%, 0) scale(1.08); } 16% { transform: translate(-50%, 0) scale(1); } 88% { opacity: 1; transform: translate(-50%, 0) scale(1); } 100% { opacity: 0; transform: translate(-50%, -12px) scale(.95); } }
|
|
637
|
+
@keyframes gift-bob { to { transform: translateY(-6px) rotate(-8deg) scale(1.15); } }
|
|
638
|
+
@media (prefers-reduced-motion: reduce) { .gift-pop.show, .gift-pop.show .gift-emoji { animation: none; } }
|