@ywkrlerche/richardwho 1.0.34 β†’ 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.
Files changed (4) hide show
  1. package/app.js +548 -72
  2. package/index.html +100 -7
  3. package/package.json +1 -1
  4. package/style.css +89 -2
package/app.js CHANGED
@@ -406,11 +406,11 @@
406
406
  }
407
407
 
408
408
  // ---------- Routing: "" home, #games, #recent, #play/<id> ----------
409
- const VIEW_ORDER = ["home", "games", "chat", "stats", "settings", "changelog"];
409
+ const VIEW_ORDER = ["home", "games", "chat", "stats", "live", "settings", "changelog"];
410
410
  let lastView = null;
411
411
  function viewFor(hash) {
412
412
  return hash === "#games" || hash === "#recent" ? "games" : hash === "#settings" ? "settings" : hash === "#chat" ? "chat"
413
- : hash === "#stats" ? "stats" : hash === "#changelog" ? "changelog" : "home";
413
+ : hash === "#stats" ? "stats" : hash === "#changelog" ? "changelog" : hash === "#live" ? "live" : "home";
414
414
  }
415
415
  // Switching pages: the old page slides out while the new one slides in (down the side bar = upward,
416
416
  // up the side bar = downward). Uses the browser's view transitions; older browsers just switch.
@@ -420,12 +420,14 @@
420
420
  !matchMedia("(prefers-reduced-motion: reduce)").matches;
421
421
  if (!animate) { routeNow(); after?.(); return; }
422
422
  document.documentElement.dataset.navDir = VIEW_ORDER.indexOf(next) < VIEW_ORDER.indexOf(lastView) ? "up" : "down";
423
- document.startViewTransition(() => { routeNow(); after?.(); });
423
+ const t = document.startViewTransition(() => { routeNow(); after?.(); });
424
+ t.ready.catch(() => {}); // a quick second click skips the first slide: harmless, so don't report it as an error
424
425
  }
425
426
  function routeNow() {
426
427
  const m = location.hash.match(/^#play\/(.+)$/);
427
428
  const game = m && byId.get(decodeURIComponent(m[1]));
428
429
  if (game) {
430
+ if (live.viewer) stopWatching(); // a game covers the Live page: stop the stream's sound too
429
431
  els.player.hidden = false;
430
432
  document.body.classList.add("playing");
431
433
  addRecent(game.id);
@@ -449,6 +451,9 @@
449
451
  lastView = view;
450
452
  $("view-stats").hidden = view !== "stats";
451
453
  $("view-changelog").hidden = view !== "changelog";
454
+ $("view-live").hidden = view !== "live";
455
+ if (view === "live") { openChat(); renderLive(); }
456
+ else if (live.viewer) stopWatching(); // leaving the Live page stops the stream (and its sound); Watch live rejoins
452
457
  if (view === "changelog") renderChangelog();
453
458
  placeChatBox();
454
459
  if (view === "settings") { renderSettings(); renderAdmin(); }
@@ -461,10 +466,13 @@
461
466
  if (location.hash === "#recent") requestAnimationFrame(() => els.recentBlock.scrollIntoView({ block: "start" }));
462
467
  }
463
468
  function play(id) { location.hash = `#play/${encodeURIComponent(id)}`; }
464
- function go(view) {
469
+ // instant: switch right away, no slide (used when typing on the home search moves you to Games,
470
+ // so the Games search box can take focus before the next key arrives)
471
+ function go(view, { instant = false } = {}) {
465
472
  const target = view === "home" ? "" : `#${view}`;
466
473
  if (location.hash !== target) history.pushState(null, "", target || location.pathname + location.search);
467
- route(() => { if (view !== "recent") window.scrollTo(0, 0); });
474
+ const after = () => { if (view !== "recent") window.scrollTo(0, 0); };
475
+ if (instant) { routeNow(); after(); } else route(after);
468
476
  }
469
477
  function goBack() {
470
478
  if (location.hash.startsWith("#play/")) history.length > 1 ? history.back() : (location.hash = "#games");
@@ -518,6 +526,15 @@
518
526
  // Newest first. Add an entry here with every publish; its version should match package.json.
519
527
  // Each has: new (features), games (added/removed/fixed games), fixes (bugs). Leave a list out if empty.
520
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"] },
532
+ { version: "1.0.35", date: "2026-10-28",
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",
534
+ "πŸ“Έ Take a photo with your camera right in the chat", "Full-screen chat", "Chat titles: add a title next to your name",
535
+ "See how many people are in chat right now", "Chat starts fresh every day at 1:35 PM"],
536
+ fixes: ["Chat doesn't block messages anymore: swear words just get their middle letters hidden",
537
+ "Nicknames can be anything", "No cooldown between messages or photos"] },
521
538
  { version: "1.0.34", date: "2026-10-27",
522
539
  new: ["Send photos in chat: drag and drop, paste, or tap πŸ“·", "Emoji picker and 230 animated stickers (😊 button)",
523
540
  "🚩 Report messages: 3 reports hides a message", "Slow mode and chat lock when chat gets busy"],
@@ -1071,36 +1088,29 @@
1071
1088
  return BAD_WHOLE_WORD.includes(p) || BAD_WHOLE_WORD.includes(w) ||
1072
1089
  [...BAD_ANYWHERE, ...extraWords()].some((b) => w.includes(tight(b)));
1073
1090
  }
1074
- // Blocked content just says this, in red: no hints about which word tripped the filter
1075
- const NOT_ALLOWED = "Not allowed";
1076
- // Returns { text } or { error } when the message can't be sent. Nothing is ever starred out.
1091
+ // Nothing is ever blocked: swear words just get their middle letters hidden ("f**k").
1092
+ // The owner's extra word list (Settings β†’ Tools) is hidden the same way.
1093
+ function maskWord(w) {
1094
+ const letters = [...w];
1095
+ if (letters.length <= 2) return "*".repeat(letters.length);
1096
+ return letters[0] + "*".repeat(letters.length - 2) + letters[letters.length - 1];
1097
+ }
1098
+ function maskText(text) {
1099
+ return String(text).split(/(\s+)/).map((w) => (/\S/.test(w) && isBadWord(w) ? maskWord(w) : w)).join("");
1100
+ }
1101
+ // Returns { text } (masked) or { error } only when there's nothing to send
1077
1102
  function cleanMessage(raw) {
1078
1103
  const text = String(raw).replace(/\s+/g, " ").trim();
1079
1104
  if (!text) return { error: "Type a message first." };
1080
- const folded = fold(text);
1081
- if (/(https?:|www\.|discord\.gg|\b[a-z0-9-]+\s*(\.|dot)\s*(com|net|org|io|gg|xyz|co|me|tv|ly|app|dev|link|ru|us)\b)/i.test(folded)) return { error: NOT_ALLOWED };
1082
- if (/\S+@\S+\.\S+/.test(folded)) return { error: NOT_ALLOWED };
1083
- if (/(\d[\s().-]*){7,}/.test(folded)) return { error: NOT_ALLOWED };
1084
- if (text.split(" ").some(isBadWord)) return { error: NOT_ALLOWED };
1085
- // spaced-out tricks like "f u c k" survive word-by-word checks; catch them on the whole line
1086
- const joined = tight(text.split(" ").filter((w) => !SAFE_WORDS.includes(plain(w))).join(" "));
1087
- if ([...BAD_ANYWHERE, ...extraWords()].some((b) => joined.includes(tight(b)))) return { error: NOT_ALLOWED };
1088
- const sentence = plain(text).replace(/\s+/g, " ");
1089
- if (BAD_PHRASES.some((re) => re.test(sentence))) return { error: NOT_ALLOWED };
1090
- return { text };
1091
- }
1092
- // Teacher titles and staff-sounding names aren't allowed (people were posing as teachers)
1093
- const NAME_TITLES = /^(mr|mrs|ms|miss|mx|dr|sir|madam|coach|prof|professor|principal|teacher|dean|admin|mod|moderator|owner|staff|system)( |_|-|$)/i;
1105
+ return { text: maskText(text).slice(0, 300) };
1106
+ }
1107
+ // Names can be anything up to 16 characters. (The admin code is longer than that, so a mistyped code is
1108
+ // refused instead of being posted as someone's name.) "Richard" stays the owner's.
1094
1109
  function cleanName(raw) {
1095
- // Refuse (don't silently strip) other characters: a wrong or not-yet-saved admin code like "Code123!"
1096
- // must never be posted as a nickname
1097
- if (/[^A-Za-z0-9 _-]/.test(raw)) return { error: "Nicknames can only use letters, numbers, spaces, _ and -." };
1098
- // (the box allows 40 characters so the admin code fits; real nicknames stop at 16)
1099
- const name = raw.replace(/\s+/g, " ").trim();
1100
- if (name.length < 2 || name.length > 16) return { error: "Pick a nickname (2–16 letters)." };
1101
- if (NAME_TITLES.test(name)) return { error: "Nicknames can't use titles like Mr., Ms. or Teacher." };
1102
- if (name.split(/[ _-]/).some(isBadWord) || isBadWord(name.replace(/[ _-]/g, ""))) return { error: NOT_ALLOWED };
1103
- return { name };
1110
+ const name = String(raw).replace(/\s+/g, " ").trim();
1111
+ if (!name) return { error: "Pick a nickname." };
1112
+ if ([...name].length > 16) return { error: "Nicknames can be up to 16 characters." };
1113
+ return { name: maskText(name) };
1104
1114
  }
1105
1115
 
1106
1116
  const chat = {
@@ -1108,9 +1118,12 @@
1108
1118
  settings: {}, // owner's live settings: slowMode (s), locked, words
1109
1119
  mutedUntil: 0, banned: false,
1110
1120
  flags: {}, // message key -> number of people who reported it
1111
- lastText: "", lastTextAt: 0, strikes: [],
1121
+ lastText: "", lastTextAt: 0,
1122
+ room: "main", // "main" (the Chat page / beside games) or "live" (beside the live stream)
1112
1123
  };
1113
- const HIDE_AFTER_REPORTS = 3;
1124
+ const HIDE_AFTER_REPORTS = Infinity;
1125
+ // Each room keeps its own messages, typing and "in chat" list; names, bans, mutes and settings are shared
1126
+ function roomPath(x) { return chat.room === "live" ? `live/chat/${x}` : `chat/${x}`; } // reports are switched off: nothing is hidden automatically
1114
1127
  const ADMIN_NAME = "Richard"; // what the admin's messages show as (reserved: the database refuses it from non-admins)
1115
1128
  function setAdminName() {
1116
1129
  $("chat-name").value = ADMIN_NAME;
@@ -1140,6 +1153,7 @@
1140
1153
  chat.started = true;
1141
1154
  $("chat-form").hidden = false;
1142
1155
  $("chat-name").value = store.get("rug-chat-name", "");
1156
+ $("chat-title").value = store.get("rug-chat-title", "");
1143
1157
  chatNote("Connecting…");
1144
1158
  try {
1145
1159
  await ensureUser(app);
@@ -1148,13 +1162,50 @@
1148
1162
  return;
1149
1163
  }
1150
1164
  if (chat.admin) setAdminName();
1165
+ if (!$("view-live").hidden) renderLive(); // now we know whether this is the owner (Go live panel)
1151
1166
  chatNote("");
1152
1167
  const log = $("chat-log");
1153
1168
  log.innerHTML = `<p class="chat-empty" id="chat-empty">No messages yet. Say hi!</p>`;
1154
1169
  const db = app.database();
1155
1170
  watchChatState(db);
1171
+ listenRoom(db);
1172
+ watchChatReset(db);
1173
+ }
1174
+
1175
+ // Show the current room's messages (called again when the chat moves between the Chat page and Live)
1176
+ // The chat starts fresh every day at 1:35 PM (by this browser's clock): only messages sent since the most
1177
+ // recent 1:35 PM show. Messages over a day old are deleted from the database by whoever has the chat open.
1178
+ const CHAT_RESET = { hour: 13, minute: 35 };
1179
+ function lastChatReset(now = new Date()) {
1180
+ const t = new Date(now.getFullYear(), now.getMonth(), now.getDate(), CHAT_RESET.hour, CHAT_RESET.minute);
1181
+ if (t > now) t.setDate(t.getDate() - 1);
1182
+ return t.getTime();
1183
+ }
1184
+ function watchChatReset(db) {
1185
+ clearInterval(chat.resetTimer);
1186
+ chat.resetTimer = setInterval(() => {
1187
+ if (lastChatReset() !== chat.resetAt) { listenRoom(db); sweepOldMessages(db); } // it's 1:35: clear the screen
1188
+ }, 15000);
1189
+ sweepOldMessages(db);
1190
+ }
1191
+ async function sweepOldMessages(db) {
1192
+ const dayAgo = Date.now() - 86400000;
1193
+ for (const path of ["chat/messages", "live/chat/messages"]) {
1194
+ try {
1195
+ const old = await db.ref(path).orderByChild("ts").endAt(dayAgo).limitToFirst(200).once("value");
1196
+ const changes = {};
1197
+ old.forEach((c) => { changes[`${path}/${c.key}`] = null; });
1198
+ if (Object.keys(changes).length) await db.ref().update(changes);
1199
+ } catch { /* older rules, or someone else already swept */ }
1200
+ }
1201
+ }
1202
+ function listenRoom(db) {
1203
+ const log = $("chat-log"), room = chat.room;
1204
+ log.innerHTML = `<p class="chat-empty" id="chat-empty">${room === "live" ? "No messages yet. Say hi to the stream!" : "No messages yet. Say hi!"}</p>`;
1205
+ $("chat-text").placeholder = room === "live" ? "Chat with the stream…" : "Say something… (drop a photo here)";
1156
1206
  if (chat.ref) chat.ref.off(); // reconnecting (signed in/out): drop the old listener so messages don't double
1157
- const ref = chat.ref = db.ref("chat/messages").orderByChild("ts").limitToLast(60);
1207
+ chat.resetAt = lastChatReset();
1208
+ const ref = chat.ref = db.ref(roomPath("messages")).orderByChild("ts").startAt(chat.resetAt).limitToLast(60);
1158
1209
  ref.on("child_added", (snap) => {
1159
1210
  const m = snap.val();
1160
1211
  const div = renderMessage(snap.key, m);
@@ -1166,7 +1217,7 @@
1166
1217
  if (nearBottom || m.uid === chat.uid) log.scrollTop = log.scrollHeight;
1167
1218
  // pictures load after they're added; keep the view pinned to the bottom when they do
1168
1219
  div.querySelector("img")?.addEventListener("load", () => { if (nearBottom || m.uid === chat.uid) log.scrollTop = log.scrollHeight; }, { once: true });
1169
- noteNewMessage(m, div.classList.contains("mention"));
1220
+ if (room === "main") noteNewMessage(m, div.classList.contains("mention")); // the unread dot is for the regular chat
1170
1221
  });
1171
1222
  // Deleted (by its sender or the owner): disappears for everyone
1172
1223
  ref.on("child_removed", (snap) => {
@@ -1174,6 +1225,20 @@
1174
1225
  if (!log.querySelector(".chat-msg")) log.innerHTML = `<p class="chat-empty" id="chat-empty">No messages yet. Say hi!</p>`;
1175
1226
  });
1176
1227
  startTypingWatch(db);
1228
+ watchHere(db);
1229
+ updateHere();
1230
+ }
1231
+ async function switchRoom(room) {
1232
+ if (room === chat.room) return;
1233
+ stopTyping();
1234
+ typing.ref = null;
1235
+ if (hereOn && hereRef) hereRef.remove().catch(() => {});
1236
+ hereOn = false;
1237
+ hereRef = null;
1238
+ chat.room = room;
1239
+ if (!chat.started || !chat.uid) return;
1240
+ const app = await getFirebase();
1241
+ if (app) listenRoom(app.database());
1177
1242
  }
1178
1243
 
1179
1244
  // One chat row: text, a sticker or a photo, plus its buttons (shown by CSS for who may use them)
@@ -1182,10 +1247,8 @@
1182
1247
  if (!m || typeof m.name !== "string") return null;
1183
1248
  let body;
1184
1249
  if (typeof m.text === "string") {
1185
- // filter again on display: older messages and newly blocked words disappear
1186
- const shown = cleanMessage(m.text).text;
1187
- if (!shown) return null;
1188
- body = escapeHtml(shown).replace(/(^|\s)@([\w-]{2,16})/g, '$1<span class="at">@$2</span>');
1250
+ // mask again on display, so words added to the owner's list later get hidden in old messages too
1251
+ body = escapeHtml(maskText(m.text)).replace(/(^|\s)@([\w-]{2,16})/g, '$1<span class="at">@$2</span>');
1189
1252
  } else if (typeof m.sticker === "string" && STICKERS.includes(m.sticker)) {
1190
1253
  body = `<img class="chat-sticker" src="${STICKER_URL(m.sticker)}" alt="sticker" width="96" height="96" loading="lazy">`; } else if (typeof m.img === "string" && /^data:image\/(webp|jpeg);base64,[A-Za-z0-9+/=]+$/.test(m.img)) {
1191
1254
  body = `<button class="chat-photo-btn" type="button" data-act="view" title="Open photo"><img class="chat-photo" src="${m.img}" alt="Photo from ${escapeHtml(m.name)}" loading="lazy"></button>`;
@@ -1199,10 +1262,10 @@
1199
1262
  div.dataset.name = m.name;
1200
1263
  if (typeof m.text === "string") div.dataset.text = m.text;
1201
1264
  if (!mine && typeof m.text === "string" && mentionsMe(m.text)) div.classList.add("mention");
1202
- div.innerHTML = `${m.admin ? `<span class="badge-admin">⭐ ADMIN</span>` : ""}<span class="who" title="Mention">${escapeHtml(m.name)}</span>` +
1265
+ const title = typeof m.title === "string" && m.title.trim() ? `<span class="chat-title-pill">${escapeHtml(maskText(m.title))}</span>` : "";
1266
+ div.innerHTML = `${m.admin ? `<span class="badge-admin">⭐ ADMIN</span>` : ""}${title}<span class="who" title="Mention">${escapeHtml(maskText(m.name))}</span>` +
1203
1267
  `${body}<span class="when">${t.toLocaleTimeString([], { hour: "numeric", minute: "2-digit" })}</span>` +
1204
1268
  `<span class="msg-acts">` +
1205
- (mine ? "" : `<button class="mod act-report" type="button" data-act="report" title="Report this message">🚩</button>`) +
1206
1269
  `<button class="mod act-delete" type="button" data-act="delete" title="Delete message">πŸ—‘</button>` +
1207
1270
  (mine ? "" : `<button class="mod owner-only" type="button" data-act="purge" title="Delete everything this person sent">🧹</button>` +
1208
1271
  `<button class="mod owner-only" type="button" data-act="mute" title="Mute this person">πŸ”‡</button>` +
@@ -1246,18 +1309,16 @@
1246
1309
  if (chat.banned) return "You've been banned from sending messages. You can still read.";
1247
1310
  if (chat.mutedUntil > Date.now()) return `You're muted for ${fmtWait(chat.mutedUntil - Date.now())}.`;
1248
1311
  if (chat.settings.locked) return "Chat is locked right now. You can still read.";
1249
- const strike = chat.strikes.filter((t) => Date.now() - t < 120000);
1250
- if (strike.length >= 3) return `Too many blocked messages. Wait ${fmtWait(120000 - (Date.now() - strike[0]))}.`;
1251
1312
  return "";
1252
1313
  }
1253
1314
  function fmtWait(ms) {
1254
1315
  const m = Math.ceil(ms / 60000);
1255
1316
  return m >= 60 * 24 ? `${Math.round(m / 1440)} day${m >= 2880 ? "s" : ""}` : m >= 60 ? `${Math.round(m / 60)} hour${m >= 120 ? "s" : ""}` : `${m} minute${m === 1 ? "" : "s"}`;
1256
1317
  }
1257
- function slowSeconds() { return chat.admin ? 0 : Math.max(3, Number(chat.settings.slowMode) || 0); }
1318
+ function slowSeconds() { return chat.admin ? 0 : Number(chat.settings.slowMode) || 0; } // no cooldown unless the owner turns on slow mode
1258
1319
  function updateChatStatus() {
1259
1320
  const why = blockedReason();
1260
- ["chat-text", "chat-send", "emoji-btn", "photo-btn"].forEach((id) => { if ($(id)) $(id).disabled = !!why; });
1321
+ ["chat-text", "chat-send", "emoji-btn", "photo-btn", "cam-btn"].forEach((id) => { if ($(id)) $(id).disabled = !!why; });
1261
1322
  const slow = Number(chat.settings.slowMode) || 0;
1262
1323
  $("chat-status").textContent = why || (chat.settings.locked ? "πŸ”’ Chat is locked (only you can post)" : slow ? `🐒 Slow mode: one message every ${slow}s` : "");
1263
1324
  $("chat-status").classList.toggle("err", !!why);
@@ -1274,7 +1335,10 @@
1274
1335
  }
1275
1336
  function startTypingWatch(db) {
1276
1337
  db.ref(".info/serverTimeOffset").on("value", (s) => { typing.offset = s.val() || 0; });
1277
- db.ref("chat/typing").on("value", (snap) => { typing.others = snap.val() || {}; renderTyping(); }, () => {});
1338
+ typing.watchRef?.off();
1339
+ typing.others = {};
1340
+ typing.watchRef = db.ref(roomPath("typing"));
1341
+ typing.watchRef.on("value", (snap) => { typing.others = snap.val() || {}; renderTyping(); }, () => {});
1278
1342
  clearInterval(typing.timer);
1279
1343
  typing.timer = setInterval(renderTyping, 1000);
1280
1344
  }
@@ -1295,7 +1359,7 @@
1295
1359
  if (!app) return;
1296
1360
  typing.sentAt = Date.now();
1297
1361
  if (!typing.ref) {
1298
- typing.ref = app.database().ref(`chat/typing/${chat.uid}`);
1362
+ typing.ref = app.database().ref(roomPath(`typing/${chat.uid}`));
1299
1363
  typing.ref.onDisconnect().remove();
1300
1364
  }
1301
1365
  typing.ref.set({ name, ts: window.firebase.database.ServerValue.TIMESTAMP }).catch(() => {});
@@ -1338,7 +1402,7 @@
1338
1402
  await db.ref(`chat/flags/${key}/${chat.uid}`).set(true);
1339
1403
  chatNote(`Reported. Messages with ${HIDE_AFTER_REPORTS} reports are hidden until the owner looks at them.`);
1340
1404
  } else if (act === "delete" && (mine || chat.admin)) {
1341
- await db.ref().update({ [`chat/messages/${key}`]: null, ...(chat.admin ? { [`chat/flags/${key}`]: null } : {}) });
1405
+ await db.ref().update({ [roomPath(`messages/${key}`)]: null });
1342
1406
  } else if (!chat.admin || mine) {
1343
1407
  return;
1344
1408
  } else if (act === "purge") {
@@ -1363,9 +1427,9 @@
1363
1427
  }
1364
1428
  // Every message a person sent (and the reports on them), gone in one write
1365
1429
  async function purgeUser(db, uid) {
1366
- const snap = await db.ref("chat/messages").orderByChild("uid").equalTo(uid).once("value");
1430
+ const snap = await db.ref(roomPath("messages")).orderByChild("uid").equalTo(uid).once("value");
1367
1431
  const changes = {};
1368
- snap.forEach((c) => { changes[`chat/messages/${c.key}`] = null; changes[`chat/flags/${c.key}`] = null; });
1432
+ snap.forEach((c) => { changes[roomPath(`messages/${c.key}`)] = null; });
1369
1433
  if (Object.keys(changes).length) await db.ref().update(changes);
1370
1434
  return snap.numChildren();
1371
1435
  }
@@ -1417,6 +1481,8 @@
1417
1481
  $("admin-tools-row").hidden = !on;
1418
1482
  $("admin-reports").hidden = !on;
1419
1483
  $("admin-chat-tools").hidden = !on;
1484
+ $("admin-quotes").hidden = !on;
1485
+ if (on) { watchQuoteAdmin(); renderQuoteAdmin(); }
1420
1486
  if (on) { watchReports(); watchPunished(app.database()); fillChatTools(); renderReported(); }
1421
1487
  else unwatchReports();
1422
1488
  }
@@ -1638,8 +1704,8 @@
1638
1704
  await renderAdmin();
1639
1705
  });
1640
1706
  $("admin-clear").addEventListener("click", async () => {
1641
- if (!chat.admin || !confirm("Delete every chat message for everyone?")) return;
1642
- try { await (await getFirebase()).database().ref("chat/messages").remove(); }
1707
+ if (!chat.admin || !confirm("Delete every chat message for everyone (regular chat and live chat)?")) return;
1708
+ try { await (await getFirebase()).database().ref().update({ "chat/messages": null, "live/chat/messages": null }); } // both rooms
1643
1709
  catch { alert("Couldn't clear the chat."); }
1644
1710
  });
1645
1711
  }
@@ -1659,16 +1725,8 @@
1659
1725
  }
1660
1726
  }
1661
1727
  const m = cleanMessage($("chat-text").value);
1662
- if (m.error) {
1663
- if (m.error !== "Type a message first.") chat.strikes.push(Date.now()); // 3 blocked tries in 2 minutes = short time-out
1664
- chatNote(m.error, true);
1665
- updateChatStatus();
1666
- return;
1667
- }
1668
- if (!chat.admin && m.text.toLowerCase() === chat.lastText && Date.now() - chat.lastTextAt < 60000) { chatNote("You just sent that. No spamming.", true); return; }
1728
+ if (m.error) { chatNote(m.error, true); return; }
1669
1729
  if (await postMessage({ text: m.text })) {
1670
- chat.lastText = m.text.toLowerCase();
1671
- chat.lastTextAt = Date.now();
1672
1730
  $("chat-text").value = "";
1673
1731
  stopTyping();
1674
1732
  }
@@ -1690,25 +1748,356 @@
1690
1748
  const n = chatSender();
1691
1749
  if (!n) return false;
1692
1750
  if (!chat.admin) store.set("rug-chat-name", n.name); // never save the admin code as a remembered name
1751
+ const title = maskText($("chat-title").value.replace(/\s+/g, " ").trim()).slice(0, 20);
1752
+ store.set("rug-chat-title", title);
1693
1753
  const db = app.database();
1694
- const key = db.ref("chat/messages").push().key;
1754
+ const key = db.ref(roomPath("messages")).push().key;
1695
1755
  const TS = window.firebase.database.ServerValue.TIMESTAMP;
1696
1756
  chat.lastSent = Date.now();
1697
1757
  try {
1698
1758
  await db.ref().update({
1699
- [`chat/messages/${key}`]: { name: n.name, ts: TS, uid: chat.uid, ...fields, ...(chat.admin ? { admin: true } : {}) },
1759
+ [roomPath(`messages/${key}`)]: { name: n.name, ts: TS, uid: chat.uid, ...fields, ...(title ? { title } : {}), ...(chat.admin ? { admin: true } : {}) },
1700
1760
  [`chat/last/${chat.uid}`]: TS,
1701
- ...(fields.img ? { [`chat/photoLast/${chat.uid}`]: TS } : {}),
1702
1761
  });
1703
1762
  stats.bump("chatSent");
1704
1763
  chatNote("");
1705
1764
  return true;
1706
1765
  } catch {
1707
- chatNote(blockedReason() || (fields.img ? "Photo didn't send. You can send one photo every 30 seconds." : NOT_ALLOWED), true);
1766
+ chatNote(blockedReason() || "Didn't send. Try again.", true);
1708
1767
  return false;
1709
1768
  }
1710
1769
  }
1711
1770
 
1771
+ // ---------- Quote of the day ----------
1772
+ // Anyone can submit (quotes/pending, readable only by the owner). The owner approves them into
1773
+ // quotes/approved; the bar at the top shows one of those, a different one each day.
1774
+ const quotes = { approved: [], pending: [], sentAt: 0 };
1775
+ function dayNumber() { const d = new Date(); return Math.floor(new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime() / 86400000); }
1776
+ function showQuoteOfDay() {
1777
+ const list = quotes.approved;
1778
+ const q = list.length ? list[dayNumber() % list.length] : null;
1779
+ $("quote-text").textContent = q ? maskText(q.text) : "No quote yet. Be the first to submit one!";
1780
+ $("quote-text").classList.toggle("is-empty", !q);
1781
+ $("quote-by").textContent = q?.by ? `β€” ${maskText(q.by)}` : "";
1782
+ }
1783
+ async function startQuotes() {
1784
+ const app = await getFirebase();
1785
+ if (!app) return;
1786
+ app.database().ref("quotes/approved").orderByKey().on("value", (s) => {
1787
+ quotes.approved = [];
1788
+ s.forEach((c) => { const v = c.val(); if (v && typeof v.text === "string") quotes.approved.push({ key: c.key, ...v }); });
1789
+ showQuoteOfDay();
1790
+ if (chat.admin) renderQuoteAdmin();
1791
+ }, () => {});
1792
+ }
1793
+ function openQuoteForm() {
1794
+ $("quote-input").value = ""; $("quote-author").value = ""; $("quote-msg").textContent = "";
1795
+ $("quote-msg").classList.remove("err");
1796
+ $("quote-wrap").hidden = false;
1797
+ $("quote-input").focus();
1798
+ }
1799
+ function closeQuoteForm() { $("quote-wrap").hidden = true; }
1800
+ async function sendQuote(e) {
1801
+ e.preventDefault();
1802
+ const text = $("quote-input").value.replace(/\s+/g, " ").trim(), by = $("quote-author").value.replace(/\s+/g, " ").trim();
1803
+ const say = (t, err) => { $("quote-msg").textContent = t; $("quote-msg").classList.toggle("err", !!err); };
1804
+ if (text.length < 3) return say("Type the quote first.", true);
1805
+ if (Date.now() - quotes.sentAt < 60000) return say("You just sent one. Try again in a minute.", true);
1806
+ const app = await getFirebase();
1807
+ if (!app) return say("Quotes aren't switched on for this site.", true);
1808
+ try {
1809
+ const user = chat.uid ? { uid: chat.uid } : await ensureUser(app);
1810
+ const db = app.database(), TS = window.firebase.database.ServerValue.TIMESTAMP;
1811
+ await db.ref().update({
1812
+ [`quotes/pending/${db.ref("quotes/pending").push().key}`]: { text: text.slice(0, 140), ...(by ? { by: by.slice(0, 30) } : {}), uid: user.uid, ts: TS },
1813
+ [`quotes/last/${user.uid}`]: TS,
1814
+ });
1815
+ quotes.sentAt = Date.now();
1816
+ closeQuoteForm();
1817
+ toast("Thanks! Richard will look at your quote.");
1818
+ } catch {
1819
+ say("Couldn't send. Try again in a minute.", true);
1820
+ }
1821
+ }
1822
+ // Owner: pending submissions (approve / delete) and the approved list (delete)
1823
+ let quotesPendingRef = null;
1824
+ async function watchQuoteAdmin() {
1825
+ const app = await getFirebase();
1826
+ if (!app || !chat.admin || quotesPendingRef) return;
1827
+ quotesPendingRef = app.database().ref("quotes/pending");
1828
+ quotesPendingRef.on("value", (s) => {
1829
+ const list = [];
1830
+ s.forEach((c) => { list.push({ key: c.key, ...c.val() }); });
1831
+ quotes.pending = list.reverse();
1832
+ renderQuoteAdmin();
1833
+ }, () => { quotesPendingRef = null; });
1834
+ }
1835
+ function renderQuoteAdmin() {
1836
+ const row = (q, pending) => `<div class="report" data-key="${escapeHtml(q.key)}"><div class="body"><span class="game">β€œ${escapeHtml(q.text)}”</span>` +
1837
+ `${q.by ? `<div class="meta">β€” ${escapeHtml(q.by)}</div>` : ""}</div>` +
1838
+ (pending ? `<button class="mod" type="button" data-q="approve">βœ“ Approve</button>` : "") +
1839
+ `<button class="mod" type="button" data-q="${pending ? "delete" : "unapprove"}" title="Delete">πŸ—‘</button></div>`;
1840
+ const p = quotes.pending;
1841
+ $("quotes-count").textContent = p.length ? `(${p.length})` : "";
1842
+ $("quotes-pending").innerHTML = p.length ? p.map((q) => row(q, true)).join("") : `<p class="none">No new submissions.</p>`;
1843
+ $("quotes-approved").innerHTML = quotes.approved.length ? quotes.approved.map((q) => row(q, false)).join("") : `<p class="none">None yet.</p>`;
1844
+ }
1845
+ function bindQuotes() {
1846
+ $("quote-submit-btn").addEventListener("click", openQuoteForm);
1847
+ $("quote-form").addEventListener("submit", sendQuote);
1848
+ $("quote-close").addEventListener("click", closeQuoteForm);
1849
+ $("quote-cancel").addEventListener("click", closeQuoteForm);
1850
+ $("quote-wrap").addEventListener("click", (e) => { if (e.target === $("quote-wrap")) closeQuoteForm(); });
1851
+ const act = async (e) => {
1852
+ const b = e.target.closest("[data-q]"), row = b?.closest(".report");
1853
+ if (!row || !chat.admin) return;
1854
+ const db = (await getFirebase()).database(), key = row.dataset.key;
1855
+ try {
1856
+ if (b.dataset.q === "approve") {
1857
+ const q = quotes.pending.find((x) => x.key === key);
1858
+ await db.ref().update({ [`quotes/approved/${key}`]: { text: q.text, ...(q.by ? { by: q.by } : {}) }, [`quotes/pending/${key}`]: null });
1859
+ } else if (b.dataset.q === "delete") await db.ref(`quotes/pending/${key}`).remove();
1860
+ else if (b.dataset.q === "unapprove" && confirm("Remove this quote from the rotation?")) await db.ref(`quotes/approved/${key}`).remove();
1861
+ } catch { alert("That didn't work. Are the new database rules published?"); }
1862
+ };
1863
+ $("quotes-pending").addEventListener("click", act);
1864
+ $("quotes-approved").addEventListener("click", act);
1865
+ }
1866
+
1867
+ // ---------- Live stream ----------
1868
+ // The owner streams their screen (with its sound), camera and mic straight to each viewer's browser
1869
+ // (WebRTC). The database only carries the connection set-up messages:
1870
+ // live/state { on, screen, cam, ts } (stream ids, so viewers know which video is which)
1871
+ // live/viewers/<id> { join, offer, answer, oice/*, vice/* } one entry per watching browser
1872
+ // Each viewer gets its own copy of the stream from the owner's computer, so a handful of viewers is
1873
+ // fine; dozens would need a streaming server.
1874
+ const ICE = { iceServers: [{ urls: ["stun:stun.l.google.com:19302", "stun:stun1.l.google.com:19302"] }] };
1875
+ const live = { state: null, streams: null, peers: new Map(), viewer: null, audioCtx: null };
1876
+ async function startLiveWatch() {
1877
+ const app = await getFirebase();
1878
+ if (!app) return;
1879
+ app.database().ref("live/state").on("value", (s) => {
1880
+ const st = s.val();
1881
+ const wasOn = !!live.state;
1882
+ live.state = st && st.on ? st : null;
1883
+ document.querySelector('.rail-btn[data-nav="live"]').classList.toggle("is-live", !!live.state);
1884
+ if (live.state && !wasOn && !live.streams) toast("πŸ”΄ Richard is live! Open Live in the side bar to watch.");
1885
+ if (!live.state) stopWatching();
1886
+ if (!$("view-live").hidden) renderLive();
1887
+ }, () => {});
1888
+ }
1889
+ function renderLive() {
1890
+ const on = !!live.state, mine = !!live.streams;
1891
+ $("live-pill").hidden = !on;
1892
+ $("live-owner").hidden = !chat.admin;
1893
+ $("live-go").textContent = mine ? "β–  End stream" : "πŸ”΄ Go live";
1894
+ $("live-lede").textContent = mine ? "You're live. Everyone on the site can watch."
1895
+ : on ? "Richard is live right now." : "Nobody's live right now. When Richard goes live, it shows up here.";
1896
+ $("live-overlay").hidden = mine || !!live.viewer;
1897
+ $("live-overlay-text").textContent = on ? "Richard is live" : "Not live right now";
1898
+ $("live-watch").hidden = !on || mine;
1899
+ renderGifts();
1900
+ if (on) watchGifts();
1901
+ updateViewerCount();
1902
+ }
1903
+
1904
+ // -- owner side --
1905
+ async function goLive() {
1906
+ if (live.streams) { await endLive(); return; }
1907
+ const useScreen = $("live-use-screen").checked, useCam = $("live-use-cam").checked, useMic = $("live-use-mic").checked;
1908
+ if (!useScreen && !useCam) { toast("Pick Screen or Camera (or both)."); return; }
1909
+ try {
1910
+ const screen = useScreen ? await navigator.mediaDevices.getDisplayMedia({ video: { frameRate: 30 }, audio: true }) : null;
1911
+ const cam = useCam || useMic ? await navigator.mediaDevices.getUserMedia({ video: useCam ? { width: 640, height: 360 } : false, audio: useMic }) : null;
1912
+ // one sound track: the screen's sound and the mic mixed together
1913
+ live.audioCtx = new AudioContext();
1914
+ const mix = live.audioCtx.createMediaStreamDestination();
1915
+ for (const src of [screen, cam]) if (src?.getAudioTracks().length) live.audioCtx.createMediaStreamSource(new MediaStream(src.getAudioTracks())).connect(mix);
1916
+ const mainVideo = screen ? screen.getVideoTracks() : cam ? cam.getVideoTracks() : [];
1917
+ const screenOut = new MediaStream([...mainVideo, ...mix.stream.getAudioTracks()]);
1918
+ const camOut = screen && cam?.getVideoTracks().length ? new MediaStream(cam.getVideoTracks()) : null;
1919
+ live.streams = { screenOut, camOut, raw: [screen, cam].filter(Boolean) };
1920
+ // preview what you're sending (muted, so no echo)
1921
+ $("live-screen").srcObject = screenOut;
1922
+ $("live-cam").srcObject = camOut;
1923
+ $("live-cam").hidden = !camOut;
1924
+ screen?.getVideoTracks()[0]?.addEventListener("ended", endLive); // "Stop sharing" in the browser bar
1925
+ const db = (await getFirebase()).database();
1926
+ await db.ref("live/viewers").remove();
1927
+ db.ref("live/state").onDisconnect().remove();
1928
+ db.ref("live/viewers").onDisconnect().remove();
1929
+ await db.ref("live/state").set({ on: true, main: screenOut.id, cam: camOut ? camOut.id : null, ts: window.firebase.database.ServerValue.TIMESTAMP });
1930
+ db.ref("live/viewers").on("child_added", (s) => connectViewer(db, s.key));
1931
+ db.ref("live/viewers").on("child_removed", (s) => { live.peers.get(s.key)?.close(); live.peers.delete(s.key); updateViewerCount(); });
1932
+ renderLive();
1933
+ } catch (err) {
1934
+ console.warn(err);
1935
+ live.streams?.raw.forEach((m) => m.getTracks().forEach((t) => t.stop()));
1936
+ live.streams = null;
1937
+ toast("Couldn't start the stream (screen, camera or mic was blocked).");
1938
+ }
1939
+ }
1940
+ function updateViewerCount() { $("live-viewers").textContent = live.streams ? `${live.peers.size} watching` : ""; }
1941
+ async function connectViewer(db, id) {
1942
+ if (!live.streams || live.peers.has(id)) return;
1943
+ const pc = new RTCPeerConnection(ICE);
1944
+ live.peers.set(id, pc);
1945
+ updateViewerCount();
1946
+ const { screenOut, camOut } = live.streams;
1947
+ screenOut.getTracks().forEach((t) => pc.addTrack(t, screenOut));
1948
+ camOut?.getTracks().forEach((t) => pc.addTrack(t, camOut));
1949
+ const ref = db.ref(`live/viewers/${id}`);
1950
+ pc.onicecandidate = (e) => { if (e.candidate) ref.child("oice").push(JSON.stringify(e.candidate)); };
1951
+ pc.onconnectionstatechange = () => { if (["failed", "closed"].includes(pc.connectionState)) { live.peers.delete(id); updateViewerCount(); } };
1952
+ const offer = await pc.createOffer();
1953
+ await pc.setLocalDescription(offer);
1954
+ await ref.child("offer").set({ type: offer.type, sdp: offer.sdp });
1955
+ ref.child("answer").on("value", async (s) => { const a = s.val(); if (a && !pc.currentRemoteDescription) await pc.setRemoteDescription(a).catch(() => {}); });
1956
+ ref.child("vice").on("child_added", (s) => { pc.addIceCandidate(JSON.parse(s.val())).catch(() => {}); });
1957
+ }
1958
+ async function endLive() {
1959
+ const db = (await getFirebase())?.database();
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(() => {}); }
1961
+ live.peers.forEach((pc) => pc.close());
1962
+ live.peers.clear();
1963
+ live.streams?.raw.forEach((m) => m.getTracks().forEach((t) => t.stop()));
1964
+ live.streams = null;
1965
+ live.audioCtx?.close().catch(() => {});
1966
+ live.audioCtx = null;
1967
+ $("live-screen").srcObject = null; $("live-cam").srcObject = null; $("live-cam").hidden = true;
1968
+ renderLive();
1969
+ }
1970
+
1971
+ // -- viewer side --
1972
+ async function watchLive() {
1973
+ if (!live.state || live.viewer) return;
1974
+ const app = await getFirebase();
1975
+ const user = chat.uid ? { uid: chat.uid } : await ensureUser(app);
1976
+ const ref = app.database().ref(`live/viewers/${user.uid}`);
1977
+ const pc = new RTCPeerConnection(ICE);
1978
+ live.viewer = { pc, ref };
1979
+ pc.ontrack = (e) => {
1980
+ const stream = e.streams[0];
1981
+ if (!stream) return;
1982
+ const isCam = !!live.state?.cam && stream.id === live.state.cam;
1983
+ const el = isCam ? $("live-cam") : $("live-screen");
1984
+ if (el.srcObject !== stream) el.srcObject = stream;
1985
+ if (isCam) { $("live-cam").hidden = false; return; }
1986
+ // sound needs a tap first on some browsers: try with sound, else start muted and offer the button
1987
+ el.muted = false;
1988
+ el.play().catch(() => { el.muted = true; el.play().catch(() => {}); $("live-unmute").hidden = false; });
1989
+ };
1990
+ pc.onicecandidate = (e) => { if (e.candidate) ref.child("vice").push(JSON.stringify(e.candidate)); };
1991
+ pc.onconnectionstatechange = () => {
1992
+ if (pc.connectionState === "failed") { toast("Couldn't connect to the stream (your network may block it)."); stopWatching(); renderLive(); }
1993
+ };
1994
+ await ref.remove().catch(() => {});
1995
+ ref.onDisconnect().remove();
1996
+ await ref.set({ join: window.firebase.database.ServerValue.TIMESTAMP });
1997
+ ref.child("offer").on("value", async (s) => {
1998
+ const o = s.val();
1999
+ if (!o || pc.currentRemoteDescription) return;
2000
+ await pc.setRemoteDescription(o);
2001
+ const ans = await pc.createAnswer();
2002
+ await pc.setLocalDescription(ans);
2003
+ await ref.child("answer").set({ type: ans.type, sdp: ans.sdp });
2004
+ });
2005
+ ref.child("oice").on("child_added", (s) => { pc.addIceCandidate(JSON.parse(s.val())).catch(() => {}); });
2006
+ renderLive();
2007
+ }
2008
+ function stopWatching() {
2009
+ if (!live.viewer) return;
2010
+ const { pc, ref } = live.viewer;
2011
+ ref.child("offer").off();
2012
+ ref.child("oice").off();
2013
+ ref.remove().catch(() => {});
2014
+ pc.close();
2015
+ live.viewer = null;
2016
+ if (!live.streams) { $("live-screen").srcObject = null; $("live-cam").srcObject = null; $("live-cam").hidden = true; }
2017
+ $("live-unmute").hidden = true;
2018
+ }
2019
+ function bindLive() {
2020
+ $("live-go").addEventListener("click", goLive);
2021
+ $("live-watch").addEventListener("click", watchLive);
2022
+ $("live-unmute").addEventListener("click", () => { const v = $("live-screen"); v.muted = false; v.play().catch(() => {}); $("live-unmute").hidden = true; });
2023
+ window.addEventListener("pagehide", () => { if (live.streams) endLive(); });
2024
+ }
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
+
1712
2101
  // ---------- Emoji picker and stickers ----------
1713
2102
  // Stickers are Google's Noto animated emoji (CC BY 4.0), sent by code so only these can ever appear.
1714
2103
  // Grouped into tabs in the picker; every code here was checked to exist on Google's server
@@ -1796,10 +2185,9 @@
1796
2185
  chatNote("Couldn't check that photo, so it wasn't sent. Try again in a moment.", true);
1797
2186
  return;
1798
2187
  }
2188
+ // the one check that stays: nude photos aren't sent (the chat is full of kids)
1799
2189
  if ((verdict.Porn || 0) > 0.35 || (verdict.Hentai || 0) > 0.35 || (verdict.Sexy || 0) > 0.6) {
1800
- chat.strikes.push(Date.now());
1801
- chatNote(NOT_ALLOWED, true);
1802
- updateChatStatus();
2190
+ chatNote("That photo can't be sent here.", true);
1803
2191
  return;
1804
2192
  }
1805
2193
  const img = await shrinkPhoto(bmp);
@@ -1823,8 +2211,57 @@
1823
2211
  }
1824
2212
  throw new Error("too big");
1825
2213
  }
2214
+ // ---------- πŸ“Έ Take a photo with the camera ----------
2215
+ // Live preview β†’ snapshot (mirrored like a selfie) β†’ "Send to chat" goes through sendPhoto, so it gets
2216
+ // the same nude-photo check and shrinking as any other photo.
2217
+ let camStream = null;
2218
+ async function openCamera() {
2219
+ if (!chatSender()) return; // banned, muted, no nickname…: say so first
2220
+ $("cam-msg").textContent = "";
2221
+ showCamShot(false);
2222
+ $("cam-wrap").hidden = false;
2223
+ try {
2224
+ camStream = await navigator.mediaDevices.getUserMedia({ video: { facingMode: "user", width: { ideal: 1280 }, height: { ideal: 720 } }, audio: false });
2225
+ $("cam-video").srcObject = camStream;
2226
+ } catch {
2227
+ $("cam-msg").textContent = "Couldn't open your camera. Allow camera access in the browser and try again.";
2228
+ $("cam-msg").classList.add("err");
2229
+ }
2230
+ }
2231
+ function showCamShot(taken) {
2232
+ $("cam-video").hidden = taken; $("cam-shot").hidden = !taken;
2233
+ $("cam-snap").hidden = taken; $("cam-retake").hidden = !taken; $("cam-send").hidden = !taken;
2234
+ }
2235
+ function snapCamera() {
2236
+ const v = $("cam-video"), c = $("cam-shot");
2237
+ if (!v.videoWidth) return;
2238
+ c.width = v.videoWidth; c.height = v.videoHeight;
2239
+ const g = c.getContext("2d");
2240
+ g.translate(c.width, 0); g.scale(-1, 1); // mirror, matching the preview
2241
+ g.drawImage(v, 0, 0);
2242
+ showCamShot(true);
2243
+ }
2244
+ function closeCamera() {
2245
+ camStream?.getTracks().forEach((t) => t.stop());
2246
+ camStream = null;
2247
+ $("cam-video").srcObject = null;
2248
+ $("cam-wrap").hidden = true;
2249
+ }
2250
+ function sendCamPhoto() {
2251
+ $("cam-shot").toBlob((blob) => {
2252
+ closeCamera();
2253
+ if (blob) sendPhoto(new File([blob], "camera.jpg", { type: "image/jpeg" }));
2254
+ }, "image/jpeg", 0.9);
2255
+ }
1826
2256
  function bindChatExtras() {
2257
+ $("cam-btn").addEventListener("click", openCamera);
2258
+ $("cam-snap").addEventListener("click", snapCamera);
2259
+ $("cam-retake").addEventListener("click", () => showCamShot(false));
2260
+ $("cam-send").addEventListener("click", sendCamPhoto);
2261
+ $("cam-close").addEventListener("click", closeCamera);
2262
+ $("cam-wrap").addEventListener("click", (e) => { if (e.target === $("cam-wrap")) closeCamera(); });
1827
2263
  $("emoji-btn").addEventListener("click", () => togglePicker());
2264
+ $("chat-full-btn").addEventListener("click", () => setChatFull(!$("chat-box").classList.contains("full")));
1828
2265
  document.addEventListener("pointerdown", (e) => {
1829
2266
  if (!$("picker").hidden && !e.target.closest("#picker, #emoji-btn")) togglePicker(false);
1830
2267
  });
@@ -1850,14 +2287,19 @@
1850
2287
  // There's one chat box: it sits on the Chat page, or in the player's side dock while that's open.
1851
2288
  const CHAT_SEEN_KEY = "rug-chat-seen", CHAT_DOCK_KEY = "rug-chat-dock";
1852
2289
  function dockOpen() { return !els.player.hidden && store.get(CHAT_DOCK_KEY, false); }
1853
- function chatShowing() { return dockOpen() || (els.player.hidden && !$("view-chat").hidden); }
2290
+ function liveShowing() { return els.player.hidden && !$("view-live").hidden; }
2291
+ function chatShowing() { return dockOpen() || (els.player.hidden && !$("view-chat").hidden) || liveShowing(); }
1854
2292
  function placeChatBox() {
1855
2293
  const docked = dockOpen();
1856
2294
  $("chat-dock").hidden = !docked;
1857
2295
  $("dock-btn").setAttribute("aria-pressed", docked);
1858
- const home = docked ? $("chat-dock") : $("view-chat");
2296
+ // the one chat box sits beside a game, beside the live stream, or on the Chat page
2297
+ const home = docked ? $("chat-dock") : liveShowing() ? $("live-chat") : $("view-chat");
2298
+ switchRoom(liveShowing() && !docked ? "live" : "main");
1859
2299
  if ($("chat-box").parentNode !== home) home.appendChild($("chat-box"));
2300
+ if (!chatShowing() && $("chat-box").classList.contains("full")) setChatFull(false);
1860
2301
  if (chatShowing()) markChatSeen();
2302
+ updateHere();
1861
2303
  }
1862
2304
  function toggleDock(open = !store.get(CHAT_DOCK_KEY, false)) {
1863
2305
  store.set(CHAT_DOCK_KEY, open);
@@ -1872,6 +2314,34 @@
1872
2314
  else if (mention) b.classList.add("has-mention");
1873
2315
  });
1874
2316
  }
2317
+ // "N in chat right now": chat/here/<id> exists while this browser has the chat open (or the live stream)
2318
+ let hereRef = null, hereOn = false;
2319
+ async function updateHere() {
2320
+ const want = chatShowing();
2321
+ if (want === hereOn || !chat.uid) return;
2322
+ const app = await getFirebase();
2323
+ if (!app) return;
2324
+ hereOn = want;
2325
+ hereRef ||= app.database().ref(roomPath(`here/${chat.uid}`));
2326
+ if (want) { hereRef.onDisconnect().remove(); hereRef.set(true).catch(() => {}); }
2327
+ else hereRef.remove().catch(() => {});
2328
+ }
2329
+ function watchHere(db) {
2330
+ chat.hereWatch?.off();
2331
+ chat.hereWatch = db.ref(roomPath("here"));
2332
+ const where = chat.room === "live" ? "watching" : "in chat";
2333
+ chat.hereWatch.on("value", (s) => {
2334
+ const n = s.numChildren();
2335
+ $("chat-here-n").textContent = n <= 1 ? `Just you ${where}` : `${n} ${where} right now`;
2336
+ }, () => { $("chat-here-n").textContent = ""; });
2337
+ }
2338
+ // Full-screen chat: the chat box covers the whole page (Esc or the button leaves)
2339
+ function setChatFull(on) {
2340
+ $("chat-box").classList.toggle("full", on);
2341
+ document.body.classList.toggle("chat-full", on);
2342
+ $("chat-full-btn").textContent = on ? "βœ• Exit full screen" : "β›Ά Full screen";
2343
+ if (on) $("chat-text").focus();
2344
+ }
1875
2345
  function markChatSeen() {
1876
2346
  if (chat.newest) store.set(CHAT_SEEN_KEY, chat.newest);
1877
2347
  setUnread(false);
@@ -1919,6 +2389,8 @@
1919
2389
  const keys = CFG.panicKeys || ["`", "]"];
1920
2390
  if (keys.includes(e.key)) { e.preventDefault(); panic(); return; }
1921
2391
  if (!$("report-wrap").hidden) { if (e.key === "Escape") closeReport(); return; }
2392
+ if (!$("cam-wrap").hidden) { if (e.key === "Escape") closeCamera(); return; }
2393
+ if (e.key === "Escape" && $("chat-box").classList.contains("full")) { setChatFull(false); return; }
1922
2394
  if (!$("wheel-wrap").hidden) {
1923
2395
  if (e.key === "Escape") closeWheel();
1924
2396
  else if (e.key === " " && wheel.spinning) { e.preventDefault(); finishWheel(); } // space skips
@@ -1991,8 +2463,9 @@
1991
2463
  els.search.value = els.homeInput.value;
1992
2464
  els.homeInput.value = "";
1993
2465
  setTag("All");
1994
- go("games");
2466
+ go("games", { instant: true });
1995
2467
  els.search.focus();
2468
+ els.search.setSelectionRange(els.search.value.length, els.search.value.length); // keep typing at the end
1996
2469
  renderGrid();
1997
2470
  };
1998
2471
  els.homeInput.addEventListener("input", () => { if (els.homeInput.value.trim()) fromHome(); });
@@ -2171,13 +2644,16 @@
2171
2644
  bindAdmin();
2172
2645
  bindChatTools();
2173
2646
  bindChatExtras();
2647
+ bindQuotes();
2648
+ bindLive();
2649
+ bindGifts();
2174
2650
  bindReports();
2175
2651
  startAnalytics();
2176
2652
  startPresence();
2177
2653
  // Listen to chat from the start so the chat buttons can show a dot for new messages.
2178
2654
  // First visit: only messages from now on count as new.
2179
2655
  if (store.get(CHAT_SEEN_KEY, null) === null) store.set(CHAT_SEEN_KEY, Date.now());
2180
- if (CFG.firebase) openChat();
2656
+ if (CFG.firebase) { openChat(); startQuotes(); startLiveWatch(); }
2181
2657
  // long enough to read a joke or two (skipped when the loading screen is off)
2182
2658
  const minShow = new Promise((r) => setTimeout(r, settings.boot !== false ? 1500 : 0));
2183
2659
  const update = newerVersionUrl(2500);
package/index.html CHANGED
@@ -56,6 +56,9 @@
56
56
  <button class="rail-btn" type="button" data-nav="stats" title="Stats &amp; achievements" aria-label="Stats and achievements">
57
57
  <svg viewBox="0 0 24 24"><path d="M7 3h10v2h4v3a5 5 0 0 1-4.6 5A5 5 0 0 1 13 15.9V18h3v3H8v-3h3v-2.1A5 5 0 0 1 7.6 13 5 5 0 0 1 3 8V5h4V3Zm0 4H5v1a3 3 0 0 0 2 2.8V7Zm12 0h-2v3.8A3 3 0 0 0 19 8V7Z"/></svg>
58
58
  </button>
59
+ <button class="rail-btn live-btn" type="button" data-nav="live" title="Live stream" aria-label="Live stream">
60
+ <svg viewBox="0 0 24 24"><path d="M12 9.5a2.5 2.5 0 1 1 0 5 2.5 2.5 0 0 1 0-5ZM6.3 6.3l1.4 1.4a6 6 0 0 0 0 8.6l-1.4 1.4a8 8 0 0 1 0-11.4Zm11.4 0a8 8 0 0 1 0 11.4l-1.4-1.4a6 6 0 0 0 0-8.6l1.4-1.4ZM3.5 3.5l1.4 1.4a10 10 0 0 0 0 14.2l-1.4 1.4a12 12 0 0 1 0-17Zm17 0a12 12 0 0 1 0 17l-1.4-1.4a10 10 0 0 0 0-14.2l1.4-1.4Z"/></svg>
61
+ </button>
59
62
  <button class="rail-btn" type="button" data-nav="recent" title="Recently played" aria-label="Recently played">
60
63
  <svg viewBox="0 0 24 24"><path d="M13 3a9 9 0 1 1-8.95 10h2.02A7 7 0 1 0 13 5a6.98 6.98 0 0 0-4.94 2.06L10 9H4V3l2.64 2.64A8.97 8.97 0 0 1 13 3Zm-1 5h2v4.6l3.2 1.9-1 1.7L12 13.7V8Z"/></svg>
61
64
  </button>
@@ -80,6 +83,13 @@
80
83
  <main class="main" id="main" tabindex="-1">
81
84
  <!-- HOME -->
82
85
  <section id="view-home" class="view home">
86
+ <!-- QUOTE OF THE DAY: a bar across the top; approved quotes take turns, a new one each day -->
87
+ <div class="quote-strip" id="quote-card">
88
+ <span class="quote-label">Quote of the day</span>
89
+ <q class="quote-text" id="quote-text">No quote yet. Be the first to submit one!</q>
90
+ <span class="quote-by" id="quote-by"></span>
91
+ <button class="text-btn link" type="button" id="quote-submit-btn">✍ Submit a quote</button>
92
+ </div>
83
93
  <h1 class="wordmark">richardwho</h1>
84
94
  <form class="home-search" id="home-search" role="search">
85
95
  <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M10.5 3a7.5 7.5 0 0 1 5.96 12.06l4.24 4.24-1.42 1.42-4.24-4.24A7.5 7.5 0 1 1 10.5 3Zm0 2a5.5 5.5 0 1 0 0 11 5.5 5.5 0 0 0 0-11Z"/></svg>
@@ -88,13 +98,15 @@
88
98
  </form>
89
99
  <p class="home-sub" id="home-sub"></p>
90
100
  <p class="online" id="online" hidden><span class="online-dot"></span><span id="online-count"></span></p>
91
- <div class="bookmark-row">
92
- <!-- Dragged to the bookmarks bar, the link's text becomes the bookmark's name -->
93
- <a class="bookmark-chip" id="bookmark-link" href="https://unpkg.com/@ywkrlerche/richardwho/index.html" draggable="true" title="Drag me to your bookmarks bar"><img id="bookmark-icon" alt=""><span id="bookmark-name">richardwho</span></a>
94
- <button class="bookmark-chip latest" type="button" id="latest-btn" title="Open the newest version of the site">⟳ Latest version</button>
95
- <span class="bookmark-hint"><span class="bookmark-arrow" aria-hidden="true">↑</span> Drag richardwho to your bookmarks bar to get back fast</span>
101
+ <!-- bottom-left corner: bookmark chip, latest version, what's new -->
102
+ <div class="home-corner">
103
+ <div class="bookmark-row">
104
+ <!-- Dragged to the bookmarks bar, the link's text becomes the bookmark's name -->
105
+ <a class="bookmark-chip" id="bookmark-link" href="https://unpkg.com/@ywkrlerche/richardwho/index.html" draggable="true" title="Drag me to your bookmarks bar"><img id="bookmark-icon" alt=""><span id="bookmark-name">richardwho</span></a>
106
+ <button class="bookmark-chip latest" type="button" id="latest-btn" title="Open the newest version of the site">⟳ Latest version</button>
107
+ </div>
108
+ <p class="whats-new-row"><button class="text-btn link whats-new" type="button" data-nav="changelog" id="whats-new-link">What's new in <span id="home-version"></span></button></p>
96
109
  </div>
97
- <p class="whats-new-row"><button class="text-btn link whats-new" type="button" data-nav="changelog" id="whats-new-link">What's new in <span id="home-version"></span></button></p>
98
110
  </section>
99
111
 
100
112
  <!-- GAMES -->
@@ -150,6 +162,10 @@
150
162
  <section id="view-chat" class="view chat" hidden>
151
163
  <header class="games-head"><div><h1>Chat</h1><p class="lede">Be nice. Swears, slurs, links and personal info are blocked. Don't post photos of real people without asking them. 🚩 reports anything bad.</p></div></header>
152
164
  <div class="chat-box" id="chat-box">
165
+ <div class="chat-top">
166
+ <span class="chat-here" id="chat-here"><span class="online-dot"></span><span id="chat-here-n">Connecting…</span></span>
167
+ <button class="text-btn" type="button" id="chat-full-btn" title="Full-screen chat (Esc to leave)">β›Ά Full screen</button>
168
+ </div>
153
169
  <div class="chat-off" id="chat-off" hidden>
154
170
  <p><strong>Chat isn't switched on yet.</strong></p>
155
171
  <p>It needs the site's free Firebase database (see SETUP.md).</p>
@@ -165,9 +181,11 @@
165
181
  </div>
166
182
  <form class="chat-form" id="chat-form" autocomplete="off" hidden>
167
183
  <input id="chat-name" class="chat-name" maxlength="40" placeholder="Nickname" spellcheck="false" aria-label="Nickname">
184
+ <input id="chat-title" class="chat-name chat-title-input" maxlength="20" placeholder="Title" spellcheck="false" aria-label="Your chat title (optional)" title="A title shown next to your name, like β€œPro Gamer” (optional)">
168
185
  <input id="chat-text" class="chat-text" maxlength="200" placeholder="Say something… (drop a photo here)" aria-label="Message">
169
186
  <button class="icon-btn" type="button" id="emoji-btn" title="Emoji and stickers" aria-label="Emoji and stickers" aria-expanded="false" aria-controls="picker">😊</button>
170
- <button class="icon-btn" type="button" id="photo-btn" title="Send a photo" aria-label="Send a photo">πŸ“·</button>
187
+ <button class="icon-btn" type="button" id="photo-btn" title="Send a photo from your computer" aria-label="Send a photo">πŸ“·</button>
188
+ <button class="icon-btn" type="button" id="cam-btn" title="Take a photo with your camera" aria-label="Take a photo with your camera">πŸ“Έ</button>
171
189
  <input type="file" id="photo-input" accept="image/*" hidden>
172
190
  <button class="pill-btn" type="submit" id="chat-send">Send</button>
173
191
  </form>
@@ -203,6 +221,43 @@
203
221
  </section>
204
222
 
205
223
  <!-- SETTINGS -->
224
+ <!-- LIVE STREAM: the owner streams screen + camera + sound; anyone can watch, with chat beside it -->
225
+ <section id="view-live" class="view live" hidden>
226
+ <header class="games-head"><div><h1>Live <span class="live-pill" id="live-pill" hidden>● LIVE</span></h1><p class="lede" id="live-lede">Nobody's live right now. When Richard goes live, it shows up here.</p></div></header>
227
+ <div class="live-layout">
228
+ <div class="live-stage" id="live-stage">
229
+ <video id="live-screen" playsinline autoplay muted></video>
230
+ <video id="live-cam" playsinline autoplay muted hidden></video>
231
+ <div class="live-overlay" id="live-overlay">
232
+ <p id="live-overlay-text">Not live right now</p>
233
+ <button class="pill-btn play" type="button" id="live-watch" hidden>β–Ά Watch live</button>
234
+ </div>
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>
238
+ </div>
239
+ <div class="live-chat" id="live-chat"></div>
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>
247
+ <!-- owner only -->
248
+ <div class="set-group live-owner" id="live-owner" hidden>
249
+ <h2>Go live</h2>
250
+ <p class="set-help">Streams your screen (with its sound), your camera and your mic to everyone on the site. Your browser asks which screen or tab to share.</p>
251
+ <div class="set-row">
252
+ <label class="live-opt"><input type="checkbox" id="live-use-screen" checked> Screen</label>
253
+ <label class="live-opt"><input type="checkbox" id="live-use-cam" checked> Camera</label>
254
+ <label class="live-opt"><input type="checkbox" id="live-use-mic" checked> Mic</label>
255
+ <span class="set-hint" id="live-viewers"></span>
256
+ <button class="pill-btn danger" type="button" id="live-go">πŸ”΄ Go live</button>
257
+ </div>
258
+ </div>
259
+ </section>
260
+
206
261
  <!-- WHAT'S NEW (filled from CHANGELOG in app.js) -->
207
262
  <section id="view-changelog" class="view settings changelog" hidden>
208
263
  <header class="games-head"><div><h1>What's new</h1><p class="lede">Every update to richardwho: new stuff, games and fixes.</p></div></header>
@@ -276,6 +331,13 @@
276
331
  <h3 class="set-sub">Muted and banned</h3>
277
332
  <div class="reports" id="punished-list"></div>
278
333
  </div>
334
+ <div id="admin-quotes" hidden>
335
+ <h3 class="set-sub">Quote submissions <span id="quotes-count"></span></h3>
336
+ <p class="set-help">Approved quotes take turns at the top of the site, a new one each day.</p>
337
+ <div class="reports" id="quotes-pending"></div>
338
+ <h3 class="set-sub">Approved quotes</h3>
339
+ <div class="reports" id="quotes-approved"></div>
340
+ </div>
279
341
  <div id="admin-reports" hidden>
280
342
  <h3 class="set-sub">Game reports and requests <span id="reports-count"></span></h3>
281
343
  <div class="reports" id="reports-list"></div>
@@ -295,6 +357,37 @@
295
357
  </section>
296
358
  </main>
297
359
 
360
+ <!-- TAKE A PHOTO WITH YOUR CAMERA (sent to the chat like any photo) -->
361
+ <div class="wheel-wrap" id="cam-wrap" hidden role="dialog" aria-label="Take a photo">
362
+ <div class="wheel-card cam-card">
363
+ <button class="wheel-x" type="button" id="cam-close" aria-label="Close">βœ•</button>
364
+ <h2>Take a photo</h2>
365
+ <div class="cam-view"><video id="cam-video" playsinline autoplay muted></video><canvas id="cam-shot" hidden></canvas></div>
366
+ <p class="chat-note" id="cam-msg"></p>
367
+ <div class="wheel-actions">
368
+ <button class="pill-btn" type="button" id="cam-retake" hidden>β†Ί Retake</button>
369
+ <button class="pill-btn play" type="button" id="cam-snap">πŸ“Έ Take photo</button>
370
+ <button class="pill-btn play" type="button" id="cam-send" hidden>Send to chat</button>
371
+ </div>
372
+ </div>
373
+ </div>
374
+
375
+ <!-- SUBMIT A QUOTE (goes to the owner for approval) -->
376
+ <div class="wheel-wrap" id="quote-wrap" hidden role="dialog" aria-labelledby="quote-title">
377
+ <form class="wheel-card report-card" id="quote-form" autocomplete="off">
378
+ <button class="wheel-x" type="button" id="quote-close" aria-label="Close">βœ•</button>
379
+ <h2 id="quote-title">Submit a quote</h2>
380
+ <p class="report-sub">If Richard picks it, it shows at the top of the site for a day.</p>
381
+ <textarea class="report-input" id="quote-input" maxlength="140" rows="3" placeholder="The quote…" aria-label="Quote"></textarea>
382
+ <input class="report-input" id="quote-author" maxlength="30" placeholder="Who said it? (optional)" aria-label="Who said it">
383
+ <p class="chat-note" id="quote-msg"></p>
384
+ <div class="wheel-actions">
385
+ <button class="pill-btn" type="button" id="quote-cancel">Cancel</button>
386
+ <button class="pill-btn play" type="submit" id="quote-send">Send</button>
387
+ </div>
388
+ </form>
389
+ </div>
390
+
298
391
  <!-- REPORT A BROKEN GAME / REQUEST A GAME -->
299
392
  <div class="wheel-wrap" id="report-wrap" hidden role="dialog" aria-labelledby="report-title">
300
393
  <form class="wheel-card report-card" id="report-form" autocomplete="off">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ywkrlerche/richardwho",
3
- "version": "1.0.34",
3
+ "version": "1.0.36",
4
4
  "description": "Richards Unblocked Games",
5
5
  "license": "UNLICENSED",
6
6
  "files": [
package/style.css CHANGED
@@ -389,8 +389,13 @@ body:has(#view-games:not([hidden])) .aurora { opacity: .7; }
389
389
  .stage { position: relative; flex: 1; min-width: 0; }
390
390
  .chat-dock { width: 340px; flex: none; display: flex; border-left: 1px solid rgba(255,255,255,.08); background: #0a0a0c; }
391
391
  .chat-dock .chat-box { flex: 1; height: auto; border: 0; border-radius: 0; min-width: 0; }
392
- .chat-dock .chat-name { width: 90px; }
393
- .chat-dock .chat-form { flex-wrap: wrap; }
392
+ /* Narrow chat (beside a game or the live stream): the message box gets its own full-width line on top */
393
+ .chat-dock .chat-form, .live-chat .chat-form { flex-wrap: wrap; }
394
+ .chat-dock .chat-text, .live-chat .chat-text { flex: 1 1 100%; order: -1; }
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; }
398
+ .chat-dock .chat-box .pill-btn, .live-chat .chat-box .pill-btn { padding: 0 14px; }
394
399
  .chat-toggle[aria-pressed="true"] { background: #fff; color: #000; border-color: #fff; }
395
400
  @media (max-width: 720px) { .chat-dock { position: absolute; right: 0; top: 49px; bottom: 0; width: min(340px, 100%); z-index: 2; } }
396
401
 
@@ -549,3 +554,85 @@ body:has(#view-changelog:not([hidden])) .corner-links { display: none; }
549
554
  .clock { top: 8px; right: 8px; }
550
555
  }
551
556
  @media (prefers-reduced-motion: reduce) { .aurora span, .sweep::after, .wordmark, .boot-word { animation: none; } }
557
+
558
+ /* ---------- Chat: top line (people in chat, full screen), titles, full-screen mode ---------- */
559
+ .chat-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); }
560
+ .chat-here { display: inline-flex; align-items: center; gap: 7px; }
561
+ .chat-here .online-dot { width: 7px; height: 7px; }
562
+ .chat-title-input { width: 100px; }
563
+ .chat-title-pill { display: inline-block; margin-right: 6px; padding: 0 7px; border-radius: 9px; background: color-mix(in srgb, var(--glow-violet, #8b5cf6) 30%, transparent); color: var(--text); font-size: 11px; font-weight: 700; line-height: 18px; vertical-align: 1px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
564
+ .chat-box.full { position: fixed; inset: 0; z-index: 85; height: auto; border-radius: 0; border: 0; background: var(--bg); }
565
+ .chat-box.full .chat-log { padding: 18px max(16px, calc((100vw - 900px) / 2)); }
566
+ .chat-box.full .chat-form, .chat-box.full .chat-top { padding-left: max(12px, calc((100vw - 900px) / 2)); padding-right: max(12px, calc((100vw - 900px) / 2)); }
567
+ body.chat-full { overflow: hidden; }
568
+ @media (max-width: 720px) { .chat-title-input { width: 72px; } }
569
+
570
+ /* ---------- Quote of the day: a long bar across the top of the front page ---------- */
571
+ .quote-strip {
572
+ position: absolute; top: 14px; left: clamp(16px, 3vw, 44px); right: 150px; /* room for the clock */
573
+ display: flex; align-items: center; gap: 12px; min-width: 0; padding: 10px 16px;
574
+ border: 1px solid var(--line-2); border-radius: 6px; background: color-mix(in srgb, var(--panel) 80%, transparent); font-size: 14px;
575
+ }
576
+ .quote-label { flex: none; font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--glow-cyan, #22d3ee); }
577
+ .quote-text { flex: 0 1 auto; min-width: 0; font-style: italic; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; quotes: "β€œ" "”"; }
578
+ .quote-text.is-empty { font-style: normal; color: var(--muted); quotes: none; }
579
+ .quote-by { flex: none; color: var(--muted); font-size: 13px; }
580
+ .quote-by:empty { display: none; }
581
+ .quote-strip .text-btn.link { flex: none; margin-left: auto; font-size: 13px; }
582
+ .home { position: relative; }
583
+ @media (max-width: 720px) {
584
+ .quote-strip { right: 16px; flex-wrap: wrap; }
585
+ .quote-text { white-space: normal; flex-basis: 100%; order: 1; }
586
+ }
587
+
588
+ /* ---------- Front page, bottom-left corner: bookmark chip, latest version, what's new ---------- */
589
+ .home-corner { position: fixed; left: calc(var(--rail-w) + 14px); bottom: 12px; z-index: 5; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
590
+ .home-corner .bookmark-row { margin: 0; justify-content: flex-start; }
591
+ .home-corner .whats-new-row { margin: 0; }
592
+ @media (max-width: 720px) { .home-corner { position: static; align-items: center; margin-top: 22px; } }
593
+
594
+ /* ---------- Live ---------- */
595
+ .live { padding-top: 26px; padding-bottom: 40px; }
596
+ .live-pill { display: inline-block; vertical-align: middle; margin-left: 8px; padding: 2px 9px; border-radius: 4px; background: #dc2626; color: #fff; font-size: 13px; letter-spacing: .04em; animation: unread-pulse 1.6s ease-in-out infinite; }
597
+ .live-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 14px; align-items: stretch; margin-bottom: 16px; }
598
+ .live-stage { position: relative; aspect-ratio: 16 / 9; background: #000; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
599
+ .live-stage video { display: block; }
600
+ #live-screen { width: 100%; height: 100%; object-fit: contain; }
601
+ #live-cam { position: absolute; right: 12px; bottom: 12px; width: 24%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; border: 2px solid rgba(255,255,255,.7); box-shadow: 0 8px 24px rgba(0,0,0,.6); background: #111; }
602
+ .live-overlay { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; color: #fff; text-align: center; background: radial-gradient(circle at 50% 40%, #1e293b, #000); }
603
+ .live-overlay p { margin: 0; font-size: 18px; font-weight: 700; }
604
+ .live-overlay .pill-btn { height: 40px; padding: 0 20px; background: #dc2626; border-color: #dc2626; }
605
+ .live-unmute { position: absolute; left: 12px; bottom: 12px; }
606
+ .live-chat { min-height: 0; min-width: 0; display: flex; }
607
+ .live-chat .chat-box { flex: 1; height: auto; min-height: 360px; min-width: 0; }
608
+ .live-stage { min-width: 0; }
609
+ .live-owner .set-row { flex-wrap: wrap; }
610
+ .live-opt { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
611
+ .live-owner .pill-btn { height: 38px; padding: 0 18px; }
612
+ .rail-btn.is-live { color: #ef4444; }
613
+ .rail-btn.is-live::before { content: ""; position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: #ef4444; box-shadow: 0 0 0 2px var(--bg), 0 0 10px #ef4444; }
614
+ @media (max-width: 1000px) { .live-layout { grid-template-columns: 1fr; } .live-chat .chat-box { min-height: 420px; } }
615
+ body:has(#view-live:not([hidden])) .corner-links { display: none; }
616
+
617
+ /* Take-a-photo window */
618
+ .cam-card { width: min(560px, 100%); }
619
+ .cam-view { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: 6px; overflow: hidden; }
620
+ .cam-view video, .cam-view canvas { width: 100%; height: 100%; object-fit: cover; display: block; }
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; } }