Add Airframes.org and FlightAware Mode-S links

This commit is contained in:
Carlos Salaverria 2016-08-22 18:15:06 -05:00
parent 96fe1e0ee5
commit 70e86384f0
3 changed files with 33 additions and 9 deletions

View file

@ -209,11 +209,3 @@ function format_data_source(source) {
return ""; return "";
} }
function format_ident(ident) {
if (ident !== null && ident !== "") {
return "<a href=\"https://flightaware.com/live/flight/" + ident.trim() + "\">" + ident + "</a>";
}
return "";
}

View file

@ -190,6 +190,8 @@
<td id="lat" onclick="sortByLatitude();" style="text-align: right">Latitude</td> <td id="lat" onclick="sortByLatitude();" style="text-align: right">Latitude</td>
<td id="lon" onclick="sortByLongitude();" style="text-align: right">Longitude</td> <td id="lon" onclick="sortByLongitude();" style="text-align: right">Longitude</td>
<td id="data_source" onclick="sortByDataSource();" style="text-align: right">Data Source</td> <td id="data_source" onclick="sortByDataSource();" style="text-align: right">Data Source</td>
<td id="airframes_mode_s_link" style="text-align: center">Airframes.org Link</td>
<td id="flightaware_mode_s_link" style="text-align: center">FlightAware Link</td>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -211,6 +213,8 @@
<td style="text-align: right">LAT</td> <td style="text-align: right">LAT</td>
<td style="text-align: right">LON</td> <td style="text-align: right">LON</td>
<td style="text-align: right">DATA_SOURCE</td> <td style="text-align: right">DATA_SOURCE</td>
<td style="text-align: center">AIRFRAMES_MODE_S_LINK</td>
<td style="text-align: center">FLIGHTAWARE_MODE_S_LINK</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>

View file

@ -818,7 +818,7 @@ function refreshTableInfo() {
} }
// ICAO doesn't change // ICAO doesn't change
tableplane.tr.cells[2].innerHTML = format_ident(tableplane.flight); tableplane.tr.cells[2].innerHTML = getFlightAwareIdentLink(tableplane.flight);
tableplane.tr.cells[3].textContent = (tableplane.registration !== null ? tableplane.registration : ""); tableplane.tr.cells[3].textContent = (tableplane.registration !== null ? tableplane.registration : "");
tableplane.tr.cells[4].textContent = (tableplane.icaotype !== null ? tableplane.icaotype : ""); tableplane.tr.cells[4].textContent = (tableplane.icaotype !== null ? tableplane.icaotype : "");
tableplane.tr.cells[5].textContent = (tableplane.squawk !== null ? tableplane.squawk : ""); tableplane.tr.cells[5].textContent = (tableplane.squawk !== null ? tableplane.squawk : "");
@ -833,6 +833,8 @@ function refreshTableInfo() {
tableplane.tr.cells[14].textContent = (tableplane.position !== null ? tableplane.position[1].toFixed(4) : ""); tableplane.tr.cells[14].textContent = (tableplane.position !== null ? tableplane.position[1].toFixed(4) : "");
tableplane.tr.cells[15].textContent = (tableplane.position !== null ? tableplane.position[0].toFixed(4) : ""); tableplane.tr.cells[15].textContent = (tableplane.position !== null ? tableplane.position[0].toFixed(4) : "");
tableplane.tr.cells[16].textContent = format_data_source(tableplane.getDataSource()); tableplane.tr.cells[16].textContent = format_data_source(tableplane.getDataSource());
tableplane.tr.cells[17].innerHTML = getAirframesModeSLink(tableplane.icao);
tableplane.tr.cells[18].innerHTML = getFlightAwareModeSLink(tableplane.icao);
tableplane.tr.className = classes; tableplane.tr.className = classes;
$("#header_altitude_unit").text(get_unit_label("altitude", DisplayUnits)); $("#header_altitude_unit").text(get_unit_label("altitude", DisplayUnits));
@ -1124,6 +1126,8 @@ function setColumnVisibility() {
showColumn(infoTable, "#lat", !mapIsVisible); showColumn(infoTable, "#lat", !mapIsVisible);
showColumn(infoTable, "#lon", !mapIsVisible); showColumn(infoTable, "#lon", !mapIsVisible);
showColumn(infoTable, "#data_source", !mapIsVisible); showColumn(infoTable, "#data_source", !mapIsVisible);
showColumn(infoTable, "#airframes_mode_s_link", !mapIsVisible);
showColumn(infoTable, "#flightaware_mode_s_link", !mapIsVisible);
} }
function initializeUnitsSelector() { function initializeUnitsSelector() {
@ -1162,3 +1166,27 @@ function onDisplayUnitsChanged(e) {
} }
}); });
} }
function getFlightAwareIdentLink(ident) {
if (ident !== null && ident !== "") {
return "<a target=\"_blank\" href=\"https://flightaware.com/live/flight/" + ident.trim() + "\">" + ident + "</a>";
}
return "";
}
function getFlightAwareModeSLink(code) {
if (code !== null && code.length > 0 && code[0] !== '~') {
return "<a target=\"_blank\" href=\"https://flightaware.com/live/modes/" + code + "/redirect\">FlightAware: " + code.toUpperCase() + "</a>";
}
return "";
}
function getAirframesModeSLink(code) {
if (code !== null && code.length > 0 && code[0] !== '~') {
return "<a href=\"http://www.airframes.org/\" onclick=\"$('#airframes_post_icao').attr('value','" + code + "'); document.getElementById('horrible_hack').submit.call(document.getElementById('airframes_post')); return false;\">Airframes.org: " + code.toUpperCase() + "</a>";
}
return "";
}