From 94ee444be73c8a2d4a417d186a30ef1150887bfb Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Mon, 28 Aug 2023 21:57:52 +0200 Subject: [PATCH] link out from the message panel, too --- htdocs/lib/MessagePanel.js | 40 +++++++++++++++++++++++++++++++------- htdocs/openwebrx.js | 3 +++ owrx/connection.py | 1 + 3 files changed, 37 insertions(+), 7 deletions(-) diff --git a/htdocs/lib/MessagePanel.js b/htdocs/lib/MessagePanel.js index cf581c08..2792cb38 100644 --- a/htdocs/lib/MessagePanel.js +++ b/htdocs/lib/MessagePanel.js @@ -273,6 +273,7 @@ $.fn.pocsagMessagePanel = function() { AdsbMessagePanel = function(el) { MessagePanel.call(this, el); this.aircraft = {} + this.aircraftTrackingService = false; this.initClearTimer(); } @@ -287,13 +288,12 @@ AdsbMessagePanel.prototype.render = function() { '' + '' + '' + - '' + + '' + '' + '' + '' + '' + - '' + - '' + + '' + '' + '' + '' + @@ -329,15 +329,19 @@ AdsbMessagePanel.prototype.pushMessage = function(message) { return Math.round(i * 1000) / 1000; } + var getPosition = function(state) { + if (!('lat' in state) || !('lon') in state) return ''; + return '' + coordRound(state.lat) + ', ' + coordRound(state.lon) + ''; + } + state.el.html( - '' + - '' + + '' + + '' + '' + '' + '' + '' + - '' + - '' + + '' + '' ); }; @@ -361,6 +365,28 @@ AdsbMessagePanel.prototype.initClearTimer = function() { }, 15000); }; +AdsbMessagePanel.prototype.setAircraftTrackingService = function(service) { + this.aircraftTrackingService = service; +}; + +AdsbMessagePanel.prototype.linkify = function(state, text) { + var link = false; + switch (this.aircraftTrackingService) { + case 'flightaware': + link = 'https://flightaware.com/live/modes/' + state.icao; + if (state.identification) link += "/ident/" + state.identification + link += '/redirect'; + break; + case 'planefinder': + if (state.identification) link = 'https://planefinder.net/flight/' + state.identification; + break; + } + if (link) { + return '' + text + ''; + } + return text; + +}; $.fn.adsbMessagePanel = function () { if (!this.data('panel')) { diff --git a/htdocs/openwebrx.js b/htdocs/openwebrx.js index d3767774..40f5240f 100644 --- a/htdocs/openwebrx.js +++ b/htdocs/openwebrx.js @@ -788,6 +788,9 @@ function on_ws_recv(evt) { if ('tuning_precision' in config) $('#openwebrx-panel-receiver').demodulatorPanel().setTuningPrecision(config['tuning_precision']); + if ('aircraft_tracking_service' in config) + $('#openwebrx-panel-adsb-message').adsbMessagePanel().setAircraftTrackingService(config['aircraft_tracking_service']); + break; case "secondary_config": var s = json['value']; diff --git a/owrx/connection.py b/owrx/connection.py index 450f5a0a..ee8f0745 100644 --- a/owrx/connection.py +++ b/owrx/connection.py @@ -137,6 +137,7 @@ class OpenWebRxReceiverClient(OpenWebRxClient, SdrSourceEventClient): "fft_compression", "max_clients", "tuning_precision", + "aircraft_tracking_service", ] def __init__(self, conn):
ICAOCallsignFlightAltitudeSpeedTrackV/SLatLongPositionMessages
' + state.icao + '' + ifDefined(state.identification) + '' + this.linkify(state, state.icao) + '' + this.linkify(state, ifDefined(state.identification)) + '' + ifDefined(state.altitude) + '' + ifDefined(state.groundspeed || state.IAS || state.TAS, Math.round) + '' + ifDefined(state.groundtrack || state.heading, Math.round) + '' + ifDefined(state.verticalspeed) + '' + ifDefined(state.lat, coordRound) + '' + ifDefined(state.lon, coordRound) + '' + getPosition(state) + '' + state.messages + '