Skip to content

Commit 0df962d

Browse files
committed
Hot right now row and flame badges
- **New: "🔥 Hot right now"** row at the top of the Back Room (above Fastest climbing Aisles today), on the Back Room page, the home page's Back Room and the phone page: the games the most people are in right now, busiest first, with "N playing" and a **▲ surging** mark for games filling up fast (+3 players in 10 minutes). - **Flame badges** ("🔥 3 playing") on those games' cards and tiles. - **How:** new `e63334287a3deaa3/hot.js` reads the Online list's existing nodes (`rooms/ol-lobby/players`, which social.js already listens to, so nothing extra is downloaded) and counts each fresh player's open game. Writes nothing. Loader lines in `index.html`, `e63334287a3deaa3/index.html` and `e63334287a3deaa3/m/index.html`; README; What's new. - Limits: only games social.js advertises (the multiplayer and party games) can show; players with Hide me on aren't counted. Hidden while nobody is playing. - Risk: low, read-only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016ZY4GY6KEVGmw5xYZiPbvp
1 parent 652c7fb commit 0df962d

6 files changed

Lines changed: 158 additions & 0 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

‎e63334287a3deaa3/hot.js‎

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
/*
2+
* Hot right now (Back Room page, home page Back Room and phone page): a row near the top of the page with the games the
3+
* most people are playing at this moment, busiest first, and a small flame badge ("🔥 5 playing") on those games' cards.
4+
*
5+
* Data: the Online list's own nodes, rooms/ol-lobby/players/<uid> (social.js writes them and already listens to them, so
6+
* this listener downloads nothing extra). A player counts for the game in `g` (the game they have open, one of
7+
* social.js's GAMES keys; single-player games aren't in that list, so they never show here) while their node has a
8+
* heartbeat (`ts`) in the last 75 s, social.js's own limit. People with Hide me on have no node and aren't counted.
9+
* "Surging" (▲) marks a game with at least 3 more players than 10 minutes ago, from counts this page has kept since
10+
* it opened. The row is hidden while nobody is in a game. Writes nothing; signs in only through party.js (Party.boot).
11+
* Clicking a game opens it the way its card does (window.BackRoom.openGame on the home page and the phone page).
12+
*/
13+
(function () {
14+
'use strict';
15+
if (window.BackRoomHot) return;
16+
var PATH = 'rooms/ol-lobby/players', FRESH = 75000, SHOW = 6, BASE = '/e63334287a3deaa3/';
17+
// social.js's game keys → folder and name (only games that live in the Back Room folder).
18+
var GAMES = {
19+
sc: ['shell-crackers', 'Shell Crackers'], rk: ['rumble-karts', 'Rumble Karts'], ss: ['slipstream', 'Slipstream'],
20+
bb: ['boostball', 'Boostball'], cl: ['coil', 'Coil'], sd: ['showdown', 'Showdown'], br: ['backrooms-1v1', 'Backrooms 1v1–4v4'],
21+
cf: ['chromaflage', 'Chromaflage'], tw: ['spire', 'Spire'], sr: ['turbo-trail', 'Turbo Trail'], er: ['escapade', 'Escapade'],
22+
up: ['updraft', 'Updraft'], ph: ['odd-one-out', 'Odd One Out'], ko: ['tumble-trials', 'Tumble Trials'], dw: ['deepword', 'Deepword'],
23+
pf: ['puffer-party', 'Puffer Party'], bs: ['blockstorm', 'Blockstorm'], lh: ['lanternhold', 'Lanternhold'],
24+
hp: ['hush-pools', 'Blackwade'], vq: ['sky-duel', 'Sky Duel'], qg: ['putterby', 'Putterby'], tv: ['trivium', 'Trivium'],
25+
dz: ['drop-zone', 'Driftfall'], gd: ['lunge-line', 'Lokop']
26+
};
27+
var ES = { 'Hot right now': 'Lo más jugado ahora', 'The games people are in right now.': 'Los juegos en los que hay gente ahora mismo.', 'playing': 'jugando', 'surging': 'subiendo' };
28+
function es() { try { return !!(window.BackRoomLang && BackRoomLang.get && BackRoomLang.get() === 'es'); } catch (e) { return false; } }
29+
function T(s) { return es() && ES[s] ? ES[s] : s; }
30+
31+
var css = document.createElement('style');
32+
css.textContent =
33+
'#hotnow{padding-top:14px}' +
34+
'.hot-row{list-style:none;margin:0;padding:0 0 2px;display:flex;gap:8px;overflow-x:auto;scrollbar-width:thin}' +
35+
'.hot-it{flex:0 0 auto}' +
36+
'.hot-it a{display:flex;align-items:center;gap:10px;padding:6px 12px 6px 6px;border-radius:10px;background:var(--panel-2);border:1px solid var(--line);color:var(--ink);text-decoration:none;min-width:0}' +
37+
'.hot-it a:hover{border-color:var(--accent)}' +
38+
'.hot-it img{width:64px;height:40px;border-radius:6px;object-fit:cover;flex:none;background:var(--line)}' +
39+
'.hot-it span{display:grid;gap:2px;line-height:1.2}' +
40+
'.hot-it b{font-weight:600;white-space:nowrap}' +
41+
'.hot-it small{font-family:var(--mono);font-size:11px;font-weight:600;letter-spacing:.04em;color:#e8590c;white-space:nowrap}' +
42+
'.hot-it small i{font-style:normal;color:var(--up,#1fbf62);margin-left:6px}' +
43+
'.hot-badge{position:absolute;right:8px;top:8px;z-index:3;padding:3px 8px;border-radius:999px;background:rgba(20,10,4,.82);color:#ffb37a;' +
44+
'font:700 12px/1.2 system-ui,-apple-system,"Segoe UI",sans-serif;pointer-events:none;box-shadow:0 2px 8px rgba(0,0,0,.3);white-space:nowrap}' +
45+
'.pz .hot-badge,.grid.pz .hot-badge{top:4px;right:4px;font-size:10px;padding:2px 6px}' +
46+
'.gc .shot .hot-badge{top:auto;right:auto;left:8px;bottom:8px}' + /* the card's genre badge and i button are on top */
47+
'@media (prefers-reduced-motion:no-preference){.hot-badge{animation:hotin .4s ease-out}}' +
48+
'@keyframes hotin{from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:none}}';
49+
document.head.appendChild(css);
50+
51+
var sec = document.createElement('section');
52+
sec.id = 'hotnow'; sec.setAttribute('aria-label', 'Hot right now'); sec.hidden = true;
53+
sec.innerHTML = '<div class="pty hot"><div class="pty-top"><h2></h2><p class="pty-sub"></p></div><ol class="hot-row"></ol></div>';
54+
var $h = sec.querySelector('h2'), $sub = sec.querySelector('.pty-sub'), $row = sec.querySelector('.hot-row');
55+
var placed = false;
56+
function place() {
57+
if (placed) return;
58+
var at = document.getElementById('climbing') || document.getElementById('playingnow') || document.getElementById('party'), head = document.querySelector('header');
59+
if (!at && !head) return; placed = true;
60+
if (at && at.parentNode) at.parentNode.insertBefore(sec, at); else head.parentNode.insertBefore(sec, head.nextSibling);
61+
var party = document.getElementById('party');
62+
if (party) { var mb = getComputedStyle(party).marginBottom; if (parseFloat(mb) > 0) { sec.style.paddingTop = '0'; sec.style.marginBottom = mb; } }
63+
}
64+
65+
var raw = {}, hist = []; // hist: [{ t, c: { folder: count } }] once a minute, for "surging"
66+
function now() { try { return window.Party && Party.now ? Party.now() : Date.now(); } catch (e) { return Date.now(); } }
67+
function counts() {
68+
var t = now(), c = {};
69+
Object.keys(raw || {}).forEach(function (u) {
70+
var v = raw[u]; if (!v || typeof v.g !== 'string' || !GAMES[v.g]) return;
71+
var ts = +v.ts; if (!(ts > t - FRESH)) return;
72+
var d = GAMES[v.g][0]; c[d] = (c[d] || 0) + 1;
73+
});
74+
return c;
75+
}
76+
function before(d) {
77+
var t = Date.now() - 10 * 60000, old = null;
78+
for (var i = 0; i < hist.length; i++) if (hist[i].t <= t) old = hist[i];
79+
return old ? (old.c[d] || 0) : null;
80+
}
81+
function nameOf(d) { for (var k in GAMES) if (GAMES[k][0] === d) return GAMES[k][1]; return d; }
82+
function openIt(e, d) {
83+
var B = window.BackRoom; if (!B || !B.openGame || e.button || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;
84+
e.preventDefault(); e.stopPropagation(); B.openGame(BASE + d + '/', nameOf(d));
85+
}
86+
function badges(c) {
87+
document.querySelectorAll('.hot-badge').forEach(function (b) { b.remove(); });
88+
Object.keys(c).forEach(function (d) {
89+
var p = BASE + d + '/', label = '🔥 ' + c[d] + ' ' + T('playing');
90+
document.querySelectorAll('.gc a.shot[href="' + p + '"], .pz a[href="' + p + '"], button.tile[data-path="' + p + '"]').forEach(function (host) {
91+
if (getComputedStyle(host).position === 'static') host.style.position = 'relative';
92+
var b = document.createElement('span'); b.className = 'hot-badge'; b.textContent = label; host.appendChild(b);
93+
});
94+
});
95+
}
96+
var sigLast = '';
97+
function draw() {
98+
var c = counts(), list = Object.keys(c).sort(function (a, b) { return c[b] - c[a] || (a < b ? -1 : 1); });
99+
var sig = JSON.stringify(c) + (es() ? 'es' : 'en');
100+
if (sig === sigLast) return; sigLast = sig;
101+
place();
102+
$h.textContent = '🔥 ' + T('Hot right now'); $sub.textContent = T('The games people are in right now.');
103+
sec.hidden = !list.length;
104+
$row.textContent = '';
105+
list.slice(0, SHOW).forEach(function (d) {
106+
var li = document.createElement('li'); li.className = 'hot-it';
107+
var a = document.createElement('a'); a.href = BASE + d + '/';
108+
a.addEventListener('click', function (e) { openIt(e, d); });
109+
var im = document.createElement('img'); im.src = BASE + 'm/thumbs/' + d + '.jpg'; im.alt = ''; im.loading = 'lazy';
110+
var sp = document.createElement('span'), b = document.createElement('b'), sm = document.createElement('small');
111+
b.textContent = nameOf(d); sm.textContent = '🔥 ' + c[d] + ' ' + T('playing');
112+
var was = before(d); if (was !== null && c[d] - was >= 3) { var i = document.createElement('i'); i.textContent = '▲ ' + T('surging'); sm.appendChild(i); }
113+
sp.append(b, sm); a.append(im, sp); li.appendChild(a); $row.appendChild(li);
114+
});
115+
badges(c);
116+
}
117+
function sample() { hist.push({ t: Date.now(), c: counts() }); while (hist.length > 30) hist.shift(); }
118+
119+
function start() {
120+
var n = 0;
121+
(function wait() {
122+
if (window.Party && Party.boot) {
123+
Party.boot().then(function (b) {
124+
b.db.ref(PATH).on('value', function (s) { raw = s.val() || {}; draw(); });
125+
}).catch(function () {});
126+
setInterval(function () { sigLast = ''; draw(); }, 15000); // heartbeats go stale even when nothing changes
127+
setInterval(sample, 60000); setTimeout(sample, 3000);
128+
document.addEventListener('backroom:lang', function () { sigLast = ''; draw(); });
129+
return;
130+
}
131+
if (++n < 300) setTimeout(wait, 200);
132+
})();
133+
}
134+
window.BackRoomHot = { counts: counts, draw: draw };
135+
if (navigator.webdriver) window.__hot = { set: function (r) { raw = r || {}; sigLast = ''; draw(); }, hist: hist }; // tests only
136+
start();
137+
})();

‎e63334287a3deaa3/index.html‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,6 +1221,7 @@ <h3>Flood Crew</h3>
12211221
<script src="/e63334287a3deaa3/avismiles.js" defer></script>
12221222
<script src="/e63334287a3deaa3/playingnow.js" defer></script>
12231223
<script src="/e63334287a3deaa3/climb.js" defer></script> <!-- Fastest climbing Aisles today (climb.js) -->
1224+
<script src="/e63334287a3deaa3/hot.js" defer></script> <!-- Hot right now (hot.js) -->
12241225
<script src="/e63334287a3deaa3/door.js" defer></script>
12251226
<script src="/e63334287a3deaa3/seasons.js" defer></script>
12261227
<script src="/e63334287a3deaa3/events.js" defer></script>

‎e63334287a3deaa3/m/index.html‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ <h1><span data-door>ASC</span>oding <span>games</span></h1>
396396
var avm=document.createElement('script');avm.src=B+'avismiles.js';document.body.appendChild(avm);
397397
var pn=document.createElement('script');pn.src=B+'playingnow.js';document.body.appendChild(pn);
398398
var cl=document.createElement('script');cl.src=B+'climb.js';document.body.appendChild(cl); // Fastest climbing Aisles today (climb.js)
399+
var ht=document.createElement('script');ht.src=B+'hot.js';document.body.appendChild(ht); // Hot right now (hot.js)
399400
// Your school (school.js): fills in the [data-school] box under the header.
400401
var sk=document.createElement('script');sk.src=B+'school.js';document.body.appendChild(sk);
401402

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"kind": "feature",
3+
"title": "Hot right now",
4+
"tags": ["Back Room"],
5+
"items": [
6+
"A new Hot right now row at the top of the Back Room shows the games the most people are playing this minute.",
7+
"Busy games get a flame badge on their card with how many people are in, and a game that's filling up fast says it's surging.",
8+
"Tap one to jump straight in."
9+
],
10+
"es": {
11+
"Hot right now": "Lo más jugado ahora",
12+
"Back Room": "Back Room",
13+
"A new Hot right now row at the top of the Back Room shows the games the most people are playing this minute.": "Una nueva fila, Lo más jugado ahora, arriba del Back Room muestra los juegos con más gente jugando en este momento.",
14+
"Busy games get a flame badge on their card with how many people are in, and a game that's filling up fast says it's surging.": "Los juegos con gente llevan una insignia de fuego en su tarjeta con cuántos están dentro, y un juego que se llena rápido dice que está subiendo.",
15+
"Tap one to jump straight in.": "Toca uno para entrar directo."
16+
}
17+
}

‎index.html‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ <h3>Productivity</h3>
442442
var ai=document.createElement('script');ai.src=dir+'aisles.js';document.body.appendChild(ai);
443443
var pn=document.createElement('script');pn.src=dir+'playingnow.js';document.body.appendChild(pn); // Playing now: public parties' games (playingnow.js)
444444
var cb=document.createElement('script');cb.src=dir+'climb.js';document.body.appendChild(cb); // Fastest climbing Aisles today (climb.js)
445+
var ht=document.createElement('script');ht.src=dir+'hot.js';document.body.appendChild(ht); // Hot right now (hot.js)
445446
// The seasonal look (seasons.js) is only for the Back Room, so the home page loads it once the Back Room is open.
446447
var se=document.createElement('script');se.src=dir+'seasons.js';document.body.appendChild(se);
447448
// The Turkey Week switch (events.js) is a button in the Back Room's header, which was copied in above; this fills it in.

0 commit comments

Comments
 (0)