const $ = (s) => document.querySelector(s); const id = location.pathname.split('/').filter(Boolean).pop(); let joinUrl = ''; function toast(msg) { const t = $('#toast'); t.textContent = msg; t.classList.add('show'); clearTimeout(toast._t); toast._t = setTimeout(() => t.classList.remove('show'), 1800); } async function load() { try { const meta = await (await fetch(`/api/sessions/${id}`)).json(); if (meta && meta.title) $('#qrTitle').textContent = meta.title; } catch {} try { const q = await (await fetch(`/api/sessions/${id}/qr`)).json(); joinUrl = q.url; const img = new Image(); img.alt = 'QR code'; img.src = q.dataUrl; $('#qrBig').replaceChildren(img); const link = $('#qrLink'); link.href = q.url; link.textContent = q.url; } catch { $('#qrBig').innerHTML = '
This presentation is no longer available.
'; $('#eyebrow').textContent = ''; } } $('#copyBtn').addEventListener('click', () => { if (joinUrl) navigator.clipboard.writeText(joinUrl).then(() => toast('Link copied')); }); $('#fsBtn').addEventListener('click', () => { const el = document.documentElement; if (document.fullscreenElement) document.exitFullscreen(); else el.requestFullscreen?.(); }); $('#printBtn').addEventListener('click', () => window.print()); load();