From 2201daaa20f53eb032c9a53cf8cd586a012f0c96 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Sun, 7 Jul 2019 22:36:34 +0200 Subject: [PATCH] click-through to selected locator on the map --- htdocs/map.js | 47 ++++++++++++++++++++++++++------------------- htdocs/openwebrx.js | 6 +++++- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/htdocs/map.js b/htdocs/map.js index 875060f..4a3309e 100644 --- a/htdocs/map.js +++ b/htdocs/map.js @@ -15,6 +15,8 @@ var expectedCallsign; if (query.callsign) expectedCallsign = query.callsign; + var expectedLocator; + if (query.locator) expectedLocator = query.locator; var ws_url = protocol + "://" + (window.location.origin.split("://")[1]) + "/ws/"; if (!("WebSocket" in window)) return; @@ -68,13 +70,15 @@ var loc = update.location.locator; var lat = (loc.charCodeAt(1) - 65 - 9) * 10 + Number(loc[3]); var lon = (loc.charCodeAt(0) - 65 - 9) * 20 + Number(loc[2]) * 2; + var center = new google.maps.LatLng({lat: lat + .5, lng: lon + 1}); var rectangle; if (rectangles[update.callsign]) { rectangle = rectangles[update.callsign]; } else { rectangle = new google.maps.Rectangle(); - var center = new google.maps.LatLng({lat: lat + .5, lng: lon + 1}); - rectangle.addListener('click', buildRectangleClick(update.location.locator, center)); + rectangle.addListener('click', function(){ + showInfoWindow(update.location.locator, center); + }); rectangles[update.callsign] = rectangle; } rectangle.setOptions($.extend({ @@ -91,6 +95,12 @@ }, getRectangleOpacityOptions(update.lastseen) )); rectangle.lastseen = update.lastseen; rectangle.locator = update.location.locator; + + if (expectedLocator && expectedLocator == update.location.locator) { + map.panTo(center); + showInfoWindow(expectedLocator, center); + delete(expectedLocator); + } break; } }); @@ -148,25 +158,22 @@ }; var infowindow; - - var buildRectangleClick = function(locator, pos) { + var showInfoWindow = function(locator, pos) { if (!infowindow) infowindow = new google.maps.InfoWindow(); - return function() { - var inLocator = $.map(rectangles, function(r, callsign) { - return {callsign: callsign, locator: r.locator} - }).filter(function(d) { - return d.locator == locator; - }); - infowindow.setContent( - '

Locator: ' + locator + '

' + - '
Active Callsigns:
' + - '' - ); - infowindow.setPosition(pos); - infowindow.open(map); - }; + var inLocator = $.map(rectangles, function(r, callsign) { + return {callsign: callsign, locator: r.locator} + }).filter(function(d) { + return d.locator == locator; + }); + infowindow.setContent( + '

Locator: ' + locator + '

' + + '
Active Callsigns:
' + + '' + ); + infowindow.setPosition(pos); + infowindow.open(map); } var getScale = function(lastseen) { diff --git a/htdocs/openwebrx.js b/htdocs/openwebrx.js index 7e936a7..fa36e68 100644 --- a/htdocs/openwebrx.js +++ b/htdocs/openwebrx.js @@ -1379,7 +1379,11 @@ 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"); } - var linkedmsg = msg['msg'].replace(/(.*\s[A-Z0-9]+\s)([A-R]{2}[0-9]{2})$/, '$1$2'); + var linkedmsg = msg['msg']; + var matches = linkedmsg.match(/(.*\s[A-Z0-9]+\s)([A-R]{2}[0-9]{2})$/); + if (matches && matches[2] != 'RR73') { + linkedmsg = matches[1] + '' + matches[2] + ''; + } $b.append($( '' + '' + pad(t.getUTCHours()) + pad(t.getUTCMinutes()) + pad(t.getUTCSeconds()) + '' +