zebra-report: trace leave click + global JS error logging

Mirror of zebra-report 6d5a2d4.
This commit is contained in:
russell@unturf.com 2026-06-03 22:41:28 -04:00
parent ccab98bee6
commit 63ff3ba5ec
No known key found for this signature in database

View file

@ -817,6 +817,17 @@ function hex(buf){ const u8=buf instanceof Uint8Array?buf:new Uint8Array(buf); r
function shortHex(s){ return s.slice(0,4)+'…'+s.slice(-4); }
const logEl = $('log');
/* Global error handler — runtime errors used to die silently (no
* stack trace anywhere), so a broken button just stopped working
* with no signal-server visibility. Now every uncaught exception
* AND unhandled-promise-rejection forwards to CLIENT_LOG as kind=err. */
window.addEventListener('error', (ev) => {
try { logLine('err', 'JS error: '+ev.message+' at '+(ev.filename||'?')+':'+(ev.lineno||'?')); } catch(_){}
});
window.addEventListener('unhandledrejection', (ev) => {
try { logLine('err', 'JS unhandled: '+(ev.reason && (ev.reason.message || ev.reason.toString()) || 'unknown')); } catch(_){}
});
function logLine(kind, msg){
const d=document.createElement('div'); d.className='log-line '+(kind||'');
d.innerHTML='<span class="ts">'+new Date().toLocaleTimeString()+'</span> '+msg.replace(/[&<>]/g,c=>({'&':'&amp;','<':'&lt;','>':'&gt;'}[c]));
@ -4864,6 +4875,7 @@ $('btn-copy-share').addEventListener('click', async () => {
* the same channel cameras/screens use so the room sees the choice */
renderGamesColumn();
$('btn-leave').addEventListener('click', async () => {
logLine('', 'leave-button: click fired');
wantConnected = false;
roomMachines.call.send('LEAVE');
/* explicit leave wipes the auto-rejoin state — user said 'out' */
@ -4932,8 +4944,8 @@ logLine('', 'ready — pick a handle, type a rendezvous code, enter the space');
<footer style="margin:2.2rem auto 0;font-size:0.65rem;color:#999;line-height:1.7;word-break:break-all;font-family:monospace">
<span id="pi-seal" style="color:#777;cursor:default;user-select:none" title="">page integrity</span> &nbsp;·&nbsp; built <span class="stamp-date">2026-06-04</span><br>
md5 <span class="stamp-md5">4801a9d879cbae20a3796724d7dc36ca</span><br>
sha256 <span class="stamp-sha">2336ee1740da7e2b833c4c9133d99645b861fabf13a1347d74678790f81e9f73</span><br>
md5 <span class="stamp-md5">7c72885fd864891bda66a349ef766a10</span><br>
sha256 <span class="stamp-sha">f691d157e5319d3fad208052da67b26ce91aba3ea79f6c1503b4583595974580</span><br>
<span style="color:#bbb">hashes are of this page with these two fields zeroed — to verify, blank them and re-hash</span><br>
<span style="color:#bbb">one self-contained file — <strong>save a copy</strong> and verify against these hashes; point at your own servers with ?signal= and ?turncred=, or <a href="host-your-own.html" style="color:#999">host your own community</a></span>
</footer>