implement removal of old messages in the gui

This commit is contained in:
Jakob Ketterl 2019-07-07 14:31:12 +02:00
parent 1a257064f7
commit d0cecbdfd7

View File

@ -1246,20 +1246,7 @@ function on_ws_recv(evt)
update_metadata(json.value); update_metadata(json.value);
break; break;
case "wsjt_message": case "wsjt_message":
var msg = json.value; update_wsjt_panel(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($(
'<tr>' +
'<td>' + pad(t.getUTCHours()) + pad(t.getUTCMinutes()) + pad(t.getUTCSeconds()) + '</td>' +
'<td>' + msg['db'] + '</td>' +
'<td>' + msg['dt'] + '</td>' +
'<td>' + msg['freq'] + '</td>' +
'<td class="message">' + msg['msg'] + '</td>' +
'</tr>'
));
$b.scrollTop($b[0].scrollHeight);
break; break;
default: default:
console.warn('received message of unknown type: ' + json.type); 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($(
'<tr data-timestamp="' + msg['timestamp'] + '">' +
'<td>' + pad(t.getUTCHours()) + pad(t.getUTCMinutes()) + pad(t.getUTCSeconds()) + '</td>' +
'<td>' + msg['db'] + '</td>' +
'<td>' + msg['dt'] + '</td>' +
'<td>' + msg['freq'] + '</td>' +
'<td class="message">' + msg['msg'] + '</td>' +
'</tr>'
));
$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() { function hide_digitalvoice_panels() {
$(".openwebrx-meta-panel").each(function(_, p){ $(".openwebrx-meta-panel").each(function(_, p){
toggle_panel(p.id, false); toggle_panel(p.id, false);
@ -2717,6 +2734,7 @@ function secondary_demod_init()
.mousedown(secondary_demod_canvas_container_mousedown) .mousedown(secondary_demod_canvas_container_mousedown)
.mouseenter(secondary_demod_canvas_container_mousein) .mouseenter(secondary_demod_canvas_container_mousein)
.mouseleave(secondary_demod_canvas_container_mouseout); .mouseleave(secondary_demod_canvas_container_mouseout);
init_wsjt_removal_timer();
} }
function secondary_demod_start(subtype) function secondary_demod_start(subtype)