DSC messages finally show up, URL storage moved to Utils.js.
This commit is contained in:
parent
8b226a9727
commit
0bb9cf3678
|
|
@ -103,10 +103,10 @@ MapManager.prototype.process = function(e) {
|
||||||
Utils.setVesselUrl(this.config.vessel_url);
|
Utils.setVesselUrl(this.config.vessel_url);
|
||||||
}
|
}
|
||||||
if ('flight_url' in this.config) {
|
if ('flight_url' in this.config) {
|
||||||
flight_url = this.config.flight_url;
|
Utils.setFlightUrl(this.config.flight_url);
|
||||||
}
|
}
|
||||||
if ('modes_url' in this.config) {
|
if ('modes_url' in this.config) {
|
||||||
modes_url = this.config.modes_url;
|
Utils.setIcaoUrl(this.config.modes_url);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -737,11 +737,11 @@ AircraftMarker.prototype.getInfoHTML = function(name, receiverMarker = null) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.icao) {
|
if (this.icao) {
|
||||||
detailsString += Utils.makeListItem('ICAO', Utils.linkify(this.icao, modes_url));
|
detailsString += Utils.makeListItem('ICAO', Utils.linkifyIcao(this.icao));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.aircraft) {
|
if (this.aircraft) {
|
||||||
detailsString += Utils.makeListItem('Aircraft', Utils.linkify(this.aircraft, flight_url));
|
detailsString += Utils.makeListItem('Aircraft', Utils.linkifyFlight(this.aircraft));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.squawk) {
|
if (this.squawk) {
|
||||||
|
|
@ -792,19 +792,15 @@ AircraftMarker.prototype.getInfoHTML = function(name, receiverMarker = null) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Linkify title based on what it is (flight, aircraft, ICAO code)
|
// Linkify title based on what it is (flight, aircraft, ICAO code)
|
||||||
var text = this.flight? this.flight : this.aircraft? this.aircraft : name;
|
|
||||||
var url = null;
|
|
||||||
if (this.flight && this.flight.match(/^[A-Z]{3}[0-9]+[A-Z]*$/)) {
|
if (this.flight && this.flight.match(/^[A-Z]{3}[0-9]+[A-Z]*$/)) {
|
||||||
name = this.flight;
|
name = Utils.linkifyFlight(this.flight);
|
||||||
url = flight_url;
|
|
||||||
} else if(this.aircraft) {
|
} else if(this.aircraft) {
|
||||||
name = this.aircraft;
|
name = Utils.linkifyFlight(this.aircraft);
|
||||||
url = flight_url;
|
|
||||||
} else if(name.match(/^[0-9A-F]{6}$/)) {
|
} else if(name.match(/^[0-9A-F]{6}$/)) {
|
||||||
url = modes_url;
|
name = Utils.linkifyIcao(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return '<h3>' + Utils.linkify(name, url, text) + distance + '</h3>'
|
return '<h3>' + name + distance + '</h3>'
|
||||||
+ '<div align="center">' + timeString + ' using ' + this.mode + '</div>'
|
+ '<div align="center">' + timeString + ' using ' + this.mode + '</div>'
|
||||||
+ commentString + detailsString + messageString;
|
+ commentString + detailsString + messageString;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -342,8 +342,6 @@ HfdlMessagePanel = function(el) {
|
||||||
MessagePanel.call(this, el);
|
MessagePanel.call(this, el);
|
||||||
this.initClearTimer();
|
this.initClearTimer();
|
||||||
this.modes = ['HFDL', 'VDL2', 'ADSB', 'ACARS'];
|
this.modes = ['HFDL', 'VDL2', 'ADSB', 'ACARS'];
|
||||||
this.flight_url = null;
|
|
||||||
this.modes_url = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HfdlMessagePanel.prototype = Object.create(MessagePanel.prototype);
|
HfdlMessagePanel.prototype = Object.create(MessagePanel.prototype);
|
||||||
|
|
@ -352,14 +350,6 @@ HfdlMessagePanel.prototype.supportsMessage = function(message) {
|
||||||
return this.modes.indexOf(message['mode']) >= 0;
|
return this.modes.indexOf(message['mode']) >= 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
HfdlMessagePanel.prototype.setFlightUrl = function(url) {
|
|
||||||
this.flight_url = url;
|
|
||||||
};
|
|
||||||
|
|
||||||
HfdlMessagePanel.prototype.setModeSUrl = function(url) {
|
|
||||||
this.modes_url = url;
|
|
||||||
};
|
|
||||||
|
|
||||||
HfdlMessagePanel.prototype.render = function() {
|
HfdlMessagePanel.prototype.render = function() {
|
||||||
$(this.el).append($(
|
$(this.el).append($(
|
||||||
'<table>' +
|
'<table>' +
|
||||||
|
|
@ -383,11 +373,11 @@ HfdlMessagePanel.prototype.pushMessage = function(msg) {
|
||||||
var flight =
|
var flight =
|
||||||
!msg.flight? ''
|
!msg.flight? ''
|
||||||
: !msg.flight.match(/^[A-Z]{3}[0-9]+[A-Z]*$/)? msg.flight
|
: !msg.flight.match(/^[A-Z]{3}[0-9]+[A-Z]*$/)? msg.flight
|
||||||
: Utils.linkify(msg.flight, this.flight_url);
|
: Utils.linkifyFlight(msg.flight);
|
||||||
|
|
||||||
var aircraft =
|
var aircraft =
|
||||||
msg.aircraft? Utils.linkify(msg.aircraft, this.flight_url)
|
msg.aircraft? Utils.linkifyFlight(msg.aircraft)
|
||||||
: msg.icao? Utils.linkify(msg.icao, this.modes_url)
|
: msg.icao? Utils.linkifyIcao(msg.icao)
|
||||||
: '';
|
: '';
|
||||||
|
|
||||||
var tstamp =
|
var tstamp =
|
||||||
|
|
@ -445,8 +435,6 @@ $.fn.hfdlMessagePanel = function() {
|
||||||
AdsbMessagePanel = function(el) {
|
AdsbMessagePanel = function(el) {
|
||||||
MessagePanel.call(this, el);
|
MessagePanel.call(this, el);
|
||||||
this.clearButton.css('display', 'none');
|
this.clearButton.css('display', 'none');
|
||||||
this.flight_url = null;
|
|
||||||
this.modes_url = null;
|
|
||||||
this.receiver_pos = null;
|
this.receiver_pos = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -460,14 +448,6 @@ AdsbMessagePanel.prototype.setReceiverPos = function(pos) {
|
||||||
if (pos.lat && pos.lon) this.receiver_pos = pos;
|
if (pos.lat && pos.lon) this.receiver_pos = pos;
|
||||||
};
|
};
|
||||||
|
|
||||||
AdsbMessagePanel.prototype.setFlightUrl = function(url) {
|
|
||||||
this.flight_url = url;
|
|
||||||
};
|
|
||||||
|
|
||||||
AdsbMessagePanel.prototype.setModeSUrl = function(url) {
|
|
||||||
this.modes_url = url;
|
|
||||||
};
|
|
||||||
|
|
||||||
AdsbMessagePanel.prototype.render = function() {
|
AdsbMessagePanel.prototype.render = function() {
|
||||||
$(this.el).append($(
|
$(this.el).append($(
|
||||||
'<table>' +
|
'<table>' +
|
||||||
|
|
@ -498,11 +478,11 @@ AdsbMessagePanel.prototype.pushMessage = function(msg) {
|
||||||
|
|
||||||
// Flight identificators
|
// Flight identificators
|
||||||
var flight =
|
var flight =
|
||||||
entry.flight? Utils.linkify(entry.flight, this.flight_url)
|
entry.flight? Utils.linkifyFlight(entry.flight)
|
||||||
: '';
|
: '';
|
||||||
var aircraft =
|
var aircraft =
|
||||||
entry.aircraft? Utils.linkify(entry.aircraft, this.flight_url)
|
entry.aircraft? Utils.linkifyFlight(entry.aircraft)
|
||||||
: entry.icao? Utils.linkify(entry.icao, this.modes_url)
|
: entry.icao? Utils.linkifyIcao(entry.icao)
|
||||||
: '';
|
: '';
|
||||||
|
|
||||||
// Altitude and climb / descent
|
// Altitude and climb / descent
|
||||||
|
|
@ -589,9 +569,15 @@ DscMessagePanel.prototype.render = function() {
|
||||||
|
|
||||||
DscMessagePanel.prototype.pushMessage = function(msg) {
|
DscMessagePanel.prototype.pushMessage = function(msg) {
|
||||||
var tstamp = 0;
|
var tstamp = 0;
|
||||||
var src = '*';
|
var bcolor = msg.color? msg.color : '#000';
|
||||||
var dst = '*';
|
var fcolor = msg.color? '#000' : '#FFF';
|
||||||
var data = '';
|
var src = msg.src? Utils.linkifyVessel(msg.src) : '*';
|
||||||
|
var dst = msg.dst? Utils.linkifyVessel(msg.dst) : '*';
|
||||||
|
var data = (
|
||||||
|
(msg.category? ' ' + msg.category : '')
|
||||||
|
+ (msg.format? ' ' + msg.format : '')
|
||||||
|
+ (msg.eos? ' ' + msg.eos : '')
|
||||||
|
).trim().toUpperCase();
|
||||||
|
|
||||||
// Append report
|
// Append report
|
||||||
var $b = $(this.el).find('tbody');
|
var $b = $(this.el).find('tbody');
|
||||||
|
|
@ -602,7 +588,7 @@ DscMessagePanel.prototype.pushMessage = function(msg) {
|
||||||
'<td class="dst">' + dst + '</td>' +
|
'<td class="dst">' + dst + '</td>' +
|
||||||
'<td class="data" style="text-align:left;">' + data + '</td>' +
|
'<td class="data" style="text-align:left;">' + data + '</td>' +
|
||||||
'</tr>'
|
'</tr>'
|
||||||
));
|
).css('background-color', bcolor).css('color', fcolor));
|
||||||
|
|
||||||
// Append messsage if present
|
// Append messsage if present
|
||||||
if (msg.message) {
|
if (msg.message) {
|
||||||
|
|
@ -659,10 +645,10 @@ IsmMessagePanel.prototype.formatAttr = function(msg, key) {
|
||||||
|
|
||||||
IsmMessagePanel.prototype.pushMessage = function(msg) {
|
IsmMessagePanel.prototype.pushMessage = function(msg) {
|
||||||
// Get basic information, assume white color if missing
|
// Get basic information, assume white color if missing
|
||||||
var address = msg.hasOwnProperty('id')? msg.id : "???";
|
var address = msg.hasOwnProperty('id')? msg.id : '???';
|
||||||
var device = msg.hasOwnProperty('model')? msg.model : "";
|
var device = msg.hasOwnProperty('model')? msg.model : '';
|
||||||
var tstamp = msg.hasOwnProperty('time')? msg.time : "";
|
var tstamp = msg.hasOwnProperty('time')? msg.time : '';
|
||||||
var color = msg.hasOwnProperty('color')? msg.color : "#FFF";
|
var color = msg.hasOwnProperty('color')? msg.color : '#FFF';
|
||||||
|
|
||||||
// Append message header (address, time, etc)
|
// Append message header (address, time, etc)
|
||||||
var $b = $(this.el).find('tbody');
|
var $b = $(this.el).find('tbody');
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ function Utils() {}
|
||||||
|
|
||||||
Utils.callsign_url = null;
|
Utils.callsign_url = null;
|
||||||
Utils.vessel_url = null;
|
Utils.vessel_url = null;
|
||||||
|
Utils.flight_url = null;
|
||||||
|
Utils.icao_url = null;
|
||||||
|
|
||||||
// Set URL for linkifying callsigns
|
// Set URL for linkifying callsigns
|
||||||
Utils.setCallsignUrl = function(url) {
|
Utils.setCallsignUrl = function(url) {
|
||||||
|
|
@ -17,6 +19,16 @@ Utils.setVesselUrl = function(url) {
|
||||||
this.vessel_url = url;
|
this.vessel_url = url;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Set URL for linkifying flight and aircraft IDs
|
||||||
|
Utils.setFlightUrl = function(url) {
|
||||||
|
this.flight_url = url;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Set URL for linkifying ICAO aircraft IDs
|
||||||
|
Utils.setIcaoUrl = function(url) {
|
||||||
|
this.icao_url = url;
|
||||||
|
};
|
||||||
|
|
||||||
// Escape HTML code.
|
// Escape HTML code.
|
||||||
Utils.htmlEscape = function(input) {
|
Utils.htmlEscape = function(input) {
|
||||||
return $('<div/>').text(input).html()
|
return $('<div/>').text(input).html()
|
||||||
|
|
@ -73,6 +85,16 @@ Utils.linkifyVessel = function(mmsi) {
|
||||||
return this.linkify(mmsi, this.vessel_url, mmsi, this.mmsi2country(mmsi));
|
return this.linkify(mmsi, this.vessel_url, mmsi, this.mmsi2country(mmsi));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Create link to a flight or an aircraft
|
||||||
|
Utils.linkifyFlight = function(flight, content = null) {
|
||||||
|
return this.linkify(flight, this.flight_url, content);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Create link to a MODE-S ICAO ID
|
||||||
|
Utils.linkifyIcao = function(icao, content = null) {
|
||||||
|
return this.linkify(icao, this.icao_url, content);
|
||||||
|
};
|
||||||
|
|
||||||
// Create link to tune OWRX to the given frequency and modulation.
|
// Create link to tune OWRX to the given frequency and modulation.
|
||||||
Utils.linkifyFreq = function(freq, mod) {
|
Utils.linkifyFreq = function(freq, mod) {
|
||||||
var text;
|
var text;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,3 @@
|
||||||
// Marker.linkify() uses these URLs
|
|
||||||
var flight_url = null;
|
|
||||||
var modes_url = null;
|
|
||||||
|
|
||||||
// reasonable default; will be overriden by server
|
// reasonable default; will be overriden by server
|
||||||
var retention_time = 2 * 60 * 60 * 1000;
|
var retention_time = 2 * 60 * 60 * 1000;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,3 @@
|
||||||
// Marker.linkify() uses these URLs
|
|
||||||
var flight_url = null;
|
|
||||||
var modes_url = null;
|
|
||||||
|
|
||||||
var mapSources = [
|
var mapSources = [
|
||||||
{
|
{
|
||||||
name: 'OpenStreetMap',
|
name: 'OpenStreetMap',
|
||||||
|
|
|
||||||
|
|
@ -1076,15 +1076,13 @@ function on_ws_recv(evt) {
|
||||||
if ('flight_url' in config) {
|
if ('flight_url' in config) {
|
||||||
var hfdl_panel = $('#openwebrx-panel-hfdl-message').hfdlMessagePanel();
|
var hfdl_panel = $('#openwebrx-panel-hfdl-message').hfdlMessagePanel();
|
||||||
var adsb_panel = $('#openwebrx-panel-adsb-message').adsbMessagePanel();
|
var adsb_panel = $('#openwebrx-panel-adsb-message').adsbMessagePanel();
|
||||||
hfdl_panel.setFlightUrl(config['flight_url']);
|
Utils.setFlightUrl(config['flight_url']);
|
||||||
adsb_panel.setFlightUrl(config['flight_url']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('modes_url' in config) {
|
if ('modes_url' in config) {
|
||||||
var hfdl_panel = $('#openwebrx-panel-hfdl-message').hfdlMessagePanel();
|
var hfdl_panel = $('#openwebrx-panel-hfdl-message').hfdlMessagePanel();
|
||||||
var adsb_panel = $('#openwebrx-panel-adsb-message').adsbMessagePanel();
|
var adsb_panel = $('#openwebrx-panel-adsb-message').adsbMessagePanel();
|
||||||
hfdl_panel.setModeSUrl(config['modes_url']);
|
Utils.setIcaoUrl(config['modes_url']);
|
||||||
adsb_panel.setModeSUrl(config['modes_url']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('callsign_url' in config) {
|
if ('callsign_url' in config) {
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,9 @@ class DscParser(TextParser):
|
||||||
if self.service:
|
if self.service:
|
||||||
return None
|
return None
|
||||||
# Expect JSON data in text form
|
# Expect JSON data in text form
|
||||||
logger.debug("TEXT: {0}".format(msg))
|
|
||||||
out = json.loads(msg)
|
out = json.loads(msg)
|
||||||
# Add mode name and a color to identify the sender
|
# Add mode name and a color to identify the sender
|
||||||
out["mode"] = "DSC"
|
out["mode"] = "DSC"
|
||||||
out["color"] = self.colors.getColor(out["src"])
|
out["color"] = self.colors.getColor(out["src"])
|
||||||
logger.debug("JSON: {0}".format(out))
|
logger.debug("{0}".format(out))
|
||||||
return out
|
return out
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue