Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor JS cleanup #1260

Merged
merged 1 commit into from
Jul 10, 2023
Merged
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
15 changes: 7 additions & 8 deletions js/greatcircle.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,15 @@ function gcBearingTo(from, to) {
Math.sin(y[0]) * Math.cos(y[1]) * Math.cos(x[1] - x[0]);

if (a == 0 && b == 0) {
bearing = 0;
return bearing;
return 0;
}

if (b == 0) {
if (a < 0) {
bearing = 270;
return 270;
} else {
bearing = 90;
return 90;
}
return bearing;
}

if (b < 0) {
Expand All @@ -75,9 +73,10 @@ function gcBearingTo(from, to) {
adjust = 0;
}
}
bearing = (Math.atan(a / b) + adjust) * RAD2DEG;
return bearing;
} else return null;
return (Math.atan(a / b) + adjust) * RAD2DEG;
} else {
return null;
}
}

/**
Expand Down
36 changes: 12 additions & 24 deletions openflights.js
Original file line number Diff line number Diff line change
Expand Up @@ -1437,15 +1437,14 @@ function updateFilter(str) {
$("input_trip_select").innerHTML =
"&nbsp;" + gt.gettext("No trips. Add one? ");
} else {
var tripSelect = createSelect(
$("filter_tripselect").innerHTML = createSelect(
"Trips",
gt.gettext("All trips"),
filter_trid,
trips.split("\t"),
SELECT_MAXLEN,
"refresh(true)"
);
$("filter_tripselect").innerHTML = tripSelect;
var editTripSelect = document.forms["inputform"].trips;
if (editTripSelect) {
// New trip added, so now we need to figure out the newest (highest) trid to find it
Expand Down Expand Up @@ -1473,25 +1472,22 @@ function updateFilter(str) {
);
document.forms["inputform"].trips[0].text = "Select trip";
}

var airlineSelect = createSelect(
$("filter_airlineselect").innerHTML = createSelect(
"Airlines",
gt.gettext("All carriers"),
filter_alid,
airlines.split("\t"),
SELECT_MAXLEN,
"refresh(true)"
);
$("filter_airlineselect").innerHTML = airlineSelect;
var yearSelect = createSelect(
$("filter_yearselect").innerHTML = createSelect(
"Years",
gt.gettext("All"),
filter_year,
years.split("\t"),
20,
"refresh(true)"
);
$("filter_yearselect").innerHTML = yearSelect;
}

// Generate title for current map
Expand Down Expand Up @@ -2587,8 +2583,8 @@ function editPointer(offset) {
// Load up parameters of a given flight
function preEditFlight(fid, idx) {
fidPtr = idx;
$("b_prev").disabled = fidPtr <= 0 ? true : false;
$("b_next").disabled = fidPtr >= fidList.length - 1 ? true : false;
$("b_prev").disabled = fidPtr <= 0;
$("b_next").disabled = fidPtr >= fidList.length - 1;
$("editflighttitle").innerHTML = gt.gettext("Loading...");
xmlhttpPost(URL_FLIGHTS, fid, "EDIT");
}
Expand Down Expand Up @@ -2641,19 +2637,11 @@ function editFlight(str, param) {

var myClass = inputform.myClass;
for (index = 0; index < myClass.length; index++) {
if (myClass[index].value == col[10]) {
myClass[index].checked = true;
} else {
myClass[index].checked = false;
}
myClass[index].checked = myClass[index].value == col[10];
}
var reason = inputform.reason;
for (index = 0; index < reason.length; index++) {
if (reason[index].value == col[11]) {
reason[index].checked = true;
} else {
reason[index].checked = false;
}
reason[index].checked = reason[index].value == col[11];
}

// Read these after selectAirport mucks up the dist/duration
Expand Down Expand Up @@ -3050,7 +3038,9 @@ function calcDuration(param) {
duration = 0;

// Need both airports first
if ($("src_apid").value == 0 || $("dst_apid").value == 0) return;
if ($("src_apid").value == 0 || $("dst_apid").value == 0) {
return;
}
dst_time = $("dst_time").value.trim();
if (dst_time == "" || dst_time == "HH:MM") {
dst_time = 0;
Expand Down Expand Up @@ -3824,11 +3814,9 @@ function logout(str) {
// Get current transport mode
function getMode() {
if (getCurrentPane() == "input") {
mode = document.forms["inputform"].mode.value;
} else {
mode = "F";
return document.forms["inputform"].mode.value;
}
return mode;
return "F";
}

// Functions for swapping between lower panes
Expand Down