Cleanup of old aviation API, moved sensitive data to new directories
This commit is contained in:
+3
-1
@@ -5,4 +5,6 @@ json/keys.json
|
||||
/tiles/
|
||||
/data/aircraft1.json
|
||||
/data/battery.json
|
||||
/data/
|
||||
/data/
|
||||
/.vscode/
|
||||
/information_files
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+1
-2
@@ -9,7 +9,7 @@
|
||||
var keys = {}
|
||||
// API Keys
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", "tiles/keys.json", true);
|
||||
xhr.open("GET", "information/keys.json", true);
|
||||
xhr.setRequestHeader('Content-Type', 'application/json');
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState === 4) {
|
||||
@@ -20,7 +20,6 @@ xhr.send();
|
||||
|
||||
|
||||
var ol3d
|
||||
var cesuim_active = false
|
||||
var internet_mode = 0
|
||||
var lastMETAR = 0
|
||||
var lastItin = 0
|
||||
|
||||
+71
-240
@@ -1,15 +1,77 @@
|
||||
// Generic update function for radar subtabs
|
||||
function updateFlightTab() {
|
||||
if (flight_info[SelectedPlane]) {
|
||||
if (internet_mode) {
|
||||
$.getJSON('json/airlines.json', function (world_airlines) {
|
||||
$.getJSON('json/world_airports.json', function (world_airports) {
|
||||
$.getJSON('json/airplanes.json', function (aircraft_information) {
|
||||
var flightdata = flight_info[SelectedPlane]
|
||||
var scheduledata = flight_info[SelectedPlane].schedule
|
||||
flightInfo(flightdata, world_airports, world_airlines)
|
||||
flightProgress(flightdata, world_airports, scheduledata)
|
||||
getAircraftInfo(aircraft_information, flightdata)
|
||||
getPlaneImage(flightdata)
|
||||
// Planes[SelectedPlane] gives
|
||||
document.getElementById("flight_progress_div").style.display = "none"
|
||||
document.getElementById('additional_info_hidden').style.display = "none"
|
||||
document.getElementById("img_button").disabled = true
|
||||
|
||||
document.getElementById("flight_airport_long_destination").innerHTML = "N/A"
|
||||
document.getElementById("flight_airport_short_destination").innerHTML = "N/A"
|
||||
document.getElementById("flight_airport_loc_destination").innerHTML = "N/A"
|
||||
document.getElementById("flight_airport_long_origin").innerHTML = "N/A"
|
||||
document.getElementById("flight_airport_short_origin").innerHTML = "N/A"
|
||||
document.getElementById("flight_airport_loc_origin").innerHTML = "N/A"
|
||||
|
||||
for (element in internet_mode_data) {
|
||||
if (internet_mode_data[element].hex === SelectedPlane) {
|
||||
var data = internet_mode_data[element]
|
||||
if (data.airline != "") {
|
||||
document.getElementById("flight_flightnum").innerHTML = data.flight.replace(/\D/g, "")
|
||||
document.getElementById("flight_status").innerHTML = ""
|
||||
document.getElementById("flight_flighticaonum").innerHTML = data.flight
|
||||
try {
|
||||
document.getElementById("flight_airline").innerHTML = world_airlines[data.airline].nameAirline + " "
|
||||
} catch {
|
||||
document.getElementById("flight_airline").innerHTML = "N/A "
|
||||
}
|
||||
} else {
|
||||
//document.getElementById("flight_flightnum").innerHTML = data.flight.replace(/\D/g, "")
|
||||
document.getElementById("flight_status").innerHTML = ""
|
||||
document.getElementById("flight_flightnum").innerHTML = ""
|
||||
document.getElementById("flight_flighticaonum").innerHTML = data.flight
|
||||
document.getElementById("flight_airline").innerHTML = data.flight
|
||||
}
|
||||
for (airport_search in world_airports) {
|
||||
if (world_airports[airport_search].iata === internet_mode_data[element].arr && internet_mode_data[element].arr != "") {
|
||||
var airport = world_airports[airport_search]
|
||||
try {
|
||||
document.getElementById("flight_airport_long_destination").innerHTML = airport.name
|
||||
document.getElementById("flight_airport_short_destination").innerHTML = airport.icao
|
||||
document.getElementById("flight_airport_loc_destination").innerHTML = airport.city + ", " + country_names[airport.country]
|
||||
} catch {
|
||||
document.getElementById("flight_airport_long_destination").innerHTML = "N/A"
|
||||
document.getElementById("flight_airport_short_destination").innerHTML = "N/A"
|
||||
document.getElementById("flight_airport_loc_destination").innerHTML = "N/A"
|
||||
}
|
||||
} else if (internet_mode_data[element].arr === "") {
|
||||
document.getElementById("flight_airport_long_destination").innerHTML = "N/A"
|
||||
document.getElementById("flight_airport_short_destination").innerHTML = "N/A"
|
||||
document.getElementById("flight_airport_loc_destination").innerHTML = "N/A"
|
||||
}
|
||||
|
||||
if (world_airports[airport_search].iata === internet_mode_data[element].dep && internet_mode_data[element].dep != "") {
|
||||
var airport = world_airports[airport_search]
|
||||
try {
|
||||
document.getElementById("flight_airport_long_origin").innerHTML = airport.name
|
||||
document.getElementById("flight_airport_short_origin").innerHTML = airport.icao
|
||||
document.getElementById("flight_airport_loc_origin").innerHTML = airport.city + ", " + country_names[airport.country]
|
||||
} catch {
|
||||
document.getElementById("flight_airport_long_origin").innerHTML = "N/A"
|
||||
document.getElementById("flight_airport_short_origin").innerHTML = "N/A"
|
||||
document.getElementById("flight_airport_loc_origin").innerHTML = "N/A"
|
||||
}
|
||||
} else if (internet_mode_data[element].dep === "") {
|
||||
document.getElementById("flight_airport_long_origin").innerHTML = "N/A"
|
||||
document.getElementById("flight_airport_short_origin").innerHTML = "N/A"
|
||||
document.getElementById("flight_airport_loc_origin").innerHTML = "N/A"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
document.getElementById("radar_flight_info").style.display = "block"
|
||||
document.getElementById("radar_flight_loading").style.display = "none"
|
||||
document.getElementById("radar_aircraft_info").style.display = "block"
|
||||
@@ -17,118 +79,10 @@ function updateFlightTab() {
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
} else {
|
||||
if (internet_mode) {
|
||||
$.getJSON('json/airlines.json', function (world_airlines) {
|
||||
$.getJSON('json/world_airports.json', function (world_airports) {
|
||||
$.getJSON('json/airplanes.json', function (aircraft_information) {
|
||||
// Planes[SelectedPlane] gives
|
||||
document.getElementById("flight_progress_div").style.display = "none"
|
||||
document.getElementById('additional_info_hidden').style.display = "none"
|
||||
document.getElementById("img_button").disabled = true
|
||||
|
||||
document.getElementById("flight_airport_long_destination").innerHTML = "N/A"
|
||||
document.getElementById("flight_airport_short_destination").innerHTML = "N/A"
|
||||
document.getElementById("flight_airport_loc_destination").innerHTML = "N/A"
|
||||
document.getElementById("flight_airport_long_origin").innerHTML = "N/A"
|
||||
document.getElementById("flight_airport_short_origin").innerHTML = "N/A"
|
||||
document.getElementById("flight_airport_loc_origin").innerHTML = "N/A"
|
||||
|
||||
for (element in internet_mode_data) {
|
||||
if (internet_mode_data[element].hex === SelectedPlane) {
|
||||
var data = internet_mode_data[element]
|
||||
if (data.airline != "") {
|
||||
document.getElementById("flight_flightnum").innerHTML = data.flight.replace(/\D/g, "")
|
||||
document.getElementById("flight_status").innerHTML = ""
|
||||
document.getElementById("flight_flighticaonum").innerHTML = data.flight
|
||||
try {
|
||||
document.getElementById("flight_airline").innerHTML = world_airlines[data.airline].nameAirline + " "
|
||||
} catch {
|
||||
document.getElementById("flight_airline").innerHTML = "N/A "
|
||||
}
|
||||
} else {
|
||||
//document.getElementById("flight_flightnum").innerHTML = data.flight.replace(/\D/g, "")
|
||||
document.getElementById("flight_status").innerHTML = ""
|
||||
document.getElementById("flight_flightnum").innerHTML = ""
|
||||
document.getElementById("flight_flighticaonum").innerHTML = data.flight
|
||||
document.getElementById("flight_airline").innerHTML = data.flight
|
||||
}
|
||||
for (airport_search in world_airports) {
|
||||
if (world_airports[airport_search].iata === internet_mode_data[element].arr && internet_mode_data[element].arr != "") {
|
||||
var airport = world_airports[airport_search]
|
||||
try {
|
||||
document.getElementById("flight_airport_long_destination").innerHTML = airport.name
|
||||
document.getElementById("flight_airport_short_destination").innerHTML = airport.icao
|
||||
document.getElementById("flight_airport_loc_destination").innerHTML = airport.city + ", " + country_names[airport.country]
|
||||
} catch {
|
||||
document.getElementById("flight_airport_long_destination").innerHTML = "N/A"
|
||||
document.getElementById("flight_airport_short_destination").innerHTML = "N/A"
|
||||
document.getElementById("flight_airport_loc_destination").innerHTML = "N/A"
|
||||
}
|
||||
} else if (internet_mode_data[element].arr === "") {
|
||||
document.getElementById("flight_airport_long_destination").innerHTML = "N/A"
|
||||
document.getElementById("flight_airport_short_destination").innerHTML = "N/A"
|
||||
document.getElementById("flight_airport_loc_destination").innerHTML = "N/A"
|
||||
}
|
||||
|
||||
if (world_airports[airport_search].iata === internet_mode_data[element].dep && internet_mode_data[element].dep != "") {
|
||||
var airport = world_airports[airport_search]
|
||||
try {
|
||||
document.getElementById("flight_airport_long_origin").innerHTML = airport.name
|
||||
document.getElementById("flight_airport_short_origin").innerHTML = airport.icao
|
||||
document.getElementById("flight_airport_loc_origin").innerHTML = airport.city + ", " + country_names[airport.country]
|
||||
} catch {
|
||||
document.getElementById("flight_airport_long_origin").innerHTML = "N/A"
|
||||
document.getElementById("flight_airport_short_origin").innerHTML = "N/A"
|
||||
document.getElementById("flight_airport_loc_origin").innerHTML = "N/A"
|
||||
}
|
||||
} else if (internet_mode_data[element].dep === "") {
|
||||
document.getElementById("flight_airport_long_origin").innerHTML = "N/A"
|
||||
document.getElementById("flight_airport_short_origin").innerHTML = "N/A"
|
||||
document.getElementById("flight_airport_loc_origin").innerHTML = "N/A"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
document.getElementById("radar_flight_info").style.display = "block"
|
||||
document.getElementById("radar_flight_loading").style.display = "none"
|
||||
document.getElementById("radar_aircraft_info").style.display = "block"
|
||||
document.getElementById("radar_aircraft_loading").style.display = "none"
|
||||
})
|
||||
});
|
||||
});
|
||||
} else {
|
||||
$.getJSON("https://aviation-edge.com/v2/public/flights?key=" + keys['AE'] + "&aircraftIcao24=" + SelectedPlane, function (flightdata) {
|
||||
flightdata = flightdata[0]
|
||||
$.getJSON("https://aviation-edge.com/v2/public/timetable?key=" + keys['AE'] + "&flight_icao=" + flightdata.flight.icaoNumber + "&status=active", function (scheduledata) {
|
||||
scheduledata = scheduledata[0]
|
||||
$.getJSON('json/airlines.json', function (world_airlines) {
|
||||
$.getJSON('json/world_airports.json', function (world_airports) {
|
||||
$.getJSON('json/airplanes.json', function (aircraft_information) {
|
||||
flight_info[SelectedPlane] = flightdata
|
||||
flight_info[SelectedPlane].schedule = scheduledata
|
||||
flight_info[SelectedPlane].aircraft.information = aircraft_information[flightdata.aircraft.iataCode]
|
||||
flightInfo(flightdata, world_airports, world_airlines)
|
||||
flightProgress(flightdata, world_airports, scheduledata)
|
||||
getAircraftInfo(aircraft_information, flightdata)
|
||||
getPlaneImage(flightdata)
|
||||
|
||||
document.getElementById("radar_flight_info").style.display = "block"
|
||||
document.getElementById("radar_flight_loading").style.display = "none"
|
||||
document.getElementById("radar_aircraft_info").style.display = "block"
|
||||
document.getElementById("radar_aircraft_loading").style.display = "none"
|
||||
document.getElementById("img_button").disabled = false
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// handles information of flight itself
|
||||
function flightInfo(data, world_airports, world_airlines) {
|
||||
try {
|
||||
@@ -191,103 +145,10 @@ function getAircraftInfo(aircraft_information, data) {
|
||||
}
|
||||
}
|
||||
|
||||
// Flight's current progress
|
||||
function flightProgress(flightdata, world_airports, data) {
|
||||
try {
|
||||
arrival_timezone = world_airports[data.arrival.icaoCode].tz
|
||||
departure_timezone = world_airports[data.departure.icaoCode].tz
|
||||
|
||||
if (data.departure.actualTime) {
|
||||
departure_time = DateTime.fromISO(data.departure.actualTime, {
|
||||
zone: departure_timezone
|
||||
});
|
||||
} else if (data.departure.estimatedTime) {
|
||||
departure_time = DateTime.fromISO(data.departure.estimatedTime, {
|
||||
zone: departure_timezone
|
||||
});
|
||||
} else if (data.departure.scheduledTime) {
|
||||
departure_time = DateTime.fromISO(data.departure.scheduledTime, {
|
||||
zone: departure_timezone
|
||||
});
|
||||
}
|
||||
|
||||
if (data.arrival.actualTime) {
|
||||
arrival_time = DateTime.fromISO(data.arrival.actualTime, {
|
||||
zone: arrival_timezone
|
||||
});
|
||||
} else if (data.arrival.estimatedTime) {
|
||||
arrival_time = DateTime.fromISO(data.arrival.estimatedTime, {
|
||||
zone: arrival_timezone
|
||||
});
|
||||
} else if (data.arrival.scheduledTime) {
|
||||
arrival_time = DateTime.fromISO(data.arrival.scheduledTime, {
|
||||
zone: arrival_timezone
|
||||
});
|
||||
}
|
||||
|
||||
arrival_time = arrival_time.setZone("America/New_York")
|
||||
departure_time = departure_time.setZone("America/New_York")
|
||||
document.getElementById("flight_depart_time").innerHTML = departure_time.toLocaleString(DateTime.DATETIME_MED)
|
||||
document.getElementById("flight_arrival_time").innerHTML = arrival_time.toLocaleString(DateTime.DATETIME_MED)
|
||||
var trip_progress = getTripProgress(arrival_time, departure_time)
|
||||
document.getElementById("flight_percentage_spinner").innerHTML = trip_progress + "%"
|
||||
document.getElementById("flight_progress_circle").setAttribute("class", "progress-circle p" + trip_progress)
|
||||
flight_info[SelectedPlane].schedule.progress = trip_progress
|
||||
getFlightPlanImage(flightdata, trip_progress, world_airports)
|
||||
document.getElementById("flight_progress_div").style.display = "block"
|
||||
document.getElementById('additional_info_hidden').style.display = "block"
|
||||
if (data.departure.terminal) {
|
||||
document.getElementById("flight_depart_terminal").innerHTML = data.departure.terminal
|
||||
}
|
||||
if (data.departure.gate) {
|
||||
document.getElementById("flight_depart_gate").innerHTML = data.departure.gate
|
||||
}
|
||||
|
||||
if (data.arrival.terminal) {
|
||||
document.getElementById("flight_arrival_terminal").innerHTML = data.arrival.terminal
|
||||
}
|
||||
if (data.arrival.gate) {
|
||||
document.getElementById("flight_arrival_gate").innerHTML = data.arrival.gate
|
||||
}
|
||||
} catch {
|
||||
document.getElementById("flight_progress_div").style.display = "none"
|
||||
document.getElementById('additional_info_hidden').style.display = "none"
|
||||
getFlightPlanImage(flightdata, 1, world_airports)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//Flight progress percentage
|
||||
function getTripProgress(arrival_time, departure_time) {
|
||||
var current_time = DateTime.local();
|
||||
var total_time = arrival_time.diff(departure_time);
|
||||
var time_elapsed = current_time.diff(departure_time);
|
||||
var trip_progress = ((time_elapsed * 100) / total_time).toFixed(0)
|
||||
var time_remaining = arrival_time.diff(current_time);
|
||||
document.getElementById("flight_progress").MaterialProgress.setProgress(trip_progress);
|
||||
if (time_remaining.days != 0) {
|
||||
document.getElementById("flight_progress_remaining_amount").innerHTML = time_remaining.toFormat("o 'Day(s), ' h 'Hour(s), ' m 'Minute(s)'")
|
||||
} else {
|
||||
document.getElementById("flight_progress_remaining_amount").innerHTML = time_remaining.toFormat("h 'Hour(s), ' m 'Minute(s)'")
|
||||
}
|
||||
if (time_elapsed.days != 0) {
|
||||
document.getElementById("flight_progress_elapsed_amount").innerHTML = time_elapsed.toFormat("o 'Day(s), ' h 'Hour(s), ' m 'Minute(s)'")
|
||||
} else {
|
||||
document.getElementById("flight_progress_elapsed_amount").innerHTML = time_elapsed.toFormat("h 'Hour(s), ' m 'Minute(s)'")
|
||||
}
|
||||
if (total_time.days != 0) {
|
||||
document.getElementById("flight_progress_time_amount").innerHTML = total_time.toFormat("o 'Day(s), ' h 'Hour(s), ' m 'Minute(s)'")
|
||||
} else {
|
||||
document.getElementById("flight_progress_time_amount").innerHTML = total_time.toFormat("h 'Hour(s), ' m 'Minute(s)'")
|
||||
}
|
||||
|
||||
return trip_progress
|
||||
}
|
||||
|
||||
// Get image of aircraft
|
||||
function getPlaneImage(flightdata) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", "http://"+window.location.hostname+":5000/cmd", true);
|
||||
xhr.open("POST", "http://" + window.location.hostname + ":5000/cmd", true);
|
||||
xhr.setRequestHeader('Content-Type', 'application/json');
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState === 4) {
|
||||
@@ -333,36 +194,6 @@ function getPlaneImage(flightdata) {
|
||||
}));
|
||||
}
|
||||
|
||||
// get image of whole flight path
|
||||
function getFlightPlanImage(data, flight_progress, world_airports) {
|
||||
try {
|
||||
departure_timezone = world_airports[data.departure.icaoCode].tz
|
||||
/*
|
||||
if (data.departure.actualTime) {
|
||||
departure_time = DateTime.fromISO(data.departure.actualTime, {
|
||||
zone: departure_timezone
|
||||
});
|
||||
} else if (data.departure.estimatedTime) {
|
||||
departure_time = DateTime.fromISO(data.departure.estimatedTime, {
|
||||
zone: departure_timezone
|
||||
});
|
||||
} else if (data.departure.scheduledTime) {
|
||||
departure_time = DateTime.fromISO(data.departure.scheduledTime, {
|
||||
zone: departure_timezone
|
||||
});
|
||||
}
|
||||
*/
|
||||
departure_time = DateTime.local();
|
||||
var dep_date = departure_time.toFormat('yyyyMMdd')
|
||||
document.getElementById("progress_image").setAttribute("src", "https://www.flightview.com/fvPublicSiteFT/FlightViewCGI.exe?qtype=gif&acid=" + data.flight.iataNumber + "&depap=" + data.departure.iataCode + "&arrap=" + data.arrival.iataCode + "&depdate=" + dep_date + "&pctcomplete=" + flight_progress)
|
||||
flight_info[SelectedPlane].flightimage = "https://www.flightview.com/fvPublicSiteFT/FlightViewCGI.exe?qtype=gif&acid=" + data.flight.iataNumber + "&depap=" + data.departure.iataCode + "&arrap=" + data.arrival.iataCode + "&depdate=" + dep_date + "&pctcomplete=" + flight_progress
|
||||
document.getElementById("img_button").disabled = false
|
||||
} catch {
|
||||
document.getElementById("image_modal").style.display = "none"
|
||||
document.getElementById("img_button").disabled = true
|
||||
}
|
||||
}
|
||||
|
||||
function setBigImage(source) {
|
||||
var source_url = document.getElementById(source).getAttribute("src")
|
||||
var dest_url = document.getElementById("aircraft_image1-1").getAttribute("src")
|
||||
|
||||
+4
-4
@@ -45,7 +45,7 @@ function playPLS(url, title) {
|
||||
// PLS INFO
|
||||
const proxyurl = "http://" + window.location.hostname + ":7000/";
|
||||
var request = $.ajax({
|
||||
url: 'json/liveatc.json',
|
||||
url: 'information/liveatc.json',
|
||||
timeout: 5000,
|
||||
cache: true,
|
||||
dataType: 'json'
|
||||
@@ -80,7 +80,7 @@ function playPause() {
|
||||
function listStations() {
|
||||
document.getElementById("atc_selector").innerHTML = ""
|
||||
var request = $.ajax({
|
||||
url: 'json/liveatc.json',
|
||||
url: 'information/liveatc.json',
|
||||
timeout: 5000,
|
||||
cache: true,
|
||||
dataType: 'json'
|
||||
@@ -118,7 +118,7 @@ function selectState(state) {
|
||||
var node = document.createElement("hr")
|
||||
document.getElementById("atc_selector").appendChild(node)
|
||||
var request = $.ajax({
|
||||
url: 'json/liveatc.json',
|
||||
url: 'information/liveatc.json',
|
||||
timeout: 5000,
|
||||
cache: true,
|
||||
dataType: 'json'
|
||||
@@ -165,7 +165,7 @@ function selectAirport(airport, state) {
|
||||
var node = document.createElement("hr")
|
||||
document.getElementById("atc_selector").appendChild(node)
|
||||
var request = $.ajax({
|
||||
url: 'json/liveatc.json',
|
||||
url: 'information/liveatc.json',
|
||||
timeout: 5000,
|
||||
cache: true,
|
||||
dataType: 'json'
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ function initializeSchedulesPage() {
|
||||
document.getElementById("itin_body").innerHTML = ""
|
||||
document.getElementById("itin_img").setAttribute("src", 'images/black.jpg')
|
||||
FetchPending = $.ajax({
|
||||
url: 'json/liveatc.json',
|
||||
url: 'information/liveatc.json',
|
||||
timeout: 5000,
|
||||
cache: false,
|
||||
dataType: 'json',
|
||||
|
||||
Generated
-11
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"requires": true,
|
||||
"lockfileVersion": 1,
|
||||
"dependencies": {
|
||||
"olcs": {
|
||||
"version": "2.13.0",
|
||||
"resolved": "https://registry.npmjs.org/olcs/-/olcs-2.13.0.tgz",
|
||||
"integrity": "sha512-5H41vMRdyvDcy4BWm+6V7vkS7glK+jVpUysVRqhzPnXjwvJG9NnvMxKBhAjBG07Lh9QAKAPMLnQ+RWDofN707Q=="
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
cd "/mnt/c/Users/Nicholas Pease/Offline Documents/cors-anywhere"
|
||||
export PORT=7000
|
||||
node server.js &
|
||||
|
||||
cd "/mnt/c/Users/Nicholas Pease/OneDrive/Documents/AviationAssistant/python"
|
||||
python api_pc.py &
|
||||
|
||||
cd "/mnt/c/Users/Nicholas Pease/OneDrive/Documents/AviationAssistant/"
|
||||
python -m http.server 9500
|
||||
Reference in New Issue
Block a user