Skip to content

Commit 6bc680c

Browse files
authored
Merge pull request #298 from ngcoding10/queue-notify
Playing now: tell a full room when someone queues for it
2 parents dd1e267 + f9a06d6 commit 6bc680c

5 files changed

Lines changed: 139 additions & 13 deletions

File tree

‎README.md‎

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

‎e63334287a3deaa3/news-es.js‎

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎e63334287a3deaa3/news.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@
8585
*/
8686
(function () {
8787
var NEWS = [
88+
{date: '2026-11-23', version: '1.48', title: 'See when someone is waiting for your room', kind: 'feature',
89+
tags: ['Playing now'], items: [
90+
'When a room is full and someone queues for it, the people in that room are now told.'
91+
]},
8892
{date: '2026-11-23', version: '1.47', title: 'A badge for the top of each board', kind: 'feature',
8993
tags: ['Leaderboards'], items: [
9094
'Whoever is top of a game\'s main leaderboard now wears a small badge for that game next to their name.',

‎e63334287a3deaa3/playingnow.js‎

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@
3333
* the game's Play in room button); it doesn't make you a party member. The room's player count is read every 5 s
3434
* (rooms/<prefix>-<room>/players, nodes heard from within the game's own live window). Games with rounds offer
3535
* "Queue for next game" when the room is full: this tab checks every 3 s and launches as soon as there's a spot.
36-
* Nothing is written by this file.
36+
* Nothing is written by this file itself. A queue is announced through social.js (window.BackRoomOnline.queue), which
37+
* puts qg / qr / qt on the queuer's own Online node while the queue runs and takes them off when it ends, however it
38+
* ends; the people in that room get a toast there, and the room's row here says how many are queued
39+
* (BackRoomOnline.queued, with their names in the row's tooltip).
3740
*/
3841
(function () {
3942
'use strict';
@@ -58,7 +61,12 @@
5861
'That game just ended.': 'Esa partida acaba de terminar.', 'That room just filled up ({a} of {b}).': 'Esa sala se acaba de llenar ({a} de {b}).',
5962
'That room just filled up ({a} of {b}). You can queue for a spot.': 'Esa sala se acaba de llenar ({a} de {b}). Puedes hacer fila para un lugar.',
6063
'You’re in the queue for {g}. Keep this page open; you’ll join as soon as a spot opens.': 'Estás en la fila para {g}. Deja esta página abierta; entras apenas se libere un lugar.',
61-
'You left the queue.': 'Saliste de la fila.', 'No spot opened in 30 minutes, so the queue stopped. Queue again any time.': 'No se liberó ningún lugar en 30 minutos, así que la fila se detuvo. Vuelve a hacer fila cuando quieras.'
64+
'You left the queue.': 'Saliste de la fila.',
65+
'You’re in the queue for {g}, and the people in that room have been told you’re waiting. Keep this page open; you’ll join as soon as a spot opens.':
66+
'Estás en la fila para {g}, y a la gente de esa sala se le avisó que estás esperando. Deja esta página abierta; entras apenas se libere un lugar.',
67+
'You’re in the queue for {g}. People in the room can’t see you’re waiting while Hide me is on. Keep this page open; you’ll join as soon as a spot opens.':
68+
'Estás en la fila para {g}. La gente de la sala no puede ver que estás esperando mientras Ocultarme esté activado. Deja esta página abierta; entras apenas se libere un lugar.',
69+
' · {n} queued': ' · {n} en la fila', 'Queued: {w}': 'En la fila: {w}', 'No spot opened in 30 minutes, so the queue stopped. Queue again any time.': 'No se liberó ningún lugar en 30 minutos, así que la fila se detuvo. Vuelve a hacer fila cuando quieras.'
6270
});
6371
})(0);
6472
var STALE = 120000, PARTY_TTL = 15000, ROOM_TTL = 5000, QPOLL = 3000, QUEUE_MAX = 30 * 60000;
@@ -134,6 +142,9 @@
134142
var queued = null; // { id, k, r, since, busy }
135143
var test = navigator.webdriver ? { cap: {} } : null;
136144
function now() { return P && P.now ? P.now() : Date.now(); }
145+
// social.js's Online node carries the queue (qg / qr / qt) for the people in that room; this file only asks.
146+
function announce(q) { var O = window.BackRoomOnline; try { return O && O.queue ? O.queue(q) : 'off'; } catch (e) { return 'off'; } }
147+
function queuers(e) { var O = window.BackRoomOnline; try { return O && O.queued ? O.queued(e.k, e.r) : []; } catch (er) { return []; } }
137148
function capOf(k) { var c = CAP[k] || {}; return { m: (test && test.cap[k]) || c.m || (games[k] && games[k].max) || 8, l: c.l || 10000, q: !!c.q, bb: !!c.bb }; }
138149
function dbRoom(g, r) { return g.pre + r; }
139150

@@ -307,14 +318,20 @@
307318
var ac = action(e), btn = ac.a ? '<button type="button" class="btn sm' + (ac.pri ? ' primary' : '') + '" data-' + ac.a + '="' + esc(e.id) + '">' + ac.label + '</button>'
308319
: '<button type="button" class="btn sm" disabled>' + ac.label + '</button>';
309320
var room = e.n < 0 ? 'Checking the room…' : e.n === 0 ? 'Starting the game…' : T('<b>{a} of {b}</b> in the room', { a: e.n, b: e.cap });
310-
if (queued && queued.id === e.id) room = 'You’re queued · joining as soon as there’s a spot';
321+
if (queued && queued.id === e.id) room = esc(T('You’re queued · joining as soon as there’s a spot')); // (the row is data-noi18n, so translated here)
322+
// Who else is waiting for this room (their Online nodes' qg / qr / qt, through social.js), and us.
323+
var qs = queuers(e), qn = qs.length + (queued && queued.id === e.id ? 1 : 0), qtip = '';
324+
if (qn) {
325+
room += esc(T(' · {n} queued', { n: qn }));
326+
if (qs.length) qtip = ' title="' + esc(T('Queued: {w}', { w: qs.map(function (w) { return w.n + ' · ' + w.seat; }).join(', ') })) + '"';
327+
}
311328
var avs = e.who.slice(0, 3).map(function (w) { return '<span class="pn-av" style="background:' + esc(w.c) + '" data-u="' + esc(w.uid) + '">' + esc(w.n.charAt(0).toUpperCase()) + '</span>'; }).join('');
312329
return '<li class="pn-it" data-id="' + esc(e.id) + '"><img class="pn-th" alt="" loading="lazy" src="' + esc(BASE + 'm/thumbs/' + e.g.d + '.jpg') + '">' +
313330
'<span class="pn-who" data-noi18n><span class="pn-g">' + esc(e.g.n) + (e.p ? T(' · party of {n}', { n: e.p.size }) : '') + '</span>' +
314331
'<span class="pn-l"><span class="pn-avs">' + avs + '</span>' +
315332
'<span>' + (e.p ? T('Led by {n}', { n: esc(e.p.L.n) }) + (Math.max(e.n, e.who.length) > 1 ? T(' · with {w}', { w: esc(names({ who: e.who.slice(1), n: Math.max(0, e.n - 1) })) }) : '') : T('Room with {w}', { w: esc(names(e)) })) +
316333
(e.t0 ? ' · ' + esc(ago(e.t0)) : '') + '</span></span>' +
317-
'<span class="pn-r">' + room + '</span></span>' + btn + '</li>';
334+
'<span class="pn-r"' + qtip + '>' + room + '</span></span>' + btn + '</li>';
318335
}).join('');
319336
var sig = list.map(function (e) { var ac = action(e); return e.who.map(function (w) { return w.uid; }).join(',') + '>' + e.id + '>' + ac.label; }).join('|');
320337
if (sig !== lastSig) { lastSig = sig; try { document.dispatchEvent(new CustomEvent('backroom:playing')); } catch (er) {} }
@@ -330,6 +347,7 @@
330347
// ---------------- Join and queue ----------------
331348
function find(id) { return entries().filter(function (e) { return e.id === id; })[0] || null; }
332349
function go(e) {
350+
if (queued) announce(null);
333351
queued = null;
334352
say(T('Joining {n}’s {g} (room {r})…', { n: e.p ? e.p.L.n : e.who[0].n, g: e.g.n, r: e.r })); var joining = $msg.textContent;
335353
if (!P.launch(e.k, e.r)) say('Couldn’t open that game. Reload the page to update.', true);
@@ -348,10 +366,13 @@
348366
function startQueue(id) {
349367
var e = find(id); if (!e || queued) return;
350368
queued = { id: id, k: e.k, r: e.r, since: now() };
351-
say('You’re in the queue for ' + e.g.n + '. Keep this page open; you’ll join as soon as a spot opens.');
369+
var told = announce({ g: e.k, r: e.r });
370+
say(told === 'told' ? 'You’re in the queue for ' + e.g.n + ', and the people in that room have been told you’re waiting. Keep this page open; you’ll join as soon as a spot opens.'
371+
: told === 'hidden' ? 'You’re in the queue for ' + e.g.n + '. People in the room can’t see you’re waiting while Hide me is on. Keep this page open; you’ll join as soon as a spot opens.'
372+
: 'You’re in the queue for ' + e.g.n + '. Keep this page open; you’ll join as soon as a spot opens.');
352373
draw(); tickQueue();
353374
}
354-
function cancelQueue(why) { if (!queued) return; queued = null; say(why || 'You left the queue.'); draw(); }
375+
function cancelQueue(why) { if (!queued) return; queued = null; announce(null); say(why || 'You left the queue.'); draw(); }
355376
var qT = 0;
356377
function tickQueue() {
357378
clearTimeout(qT);
@@ -418,6 +439,8 @@
418439
// button works from the Online list over a game); act(uid) joins or queues, and says whether it did anything.
419440
function rowOf(u) { return entries().filter(function (e) { return e.who.some(function (w) { return w.uid === u; }); })[0] || null; }
420441
window.BackRoomPlaying = {
442+
// Whether Playing now offers a queue for this game (social.js only shows queues for these).
443+
canQueue: function (k) { return !!(games[k] && capOf(k).q); },
421444
state: function (u) {
422445
if (!db || !UID.test(String(u))) return null;
423446
var a = ads[u], look = !document.hidden && (!inGame() || !!document.querySelector('.onl-dr.open'));

0 commit comments

Comments
 (0)