Skip to content

Commit

Permalink
#15 - Added aircraft type and registration from JSON data
Browse files Browse the repository at this point in the history
  • Loading branch information
fratsloos committed Aug 14, 2022
1 parent cd3ea49 commit dbccfa6
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dist/fr24_card.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion src/javascript/config/columns.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@
},
"age": {
"styles": ["align-right"],
"weight": 3,
"weight": 2,
"popup": true
},
"aircraft_type": {
"weight": 2,
"popup": true
}
}
14 changes: 11 additions & 3 deletions src/javascript/helpers/aircraft.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ export default class Aircraft {
this.lat = state.lat ?? null;
this.lon = state.lon ?? null;
this.seen = state.seen ?? 100;
this.aircraft_type = state.t ?? null;

// ICAO data
const icao = new ICAO();
const country = icao.country.find(this.hex);
const registration = icao.registration.lookup(this.hex);

// Set flag based on ICAO data
this.flag =
Expand All @@ -36,8 +36,16 @@ export default class Aircraft {
: null;
this.country = country !== null ? country.country : null;

// Set registration based on ICAO data
this.registration = registration;
// Registration, either from JSON or calculated
const hasRegistration = typeof state.r !== "undefined" && state.r !== "";
if (hasRegistration) {
this.registration = state.r;
} else {
const registration = icao.registration.lookup(this.hex);

// Set registration based on ICAO data
this.registration = registration;
}

// Calculate distance if distance service is setup
this.distance = distance.isSetUp()
Expand Down
3 changes: 2 additions & 1 deletion src/javascript/lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"speed": "Geschwindigkeit",
"distance": "Entfernung",
"track": "Pfad",
"age": "Letzte Nachricht"
"age": "Letzte Nachricht",
"aircraft_type": "Typ"
},
"data": {
"not_available": "N/V"
Expand Down
3 changes: 2 additions & 1 deletion src/javascript/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"speed": "Speed",
"distance": "Distance",
"track": "Track",
"age": "Last message"
"age": "Last message",
"aircraft_type": "Type"
},
"data": {
"not_available": "N/A"
Expand Down
3 changes: 2 additions & 1 deletion src/javascript/lang/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"speed": "Snelheid",
"distance": "Afstand",
"track": "Richting",
"age": "Laatste bericht"
"age": "Laatste bericht",
"aircraft_type": "Type"
},
"data": {
"not_available": "Nb"
Expand Down
3 changes: 2 additions & 1 deletion src/javascript/lang/sl.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"speed": "Hitrost",
"distance": "Razdalja",
"track": "Smer",
"age": "Zaznano pred"
"age": "Zaznano pred",
"aircraft_type": "Vrsta"
},
"data": {
"not_available": "N/A"
Expand Down

0 comments on commit dbccfa6

Please sign in to comment.