Améliorations : l'app n'attends plus l'url d'une vidéo youtube d'une
Deploy / deploy (push) Canceled after 0s
Deploy / deploy (push) Canceled after 0s
musique mais attends maintenant l'url d'une vidéo blind test
This commit is contained in:
+1
-1
@@ -6,5 +6,5 @@ COPY . .
|
||||
ENV NODE_ENV=production
|
||||
EXPOSE 3000
|
||||
USER node
|
||||
HEALTHCHECK --interval=30s --timeout=3s CMD wget -qO- http://localhost:3000/healthz || exit 1
|
||||
HEALTHCHECK --interval=30s --timeout=3s CMD wget -qO- http://127.0.0.1:3000/healthz || exit 1
|
||||
CMD ["node", "server.js"]
|
||||
|
||||
Binary file not shown.
+2
-5
@@ -5,18 +5,15 @@ services:
|
||||
container_name: blindtest
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- reverse-proxy_default # doit être le même réseau que ton conteneur traefik
|
||||
- reverse-proxy_default # même réseau que le conteneur traefik
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
|
||||
# Router HTTPS uniquement
|
||||
- "traefik.http.routers.blindtest.rule=Host(`blindtest.tuttifruitti.ddns.net`)"
|
||||
- "traefik.http.routers.blindtest.entrypoints=websecure"
|
||||
- "traefik.http.routers.blindtest.tls=true"
|
||||
- "traefik.http.routers.blindtest.tls.certresolver=letsencrypt"
|
||||
- "traefik.http.routers.blindtest.service=blindtest"
|
||||
|
||||
# Port interne du conteneur (Vaultwarden écoute en HTTP sur 80 en interne)
|
||||
# Port INTERNE du conteneur : l'appli écoute sur 3000
|
||||
- "traefik.http.services.blindtest.loadbalancer.server.port=3000"
|
||||
|
||||
networks:
|
||||
|
||||
+9
-1
@@ -20,6 +20,7 @@
|
||||
<!-- Buzzer -->
|
||||
<div id="playView" style="display:none;flex-direction:column;align-items:center;gap:20px;width:100%">
|
||||
<div class="me"><span id="meName"></span><span id="meScore"></span></div>
|
||||
<div id="toast" class="toast" hidden></div>
|
||||
<button id="buzz" disabled>BUZZ</button>
|
||||
<div id="msg"></div>
|
||||
<ul id="board" class="board" style="width:100%;max-width:420px"></ul>
|
||||
@@ -68,6 +69,14 @@ socket.on('connect', () => {
|
||||
else showJoin();
|
||||
});
|
||||
socket.on('state', s => { state = s; render(); });
|
||||
let toastTimer = null;
|
||||
socket.on('point', ({ name }) => {
|
||||
clearTimeout(toastTimer);
|
||||
const t = $('toast');
|
||||
t.textContent = me && name === me.name ? '✅ Bien joué, tu marques un point !' : `✅ ${name} marque un point !`;
|
||||
t.hidden = false;
|
||||
toastTimer = setTimeout(() => { t.hidden = true; }, 2500);
|
||||
});
|
||||
|
||||
function render() {
|
||||
if (!me) return;
|
||||
@@ -80,7 +89,6 @@ function render() {
|
||||
case 'lobby': msg = 'En attente du prochain morceau…'; label = '⏳'; break;
|
||||
case 'playing': if (locked) { msg = 'Bloqué pour ce morceau'; label = '🚫'; } else { enabled = true; msg = 'Buzze !'; } break;
|
||||
case 'buzzed': msg = state.buzzer && state.buzzer.id === me.id ? 'À toi de répondre !' : `${state.buzzer ? state.buzzer.name : ''} a buzzé`; label = '🔔'; break;
|
||||
case 'result': msg = state.buzzer ? `${state.buzzer.name} marque un point !` : ''; label = '✅'; break;
|
||||
case 'ended': msg = 'Partie terminée !'; label = '🏆'; break;
|
||||
}
|
||||
buzz.disabled = !enabled;
|
||||
|
||||
+15
-19
@@ -20,14 +20,13 @@
|
||||
<p id="joinUrl" class="small"></p>
|
||||
</div>
|
||||
<div>
|
||||
<h2>Nouveau morceau</h2>
|
||||
<p class="muted">Colle l'URL d'une vidéo YouTube puis valide.</p>
|
||||
<h2>Lancer la partie</h2>
|
||||
<p class="muted">Colle l'URL de la vidéo YouTube du blind test puis valide.</p>
|
||||
<div class="row">
|
||||
<input id="url" type="url" placeholder="https://www.youtube.com/watch?v=…" autocomplete="off">
|
||||
<button id="go" class="primary">Valider</button>
|
||||
</div>
|
||||
<p id="urlError" class="error"></p>
|
||||
<button id="endFromLobby" class="ghost">Terminer la partie</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -36,17 +35,15 @@
|
||||
<div id="game" class="card" hidden>
|
||||
<div class="video">
|
||||
<div id="yt"></div>
|
||||
<div id="mask" class="mask" hidden>🎵</div>
|
||||
</div>
|
||||
<div id="status" class="status"></div>
|
||||
<div id="toast" class="toast" hidden></div>
|
||||
<div id="judge" class="judge" hidden>
|
||||
<button id="btnTrue" class="ok">✅ Vrai</button>
|
||||
<button id="btnFalse" class="ko">❌ Faux</button>
|
||||
</div>
|
||||
<div class="row">
|
||||
<button id="next" class="primary"></button>
|
||||
<button id="endBtn" class="ghost">Terminer la partie</button>
|
||||
<label><input type="checkbox" id="hide"> Masquer la vidéo</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -72,7 +69,7 @@ const $ = id => document.getElementById(id);
|
||||
const socket = io();
|
||||
let roomId = localStorage.getItem('bt_room');
|
||||
let state = { phase: 'lobby', players: [], buzzer: null, lockedOut: [] };
|
||||
let nextVideo = null;
|
||||
let pendingVideo = null;
|
||||
|
||||
/* ---------- YouTube ---------- */
|
||||
let yt = null, ytReady = false, queued = null;
|
||||
@@ -122,6 +119,14 @@ socket.on('connect', () => {
|
||||
});
|
||||
});
|
||||
socket.on('state', s => { const prev = state.phase; state = s; render(prev); });
|
||||
let toastTimer = null;
|
||||
socket.on('point', ({ name }) => {
|
||||
clearTimeout(toastTimer);
|
||||
const t = $('toast');
|
||||
t.textContent = `✅ ${name} gagne un point !`;
|
||||
t.hidden = false;
|
||||
toastTimer = setTimeout(() => { t.hidden = true; }, 2500);
|
||||
});
|
||||
|
||||
/* ---------- Rendu ---------- */
|
||||
function sorted(players) {
|
||||
@@ -146,7 +151,7 @@ function fillBoard(el, players, medals) {
|
||||
function render(prev) {
|
||||
const ph = state.phase;
|
||||
$('lobby').hidden = ph !== 'lobby';
|
||||
$('game').hidden = !['playing', 'buzzed', 'result'].includes(ph);
|
||||
$('game').hidden = !['playing', 'buzzed'].includes(ph);
|
||||
$('endScreen').hidden = ph !== 'ended';
|
||||
$('side').hidden = ph === 'ended';
|
||||
$('mainLayout').style.gridTemplateColumns = ph === 'ended' ? '1fr' : '';
|
||||
@@ -156,7 +161,7 @@ function render(prev) {
|
||||
|
||||
// Vidéo
|
||||
if (ph !== prev) {
|
||||
if (ph === 'playing' && prev === 'lobby' && nextVideo) { loadVideo(nextVideo); nextVideo = null; }
|
||||
if (ph === 'playing' && prev === 'lobby' && pendingVideo) { loadVideo(pendingVideo); pendingVideo = null; }
|
||||
else if (ph === 'playing' && prev === 'buzzed') ytDo('playVideo');
|
||||
else if (ph === 'buzzed') ytDo('pauseVideo');
|
||||
else if (ph === 'lobby' || ph === 'ended') ytDo('stopVideo');
|
||||
@@ -169,23 +174,16 @@ function render(prev) {
|
||||
text = '🎵 Écoute… premier à buzzer !';
|
||||
if (state.lockedOut.length) text += ` (${state.lockedOut.length} bloqué${state.lockedOut.length > 1 ? 's' : ''})`;
|
||||
} else if (ph === 'buzzed') text = `🔔 ${name} propose …`;
|
||||
else if (ph === 'result') text = `✅ ${name} gagne un point !`;
|
||||
$('status').textContent = text;
|
||||
$('judge').hidden = ph !== 'buzzed';
|
||||
$('next').textContent = ph === 'result' ? 'Morceau suivant ▶' : 'Passer ce morceau ⏭';
|
||||
updateMask();
|
||||
}
|
||||
function updateMask() {
|
||||
$('mask').hidden = !($('hide').checked && state.phase !== 'result');
|
||||
}
|
||||
$('hide').addEventListener('change', updateMask);
|
||||
|
||||
/* ---------- Actions ---------- */
|
||||
function submitUrl() {
|
||||
const id = parseYoutubeId($('url').value);
|
||||
if (!id) { $('urlError').textContent = "URL YouTube invalide."; return; }
|
||||
$('urlError').textContent = '';
|
||||
nextVideo = id;
|
||||
pendingVideo = id;
|
||||
$('url').value = '';
|
||||
socket.emit('master:start');
|
||||
}
|
||||
@@ -193,9 +191,7 @@ $('go').addEventListener('click', submitUrl);
|
||||
$('url').addEventListener('keydown', e => { if (e.key === 'Enter') submitUrl(); });
|
||||
$('btnTrue').addEventListener('click', () => socket.emit('master:judge', true));
|
||||
$('btnFalse').addEventListener('click', () => socket.emit('master:judge', false));
|
||||
$('next').addEventListener('click', () => socket.emit('master:next'));
|
||||
$('endBtn').addEventListener('click', () => socket.emit('master:end'));
|
||||
$('endFromLobby').addEventListener('click', () => socket.emit('master:end'));
|
||||
$('newGame').addEventListener('click', () => socket.emit('master:newgame'));
|
||||
</script>
|
||||
</body>
|
||||
|
||||
@@ -32,6 +32,7 @@ label{color:var(--muted);display:flex;gap:6px;align-items:center}
|
||||
.video iframe{position:absolute;inset:0;width:100%;height:100%;border:0}
|
||||
.mask{position:absolute;inset:0;background:linear-gradient(135deg,#2b2250,#0f1220);display:flex;align-items:center;justify-content:center;font-size:6rem;z-index:2}
|
||||
.status{font-size:1.6rem;font-weight:800;margin:20px 0 12px;min-height:2em}
|
||||
.toast{background:var(--ok);color:#052e12;font-weight:800;padding:12px 16px;border-radius:10px;margin-bottom:16px;text-align:center}
|
||||
.judge{display:flex;gap:16px;margin-bottom:16px}
|
||||
.judge button{flex:1;font-size:1.6rem;padding:22px}
|
||||
.board{list-style:none;padding:0;margin:0;display:flex;flex-direction:column;gap:8px}
|
||||
|
||||
@@ -21,7 +21,7 @@ app.get('/qr.svg', async (req, res) => {
|
||||
});
|
||||
|
||||
/* ---------- État des rooms (en mémoire) ---------- */
|
||||
// phases : lobby | playing | buzzed | result | ended
|
||||
// phases : lobby | playing | buzzed | ended
|
||||
const rooms = new Map();
|
||||
const ROOM_RE = /^[A-Z0-9]{4,8}$/;
|
||||
const TOKEN_RE = /^[A-Za-z0-9-]{8,40}$/;
|
||||
@@ -83,24 +83,17 @@ io.on('connection', socket => {
|
||||
const room = masterRoom(socket);
|
||||
if (!room || room.phase !== 'buzzed' || !room.buzzer) return;
|
||||
const player = [...room.players.values()].find(p => p.id === room.buzzer.id);
|
||||
const buzzerName = room.buzzer.name;
|
||||
if (correct) {
|
||||
if (player) player.score += 1;
|
||||
room.phase = 'result'; // le buzzer reste affiché comme gagnant
|
||||
room.lockedOut.clear(); // bonne réponse : tout le monde peut rebuzzer sur la suite
|
||||
} else {
|
||||
room.lockedOut.add(room.buzzer.id);
|
||||
room.buzzer = null;
|
||||
room.phase = 'playing'; // la vidéo reprend, ce joueur est bloqué pour ce morceau
|
||||
room.lockedOut.add(room.buzzer.id); // mauvaise réponse : ce joueur est bloqué jusqu'à la prochaine bonne réponse
|
||||
}
|
||||
broadcast(room);
|
||||
});
|
||||
|
||||
socket.on('master:next', () => {
|
||||
const room = masterRoom(socket);
|
||||
if (!room || room.phase === 'ended') return;
|
||||
room.phase = 'lobby';
|
||||
room.buzzer = null;
|
||||
room.lockedOut.clear();
|
||||
room.phase = 'playing'; // la vidéo reprend automatiquement, sans action du master
|
||||
broadcast(room);
|
||||
if (correct) io.to(room.id).emit('point', { name: buzzerName });
|
||||
});
|
||||
|
||||
socket.on('master:end', () => {
|
||||
|
||||
Reference in New Issue
Block a user