Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions public_html/formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,26 @@ function format_track_long(track) {
return Math.round(track) + DEGREES + NBSP + "(" + TrackDirections[trackDir] + ")";
}

// Return altitude text without HTML
function format_altitude_text(alt, displayUnits) {
if (alt === null) {
return "";
} else if (alt === "ground") {
return "ground";
}
return Math.round(convert_altitude(alt, displayUnits)).toLocaleString() + NBSP;
}

// Return vertical rate triangle character (no HTML)
function format_vert_rate_triangle(vr) {
if (vr > 128) {
return UP_TRIANGLE;
} else if (vr < -128) {
return DOWN_TRIANGLE;
}
return NBSP;
}

// alt in feet
function format_altitude_brief(alt, vr, displayUnits) {
var alt_text;
Expand Down
21 changes: 17 additions & 4 deletions public_html/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,12 @@ function processReceiverUpdate(data, receiver_source) {

// set flag image if available
if (ShowFlags && plane.icaorange.flag_image !== null) {
$('img', plane.tr.cells[1]).attr('src', FlagPath + plane.icaorange.flag_image);
$('img', plane.tr.cells[1]).attr('title', plane.icaorange.country);
if (/^[a-zA-Z0-9_-]+\.png$/.test(plane.icaorange.flag_image)) {
$('img', plane.tr.cells[1]).attr('src', FlagPath + plane.icaorange.flag_image);
$('img', plane.tr.cells[1]).attr('title', plane.icaorange.country);
} else {
$('img', plane.tr.cells[1]).css('display', 'none');
}
} else {
$('img', plane.tr.cells[1]).css('display', 'none');
}
Expand Down Expand Up @@ -1733,7 +1737,16 @@ function refreshTableInfo() {
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 : "");
tableplane.tr.cells[6].innerHTML = format_altitude_brief(tableplane.altitude, tableplane.vert_rate, DisplayUnits);
{
var cell = tableplane.tr.cells[6];
cell.textContent = '';
var altText = format_altitude_text(tableplane.altitude, DisplayUnits);
cell.appendChild(document.createTextNode(altText));
var vrSpan = document.createElement('span');
vrSpan.className = 'verticalRateTriangle';
vrSpan.textContent = format_vert_rate_triangle(tableplane.vert_rate);
cell.appendChild(vrSpan);
}
tableplane.tr.cells[7].textContent = format_speed_brief(tableplane.gs, DisplayUnits);
tableplane.tr.cells[8].textContent = format_vert_rate_brief(tableplane.vert_rate, DisplayUnits);
tableplane.tr.cells[9].textContent = format_distance_brief(tableplane.sitedist, DisplayUnits);
Expand Down Expand Up @@ -2577,7 +2590,7 @@ function hideBanner() {
// Helper function to restrict the range of the inputs
function restrictUrlRequest(c) {
let v = parseFloat(c);
if (v < 0) {
if (!isFinite(v) || v < 0) {
v = 0;
} else if (v > 5) {
v = 5;
Expand Down