Add guest tally (on air / off air) and host connection warning

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
namandClaude Opus 5.5 committed 2026-11-06 11:35:10 -06:00
1 parent c2549bfab0
commit f5c5c593f9
7 files changed
+82 -4

No files matched your search

+13 -1
View File
@@ -53,7 +53,9 @@ function connect(){
const m = JSON.parse(ev.data);
switch (m.t) {
case 'welcome': case 'history':
log.textContent = ''; (m.history || []).forEach(x => renderMsg(log, x, 'guest')); break;
log.textContent = ''; (m.history || []).forEach(x => renderMsg(log, x, 'guest'));
if (m.t === 'welcome') setTally(!!m.onAir, false); break;
case 'onair': setTally(!!m.on, true); break;
case 'chat': renderMsg(log, m.msg, 'guest'); if (document.hidden && m.msg.who === 'host') flashTitle(); break;
case 'notice': renderMsg(log, {who:'system', text:m.text, ts:Date.now()}, 'guest'); break;
case 'answer': if (pc) await pc.setRemoteDescription({type:'answer', sdp:m.sdp}); break;
@@ -64,6 +66,16 @@ function connect(){
};
}
// ---- tally: a sign set by the host. It does not change any audio.
let tallyOn = null;
function setTally(on, announce){
if (on === tallyOn) return; tallyOn = on;
const el = $('#tally');
el.textContent = on ? '● ON AIR' : 'Off air';
el.className = 'tallybar ' + (on ? 'on' : 'off');
if (announce) note('host set the tally: ' + (on ? 'ON AIR' : 'off air'));
}
let flashT = null;
function flashTitle(){
if (flashT) return; const base = document.title; let on = false;