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 // rate in ft/min
function format_vert_rate_brief(rate, displayUnits) { function format_vert_rate_brief(rate, displayUnits) {
if (rate === null) { if (rate === null || rate === undefined) {
return ""; return "";
} }
if (displayUnits === "metric") { return convert_vert_rate(rate, displayUnits).toFixed(displayUnits === "metric" ? 1 : 0);
return (rate/196.85).toFixed(1); // ft/min to m/s }
} else {
return Math.round(rate); // 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 // p is a [lon, lat] coordinate

View file

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

View file

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