|
33 | 33 | * 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 |
34 | 34 | * (rooms/<prefix>-<room>/players, nodes heard from within the game's own live window). Games with rounds offer |
35 | 35 | * "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). |
37 | 40 | */ |
38 | 41 | (function () { |
39 | 42 | 'use strict'; |
|
58 | 61 | '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}).', |
59 | 62 | '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.', |
60 | 63 | '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.' |
62 | 70 | }); |
63 | 71 | })(0); |
64 | 72 | var STALE = 120000, PARTY_TTL = 15000, ROOM_TTL = 5000, QPOLL = 3000, QUEUE_MAX = 30 * 60000; |
|
134 | 142 | var queued = null; // { id, k, r, since, busy } |
135 | 143 | var test = navigator.webdriver ? { cap: {} } : null; |
136 | 144 | 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 []; } } |
137 | 148 | 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 }; } |
138 | 149 | function dbRoom(g, r) { return g.pre + r; } |
139 | 150 |
|
|
307 | 318 | 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>' |
308 | 319 | : '<button type="button" class="btn sm" disabled>' + ac.label + '</button>'; |
309 | 320 | 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 | + } |
311 | 328 | 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(''); |
312 | 329 | 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') + '">' + |
313 | 330 | '<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>' + |
314 | 331 | '<span class="pn-l"><span class="pn-avs">' + avs + '</span>' + |
315 | 332 | '<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)) })) + |
316 | 333 | (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>'; |
318 | 335 | }).join(''); |
319 | 336 | 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('|'); |
320 | 337 | if (sig !== lastSig) { lastSig = sig; try { document.dispatchEvent(new CustomEvent('backroom:playing')); } catch (er) {} } |
|
330 | 347 | // ---------------- Join and queue ---------------- |
331 | 348 | function find(id) { return entries().filter(function (e) { return e.id === id; })[0] || null; } |
332 | 349 | function go(e) { |
| 350 | + if (queued) announce(null); |
333 | 351 | queued = null; |
334 | 352 | 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; |
335 | 353 | if (!P.launch(e.k, e.r)) say('Couldn’t open that game. Reload the page to update.', true); |
|
348 | 366 | function startQueue(id) { |
349 | 367 | var e = find(id); if (!e || queued) return; |
350 | 368 | 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.'); |
352 | 373 | draw(); tickQueue(); |
353 | 374 | } |
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(); } |
355 | 376 | var qT = 0; |
356 | 377 | function tickQueue() { |
357 | 378 | clearTimeout(qT); |
|
418 | 439 | // button works from the Online list over a game); act(uid) joins or queues, and says whether it did anything. |
419 | 440 | function rowOf(u) { return entries().filter(function (e) { return e.who.some(function (w) { return w.uid === u; }); })[0] || null; } |
420 | 441 | 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); }, |
421 | 444 | state: function (u) { |
422 | 445 | if (!db || !UID.test(String(u))) return null; |
423 | 446 | var a = ads[u], look = !document.hidden && (!inGame() || !!document.querySelector('.onl-dr.open')); |
|
0 commit comments