Skip to content

Commit

Permalink
Presets: Only log 10 events
Browse files Browse the repository at this point in the history
  • Loading branch information
univrsal committed Jul 10, 2024
1 parent c166322 commit ca087a9
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions data/example.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
function on_data(e) {
console.log(e.data);
l.insertAdjacentHTML("beforeend", `<li>${e.data}</li>`);
// Only keep last 50 entries
// Only keep last 10 entries
if (!require_clear) {
count++;
if (count > 50) require_clear = true;
if (count > 10) require_clear = true;
} else {
l.children[0].remove();
}
Expand All @@ -31,7 +31,6 @@
function start_websocket() {
var ws = new WebSocket("ws://localhost:16899/");

ws.onmessage = on_data;
ws.onmessage = on_data;
ws.onerror = (e) => console.log('WebSocket error: ' + e);

Expand Down

0 comments on commit ca087a9

Please sign in to comment.