link the map in wpsr messages, too

This commit is contained in:
Jakob Ketterl 2019-07-14 14:33:30 +02:00
parent 6d5c8491e4
commit 69c3a63794
2 changed files with 21 additions and 6 deletions

View File

@ -1376,14 +1376,29 @@ function update_metadata(meta) {
} }
function html_escape(input) {
return $('<div/>').text(input).html()
}
function update_wsjt_panel(msg) { function update_wsjt_panel(msg) {
var $b = $('#openwebrx-panel-wsjt-message tbody'); var $b = $('#openwebrx-panel-wsjt-message tbody');
var t = new Date(msg['timestamp']); var t = new Date(msg['timestamp']);
var pad = function(i) { return ('' + i).padStart(2, "0"); } var pad = function(i) { return ('' + i).padStart(2, "0"); }
var linkedmsg = msg['msg']; var linkedmsg = msg['msg'];
if (msg['mode'] == 'FT8') {
var matches = linkedmsg.match(/(.*\s[A-Z0-9]+\s)([A-R]{2}[0-9]{2})$/); var matches = linkedmsg.match(/(.*\s[A-Z0-9]+\s)([A-R]{2}[0-9]{2})$/);
if (matches && matches[2] != 'RR73') { if (matches && matches[2] != 'RR73') {
linkedmsg = matches[1] + '<a href="/map?locator=' + matches[2] + '" target="_blank">' + matches[2] + '</a>'; linkedmsg = html_escape(matches[1]) + '<a href="/map?locator=' + matches[2] + '" target="_blank">' + matches[2] + '</a>';
} else {
linkedmsg = html_escape(linkedmsg);
}
} else if (msg['mode'] == 'WSPR') {
var matches = linkedmsg.match(/([A-Z0-9]*\s)([A-R]{2}[0-9]{2})(\s[0-9]+)/);
if (matches) {
linkedmsg = html_escape(matches[1]) + '<a href="/map?locator=' + matches[2] + '" target="_blank">' + matches[2] + '</a>' + html_escape(matches[3]);
} else {
linkedmsg = html_escape(linkedmsg);
}
} }
$b.append($( $b.append($(
'<tr data-timestamp="' + msg['timestamp'] + '">' + '<tr data-timestamp="' + msg['timestamp'] + '">' +

View File

@ -148,7 +148,7 @@ class WsjtParser(object):
locator_pattern = re.compile(".*\\s([A-Z0-9]+)\\s([A-R]{2}[0-9]{2})$") locator_pattern = re.compile(".*\\s([A-Z0-9]+)\\s([A-R]{2}[0-9]{2})$")
jt9_pattern = re.compile("^[0-9]{6} .*") jt9_pattern = re.compile("^[0-9]{6} .*")
wspr_pattern = re.compile("^[0-9]{4} .*") wspr_pattern = re.compile("^[0-9]{4} .*")
wspr_splitter_pattern = re.compile("([A-Z0-9]*)\\s([A-R]{2}[0-9]{2})\\s([0-90]+)") wspr_splitter_pattern = re.compile("([A-Z0-9]*)\\s([A-R]{2}[0-9]{2})\\s([0-9]+)")
def __init__(self, handler): def __init__(self, handler):
self.handler = handler self.handler = handler
@ -213,8 +213,8 @@ class WsjtParser(object):
out["dt"] = float(msg[9:13]) out["dt"] = float(msg[9:13])
out["freq"] = float(msg[14:24]) out["freq"] = float(msg[14:24])
out["drift"] = int(msg[25:28]) out["drift"] = int(msg[25:28])
out["mode"] = "wspr" out["mode"] = "WSPR"
wsjt_msg = msg[29:60].strip() wsjt_msg = msg[29:].strip()
out["msg"] = wsjt_msg out["msg"] = wsjt_msg
self.parseWsprMessage(wsjt_msg) self.parseWsprMessage(wsjt_msg)
return out return out