Skip to content

Commit 31698da

Browse files
committed
add support for vehicle occupancy and inv number for stop times
1 parent 44d0200 commit 31698da

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/js/map_stops.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,22 @@ function display_stop_times(stop_routes) {
170170
row.appendChild(td);
171171
}
172172
{
173-
for(const { actual_time, scheduled_time } of route.times) {
173+
for(const { actual_time, scheduled_time, occupancy: vehicle_occupancy } of route.times) {
174174
const td = document.createElement('td');
175175
const r = display_hours(scheduled_time, actual_time);
176-
td.innerHTML = r[0] + (r[1] ? ` <br>${r[1]}` : '');
176+
let occupancy = '';
177+
if(vehicle_occupancy) {
178+
const mappings = {
179+
'EMPTY': '<i class="bi bi-person text-success" title="Празен"></i>',
180+
'MANY_SEATS_AVAILABLE': '<i class="bi bi-person text-success" title="Много свободни места"></i>',
181+
'FEW_SEATS_AVAILABLE': '<i class="bi bi-people-fill text-success" title="Малко свободни места"></i>',
182+
'STANDING_ROOM_ONLY': '<i class="bi bi-people-fill text-danger" title="Само правостоящи"></i>',
183+
'CRUSHED_STANDING_ROOM_ONLY': '<i class="bi bi-people-fill text-danger" title="Претъпкано"></i>',
184+
'FULL': '<i class="bi bi-people-fill text-danger" title="Пълен"></i>'
185+
};
186+
occupancy = mappings[vehicle_occupancy] || vehicle_occupancy;
187+
}
188+
td.innerHTML = r[0] + (r[1] ? ` <br>${r[1]}` : '') + (occupancy ? ` ${occupancy}` : '');
177189
row.appendChild(td);
178190
}
179191
for(let i = route.times.length; i < 3; i++) {

0 commit comments

Comments
 (0)