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iU)q>EO( literal 0 HcmV?d00001 diff --git a/static/viewer.css b/static/viewer.css new file mode 100644 index 0000000..c03c1cc --- /dev/null +++ b/static/viewer.css @@ -0,0 +1,8 @@ +.fox_button { + transition: all .3s ease; + cursor: pointer; +} + +.fox_active, .fox_atc_active { + background-color: #dee2e6 !important; +} diff --git a/static/viewer.js b/static/viewer.js new file mode 100644 index 0000000..349977f --- /dev/null +++ b/static/viewer.js @@ -0,0 +1,146 @@ +// Fetching user's ATC session informations from API +let userSession = {}; + +fetch(ATC_API_URL, {}).then(response => response.json).then(result => { + for (let session of result["items"]) { + // Separate each session by it's connection ID + let session_id = session["connection_id"]["id"]; + userSession[session_id] = session; + + // Long line. Not in the whole file, but still bad + // Open to any suggestions about fix it + let sessionElement = " " + session["connection_id"]["callsign"] + ""; + $("#fox_atc").append(sessionElement); + } + + showSession(userSession[result["items"][0]["callsign"]]); +}); + +// Fetching user's flightplans from VATSIM API +let userFlightplans = {}; + +fetch(FLIGHTPLANS_API_URL, {}).then(response => response.json).then(result => { + for (let flightplan of result) { + // Separate each flight by it's connection ID + // Like it was with ATC session's + let flightplan_id = flightplan["connection_id"] + userFlightplans[flightplan_id] = flightplan; + + // Long line again + let flightplanElement = "" + flightplan["callsign"] + ""; + $("#fox_flightplans").append(flightplanElement); + } + showFlight(userFlightplans[result[0]["callsign"]]); +}); + +// Fetching airports information +// Get it from localhost +// Becase I think it would be much faster than getting it from VATSIM API +let airports = {}; + +$.getJSON("/static/data/airports.json", function(json) { + airports = json; + } +); + +// Map creation +const MAP_ELEMENT = L.map("fox_map"); +const MAP_DEFAULT_TARGET = L.latLng("47.50737", "19.04611"); +const MAP_DEFAULT_ZOOM_VIEW = 14; +let line = null; + +MAP_ELEMENT.setView(MAP_DEFAULT_TARGET, MAP_DEFAULT_ZOOM_VIEW); + +L.tileLayer("http://{s}.tile.osm.org/{z}/{x}/{y}.png", { + attribution: '© OpenStreetMap contributors', + subdomains: "abcd", + maxZoom: 20, + minZoom: 2 +}).addTo(MAP_ELEMENT); + +// Function to delete route line from map +function mapDeleteDraws() { + if (!line) return; + MAP_ELEMENT.removeLayer(line); + line = null; +} + +// Function to draw flight path on map +function mapDrawFlight(flight) { + if (!flight) return; + mapDeleteDraws(); + + let departureAirport = flight["dep"]; + let arrivalAirport = flight["arr"]; + + line = L.polyline([ + [ + airports[departureAirport]["lat"], + airports[departureAirport]["lon"] + ], + [ + airports[arrivalAirport]["lat"], + airports[arrivalAirport]["lon"] + ] + ], {color: "red"}).addTo(MAP_ELEMENT); + + MAP_ELEMENT.fitBounds(line.getBounds()); +} + +// Function to show data in right flight bar +function showFlight(flight) { + if (!flight) return; + + // Changing text in each class + // FP before _ - means flightplan + $(".fp_callsign").text(flight["callsign"]); + $(".fp_depa_city").text(airports[flight["dep"]]["city"]); + $(".fp_arra_city").text(airports[flight["arr"]]["city"]); + $(".fp_aicraft").text(flight["aircraft"]); + $(".fp_entime").text(flight["hrsenroute"] + ":" + flight["minenroute"]); + $(".fp_depa").text(flight["dep"]); + $(".fp_arra").text(flight["arr"]); + $(".fp_altna").text(flight["alt"]); + $(".fp_type").text(flight["flight_type"]); + $(".fp_speed").text(flight["cruisespeed"]); + $(".fp_alt").text(flight["altitude"]); + $(".fp_route").text(flight["route"]); + $(".fp_remarks").text(flight["rmks"]); + $(".fp_squawk").text(flight["assignedsquawk"]); + $(".fp_filed").text(flight["filed"].replace("T", " ")); + + mapDrawFlight(flight); +} + +// Function to show ATC session +function showSession(session) { + if (!session) return; + + $(".atc_callsign").text(session["connection_id"]["callsign"]); + $(".atc_start_time").text(session["connection_id"]["start"]); + $(".atc_end_time").text(session["connection_id"]["end"]); + $(".atc_trackedair").text(session["aircrafttracked"]); + $(".atc_seenair").text(session["aircraftseen"]); + $(".atc_squawks").text(session["squawksassigned"]); + $(".atc_transfers").text(session["handoffsinitiated"]); + $(".atc_received").text(session["handoffsreceived"]); +} + +// Click event handler to left menu button +$(".fox_atc").click(function() { + if ($(this).hasClass("fox_atc_active")) return; + + $(".fox_atc_active").removeClass("fox_atc_active"); + $(this).addClass("fox_atc_active"); + + showSession(userSession[$(this).attr("id")]); +}) + +$(".fox_button").click(function() { + if ($(this).hasClass("fox_active")) return; + + $(".fox_active").removeClass("fox_active"); + $(this).addClass("fox_active"); + + showFlight(userFlightplans[$(this).attr("id")]); +}); diff --git a/templates/4O4.html b/templates/4O4.html new file mode 100644 index 0000000..eb51781 --- /dev/null +++ b/templates/4O4.html @@ -0,0 +1,12 @@ +{% extends "/include/template.html" %} +{% block title %}404 - Not Found / VATSIM Fox{% endblock %} +{% block content %} +++{% endblock %} \ No newline at end of file diff --git a/templates/include/template.html b/templates/include/template.html new file mode 100644 index 0000000..ffc0ab8 --- /dev/null +++ b/templates/include/template.html @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + +++4O4 - Page Not Found
+ + + +{% block title %}{% endblock %} + + + {% block header_css %}{% endblock %} + + + ++ + + + {% block javascript_code %}{% endblock %} + + \ No newline at end of file diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..1482061 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,52 @@ +{% extends "/include/template.html" %} +{% block title %}VATSIM Fox — view detailed profile statistic{% endblock %} +{% block content %} ++++ + + 🦊 VATSIM Fox + + + + + + {% block content %}{% endblock %} + + +++ +++Enter your VATSIM CID
+See your detailed profile statistic
++ + ++ +++{% endblock %} +{% block javascript_code %} + +{% endblock %} \ No newline at end of file diff --git a/templates/viewer.html b/templates/viewer.html new file mode 100644 index 0000000..b7125b7 --- /dev/null +++ b/templates/viewer.html @@ -0,0 +1,140 @@ +{% extends "/include/template.html" %} +{% block title %}User {{user_cid}} statistic — VATSIM Fox{% endblock %} +{% block header_css %} + + +{% endblock %} +{% block content %} +++++About
+VATSIM Fox is an open-source project to make it easier for users to see their detailed profile statistic
+++++Open source project
+This project is fully opened, so you can contribute in it if you want
+ + + +++ +{{data[0]["id"]}}
+Date of registration:
+++Last 50 flightplans
+ + +++++++Flight — from to
+ + Aircraft type: + + +
+ + Enroute time: + + +
+ + Departure airport: + + +
+ + Arrival airport: + + +
+ + Alternative airport: + + +
+ + Flight type: + + +
+ + Cruise speed: + knots + +
+ + Flight altitude: + feet + +
+ + Route: + + +
+ + Remarks: + + +
+ + Squawk: + + +
+ + Fligthplan filed at: + + +
+++{% endblock %} +{% block javascript_code %} + + + +{% endblock %}Last 100 ATC shifts
+ + +++++UUEE_DEL
+ + Start time: + 2024-01-05T16:11:22Z + +
+ + End time: + 2024-01-05T16:32:46Z + +
+ + Aircraft tracked: + 7 + +
+ + Aircraft seen: + 35 + +
+ + Squawk assigned: + 12 + +
+ + Aircraft's transferred: + 3 + +
+ + Aircraft's received: + 0 + +