From 657653dd3b6b0113476a659245cf219fde4cdb8f Mon Sep 17 00:00:00 2001 From: you Date: Sun, 22 Mar 2026 04:45:04 +0000 Subject: [PATCH] fix: pause button crash killed WS handler registration getElementById('pktPauseBtn') was null because button is rendered by loadPackets() which runs async. Crash at line 218 prevented wsHandler from being registered at line 260. Moved to data-action event delegation which works regardless of render timing. --- public/index.html | 2 +- public/packets.js | 21 ++++++++++----------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/public/index.html b/public/index.html index 801c9166..65144d1a 100644 --- a/public/index.html +++ b/public/index.html @@ -84,7 +84,7 @@ - + diff --git a/public/packets.js b/public/packets.js index 1c969f0b..0ff64aab 100644 --- a/public/packets.js +++ b/public/packets.js @@ -213,16 +213,15 @@ if (!btn) return; if (btn.dataset.action === 'pkt-refresh') loadPackets(); else if (btn.dataset.action === 'pkt-byop') showBYOP(); - }); - - document.getElementById('pktPauseBtn').addEventListener('click', function() { - packetsPaused = !packetsPaused; - this.textContent = packetsPaused ? '▶' : '⏸'; - this.title = packetsPaused ? 'Resume live updates' : 'Pause live updates'; - this.classList.toggle('active', packetsPaused); - if (!packetsPaused && pauseBuffer.length) { - pauseBuffer.forEach(msg => wsHandler(msg)); - pauseBuffer = []; + else if (btn.dataset.action === 'pkt-pause') { + packetsPaused = !packetsPaused; + btn.textContent = packetsPaused ? '▶' : '⏸'; + btn.title = packetsPaused ? 'Resume live updates' : 'Pause live updates'; + btn.classList.toggle('active', packetsPaused); + if (!packetsPaused && pauseBuffer.length) { + pauseBuffer.forEach(msg => wsHandler(msg)); + pauseBuffer = []; + } } }); @@ -456,7 +455,7 @@

Latest Packets (${totalCount})

- +