Skip to content

Commit ea89d58

Browse files
committed
apply some lint rules
1 parent cfc2ee2 commit ea89d58

File tree

5 files changed

+36
-36
lines changed

5 files changed

+36
-36
lines changed

src/js/cache.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { calculate_bearing, calculate_distance, proper_inv_number_for_sorting }
77
import { find_vehicle_in_cache } from './cache';
88

99
function is_vehicle_in_depot(type, coords) {
10-
return depots_data.some(depot =>
10+
return depots_data.some(depot =>
1111
depot.polygon
1212
&& (depot.type == type || depot.type.includes(type))
1313
&& booleanPointInPolygon(coords, depot.polygon)
@@ -112,7 +112,7 @@ export function add_to_cache(new_vehicle, tables_to_update, cache) {
112112
// else if(new_vehicle.route_ref == '') {
113113
// tables_to_update.add(`${vehicle.type}/null`);
114114
// }
115-
115+
116116
if(!vehicle) {
117117
new_vehicle.hidden = false;
118118
cache.set(new_vehicle.cgm_id, new_vehicle);

src/js/filter_stops.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ window.update_stop_suggestions = function() {
3131
const stop = stops.get(code);
3232
const btn = document.createElement('button');
3333
btn.onclick = () => {
34-
map.flyTo(stop.coords, 18, {animate: false});
34+
map.flyTo(stop.coords, 18, {animate: false});
3535
setTimeout(() => {
3636
stop.marker.fire('click');
3737
if(is_screen_width_lg_or_less()) {

src/js/filter_vehicles.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ function filter_by_all_params(type, depot_id, inv_number, is_double_decker, is_u
2929
const trs = Array.from(tbody.querySelectorAll('button[data-depot-id]'));
3030
for(const tr of trs) {
3131
const is_depot_ok = depot_id == 0 || tr.dataset.depotId == depot_id;
32-
const is_inv_number_ok = inv_number == 0
33-
|| inv_number == tr.dataset.invNumber
32+
const is_inv_number_ok = inv_number == 0
33+
|| inv_number == tr.dataset.invNumber
3434
|| tr.dataset.invNumber.includes(inv_number)
3535
|| tr.dataset.invNumber.includes('/') && tr.dataset.invNumber.includes(inv_number);
3636
const is_double_decker_ok = !is_double_decker || tr.dataset.doubleDecker;
3737
const is_unexpected_ok = !is_unexpected || tr.dataset.isUnexpected == 'true';
38-
38+
3939
if(!is_depot_ok || !is_inv_number_ok || !is_double_decker_ok || !is_unexpected_ok) {
4040
tr.classList.add('d-none');
4141
continue;

src/js/map.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export function init_map() {
1717
zoom: 15,
1818
zoomControl: false,
1919
maxBounds: [[42.9002, 23.0624], [42.5166, 23.6455]],
20-
minZoom: 13,
20+
minZoom: 13
2121
});
2222
map.invalidateSize();
2323
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'}).addTo(map);

src/js/utils.js

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,53 +8,53 @@ export function calculate_bearing(old_coords, new_coords) {
88
const [lat1, lon1] = old_coords;
99
const [lat2, lon2] = new_coords;
1010

11-
if(lat1 == lat2 && lon1 == lon2) {
12-
return null;
13-
}
14-
15-
/*
16-
Using simple trigonometry to calculate bearing
17-
between two points on the Earth's surface.
18-
19-
Using Great-circle bearing formula is not necessary
20-
and too expensive for this task.
21-
22-
The points are quite close to each other, so the
23-
approximation is acceptable and the Earth's curvature
24-
can be safely ignored.
25-
*/
26-
const deltaLat = lat2 - lat1;
11+
if(lat1 == lat2 && lon1 == lon2) {
12+
return null;
13+
}
14+
15+
/*
16+
Using simple trigonometry to calculate bearing
17+
between two points on the Earth's surface.
18+
19+
Using Great-circle bearing formula is not necessary
20+
and too expensive for this task.
21+
22+
The points are quite close to each other, so the
23+
approximation is acceptable and the Earth's curvature
24+
can be safely ignored.
25+
*/
26+
const deltaLat = lat2 - lat1;
2727
const deltaLon = lon2 - lon1;
2828
const bearingRad = Math.atan2(deltaLon, deltaLat);
2929
const bearingDeg = toDegrees(bearingRad);
30-
return ((bearingDeg + 180) % 360).toFixed(0);
30+
return ((bearingDeg + 180) % 360).toFixed(0);
3131
}
3232

3333
function toRadians(degrees) {
34-
return degrees * (Math.PI / 180);
34+
return degrees * (Math.PI / 180);
3535
}
3636

3737
function toDegrees(radians) {
38-
return radians * (180 / Math.PI);
38+
return radians * (180 / Math.PI);
3939
}
4040

4141
export function calculate_distance([lat1, lon1], [lat2, lon2]) {
4242
if(lat1 == lat2 && lon1 == lon2) {
4343
return 0;
4444
}
4545

46-
const R = 6371e3; // Earth radius in meters
47-
const φ1 = toRadians(lat1);
48-
const φ2 = toRadians(lat2);
49-
const Δφ = toRadians(lat2 - lat1);
50-
const Δλ = toRadians(lon2 - lon1);
46+
const R = 6371e3; // Earth radius in meters
47+
const phi1 = toRadians(lat1);
48+
const phi2 = toRadians(lat2);
49+
const deltaPhi = toRadians(lat2 - lat1);
50+
const deltaLambda = toRadians(lon2 - lon1);
5151

52-
const a = Math.sin(Δφ / 2) * Math.sin(Δφ / 2) +
53-
Math.cos(φ1) * Math.cos(φ2) *
54-
Math.sin(Δλ / 2) * Math.sin(Δλ / 2);
55-
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
52+
const a = Math.sin(deltaPhi / 2) * Math.sin(deltaPhi / 2) +
53+
Math.cos(phi1) * Math.cos(phi2) *
54+
Math.sin(deltaLambda / 2) * Math.sin(deltaLambda / 2);
55+
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
5656

57-
return R * c; // in meters
57+
return R * c; // in meters
5858
}
5959

6060
export function proper_inv_number(inv_number) {

0 commit comments

Comments
 (0)