From d0cecbdfd78e1a5cc0ba9424d21942f081b366a2 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Sun, 7 Jul 2019 14:31:12 +0200 Subject: [PATCH] implement removal of old messages in the gui --- htdocs/openwebrx.js | 46 +++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/htdocs/openwebrx.js b/htdocs/openwebrx.js index 2caf7e1..7a1619c 100644 --- a/htdocs/openwebrx.js +++ b/htdocs/openwebrx.js @@ -1246,20 +1246,7 @@ function on_ws_recv(evt) update_metadata(json.value); break; case "wsjt_message": - var msg = json.value; - var $b = $('#openwebrx-panel-wsjt-message tbody'); - var t = new Date(msg['timestamp']); - var pad = function(i) { return ('' + i).padStart(2, "0"); } - $b.append($( - '' + - '' + pad(t.getUTCHours()) + pad(t.getUTCMinutes()) + pad(t.getUTCSeconds()) + '' + - '' + msg['db'] + '' + - '' + msg['dt'] + '' + - '' + msg['freq'] + '' + - '' + msg['msg'] + '' + - '' - )); - $b.scrollTop($b[0].scrollHeight); + update_wsjt_panel(json.value); break; default: console.warn('received message of unknown type: ' + json.type); @@ -1388,6 +1375,36 @@ function update_metadata(meta) { } +function update_wsjt_panel(msg) { + var $b = $('#openwebrx-panel-wsjt-message tbody'); + var t = new Date(msg['timestamp']); + var pad = function(i) { return ('' + i).padStart(2, "0"); } + $b.append($( + '' + + '' + pad(t.getUTCHours()) + pad(t.getUTCMinutes()) + pad(t.getUTCSeconds()) + '' + + '' + msg['db'] + '' + + '' + msg['dt'] + '' + + '' + msg['freq'] + '' + + '' + msg['msg'] + '' + + '' + )); + $b.scrollTop($b[0].scrollHeight); +} + +var wsjt_removal_interval; + +// remove old wsjt messages in fixed intervals +function init_wsjt_removal_timer() { + if (wsjt_removal_interval) clearInterval(wsjt_removal_interval); + setInterval(function(){ + // let's keep 2 hours that should be plenty for most users + var cutoff = new Date().getTime()- 2 * 60 * 60 * 1000; + $('#openwebrx-panel-wsjt-message tbody tr').filter(function(_, e){ + return $(e).data('timestamp') < cutoff; + }).remove(); + }, 15000); +} + function hide_digitalvoice_panels() { $(".openwebrx-meta-panel").each(function(_, p){ toggle_panel(p.id, false); @@ -2717,6 +2734,7 @@ function secondary_demod_init() .mousedown(secondary_demod_canvas_container_mousedown) .mouseenter(secondary_demod_canvas_container_mousein) .mouseleave(secondary_demod_canvas_container_mouseout); + init_wsjt_removal_timer(); } function secondary_demod_start(subtype)