Show additional data in selected aircraft info block

This commit is contained in:
Carlos Salaverria 2016-08-30 16:38:41 -05:00
parent 5de3bffcfa
commit a37c75bf83
3 changed files with 46 additions and 13 deletions

View file

@ -161,15 +161,31 @@ function convert_distance(dist, displayUnits) {
// rate in ft/min
function format_vert_rate_brief(rate, displayUnits) {
if (rate === null) {
if (rate === null || rate === undefined) {
return "";
}
if (displayUnits === "metric") {
return (rate/196.85).toFixed(1); // ft/min to m/s
} else {
return Math.round(rate);
return convert_vert_rate(rate, displayUnits).toFixed(displayUnits === "metric" ? 1 : 0);
}
// rate in ft/min
function format_vert_rate_long(rate, displayUnits) {
if (rate === null || rate === undefined) {
return "n/a";
}
var rate_text = convert_vert_rate(rate, displayUnits).toFixed(displayUnits === "metric" ? 1 : 0) + NBSP + get_unit_label("verticalRate", displayUnits);
return rate_text;
}
// rate in ft/min
function convert_vert_rate(rate, displayUnits) {
if (displayUnits === "metric") {
return (rate / 196.85); // ft/min to m/s
}
return rate;
}
// p is a [lon, lat] coordinate

View file

@ -70,7 +70,7 @@
<span id="selected_registration"></span>
<span id="selected_icaotype"></span>
<span id="selected_emergency"></span>
<a id="selected_flightaware_link" href="" target="_blank">[FlightAware]</a>
<span id="selected_flightaware_link"></span>
</td>
</tr>
@ -88,6 +88,11 @@
<td>RSSI: <span id="selected_rssi">n/a</span></td>
</tr>
<tr class="infoblock_body">
<td>Vertical rate: <span id="selected_vertical_rate">n/a</span></td>
<td>Messages: <span id="selected_message_count">n/a</span></td>
</tr>
<tr class="infoblock_body">
<td>Track: <span id="selected_track">n/a</span></td>
<td>Last seen: <span id="selected_seen">n/a</span></td>
@ -100,6 +105,9 @@
<tr class="infoblock_body">
<td colspan="2">Distance from Site: <span id="selected_sitedist">n/a</span></td>
</tr>
<tr class="infoblock_body">
<td colspan="2"><span id="selected_photo_link"></span></td>
</tr>
</table>
</div> <!-- selected_infoblock -->
<div id="sidebar_container">

View file

@ -730,13 +730,13 @@ function refreshSelected() {
if (!selected) {
return;
}
$('#selected_flightaware_link').attr('href','//flightaware.com/live/modes/'+selected.icao+'/redirect');
if (selected.flight !== null && selected.flight !== "") {
$('#selected_callsign').text(selected.flight);
$('#selected_flightaware_link').html(getFlightAwareIdentLink(selected.flight, "[FlightAware]"));
} else {
$('#selected_callsign').text('n/a');
$('#selected_flightaware_link').html(getFlightAwareModeSLink(selected.icao, "[FlightAware]"));
}
if (selected.registration !== null) {
@ -768,6 +768,7 @@ function refreshSelected() {
}
$('#selected_speed').text(format_speed_long(selected.speed, DisplayUnits));
$('#selected_vertical_rate').text(format_vert_rate_long(selected.vert_rate, DisplayUnits));
$('#selected_icao').text(selected.icao.toUpperCase());
$('#airframes_post_icao').attr('value',selected.icao);
$('#selected_track').text(format_track_long(selected.track));
@ -808,6 +809,8 @@ function refreshSelected() {
$('#selected_sitedist').text(format_distance_long(selected.sitedist, DisplayUnits));
$('#selected_rssi').text(selected.rssi.toFixed(1) + ' dBFS');
$('#selected_message_count').text(selected.messages);
$('#selected_photo_link').html(getFlightAwarePhotoLink(selected.registration));
}
// Refreshes the larger table of all the planes
@ -1251,17 +1254,23 @@ function updatePlaneFilter() {
PlaneFilter.altitudeUnits = DisplayUnits;
}
function getFlightAwareIdentLink(ident) {
function getFlightAwareIdentLink(ident, linkText) {
if (ident !== null && ident !== "") {
return "<a target=\"_blank\" href=\"https://flightaware.com/live/flight/" + ident.trim() + "\">" + ident + "</a>";
if (!linkText) {
linkText = ident;
}
return "<a target=\"_blank\" href=\"https://flightaware.com/live/flight/" + ident.trim() + "\">" + linkText + "</a>";
}
return "";
}
function getFlightAwareModeSLink(code) {
function getFlightAwareModeSLink(code, linkText) {
if (code !== null && code.length > 0 && code[0] !== '~') {
return "<a target=\"_blank\" href=\"https://flightaware.com/live/modes/" + code + "/redirect\">FlightAware: " + code.toUpperCase() + "</a>";
if (!linkText) {
linkText = "FlightAware: " + code.toUpperCase();
}
return "<a target=\"_blank\" href=\"https://flightaware.com/live/modes/" + code + "/redirect\">" + linkText + "</a>";
}
return "";