From 70e86384f0fcc902b1a6d003591552d62baaf3e6 Mon Sep 17 00:00:00 2001 From: Carlos Salaverria Date: Mon, 22 Aug 2016 18:15:06 -0500 Subject: [PATCH] Add Airframes.org and FlightAware Mode-S links --- public_html/formatter.js | 8 -------- public_html/index.html | 4 ++++ public_html/script.js | 30 +++++++++++++++++++++++++++++- 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/public_html/formatter.js b/public_html/formatter.js index 6669dc1..80a580f 100644 --- a/public_html/formatter.js +++ b/public_html/formatter.js @@ -209,11 +209,3 @@ function format_data_source(source) { return ""; } - -function format_ident(ident) { - if (ident !== null && ident !== "") { - return "" + ident + ""; - } - - return ""; -} \ No newline at end of file diff --git a/public_html/index.html b/public_html/index.html index d78c1e4..5af5fc5 100644 --- a/public_html/index.html +++ b/public_html/index.html @@ -190,6 +190,8 @@ Latitude Longitude Data Source + Airframes.org Link + FlightAware Link @@ -211,6 +213,8 @@ LAT LON DATA_SOURCE + AIRFRAMES_MODE_S_LINK + FLIGHTAWARE_MODE_S_LINK diff --git a/public_html/script.js b/public_html/script.js index 667a45e..8eb7681 100644 --- a/public_html/script.js +++ b/public_html/script.js @@ -818,7 +818,7 @@ function refreshTableInfo() { } // 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[4].textContent = (tableplane.icaotype !== null ? tableplane.icaotype : ""); 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[15].textContent = (tableplane.position !== null ? tableplane.position[0].toFixed(4) : ""); 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; $("#header_altitude_unit").text(get_unit_label("altitude", DisplayUnits)); @@ -1124,6 +1126,8 @@ function setColumnVisibility() { showColumn(infoTable, "#lat", !mapIsVisible); showColumn(infoTable, "#lon", !mapIsVisible); showColumn(infoTable, "#data_source", !mapIsVisible); + showColumn(infoTable, "#airframes_mode_s_link", !mapIsVisible); + showColumn(infoTable, "#flightaware_mode_s_link", !mapIsVisible); } function initializeUnitsSelector() { @@ -1162,3 +1166,27 @@ function onDisplayUnitsChanged(e) { } }); } + +function getFlightAwareIdentLink(ident) { + if (ident !== null && ident !== "") { + return "" + ident + ""; + } + + return ""; +} + +function getFlightAwareModeSLink(code) { + if (code !== null && code.length > 0 && code[0] !== '~') { + return "FlightAware: " + code.toUpperCase() + ""; + } + + return ""; +} + +function getAirframesModeSLink(code) { + if (code !== null && code.length > 0 && code[0] !== '~') { + return "Airframes.org: " + code.toUpperCase() + ""; + } + + return ""; +}