summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2025-06-16 20:01:07 +0200
committerBirte Kristina Friesel <derf@finalrewind.org>2025-06-16 20:01:07 +0200
commit6ea954c9634912f499c2f1c2b3356d491e40f747 (patch)
treeafec2e6ae5860e5797b66ad2e6123f58f775cd53
parent68fcdf3d6ffc0253eb8f9f64631256fed3128549 (diff)
show load/occupancy for EFA departures and trips, if available
-rwxr-xr-xlib/Travelynx.pm26
-rw-r--r--templates/_departures_efa.html.ep3
-rw-r--r--templates/_show_load_icons.html.ep4
3 files changed, 33 insertions, 0 deletions
diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm
index 3d892ec..7c8dc19 100755
--- a/lib/Travelynx.pm
+++ b/lib/Travelynx.pm
@@ -447,6 +447,32 @@ sub startup {
);
$self->helper(
+ 'efa_load_icon' => sub {
+ my ( $self, $occupancy ) = @_;
+
+ my @symbols
+ = (
+ qw(help_outline person_outline people priority_high not_interested)
+ );
+
+ if ( $occupancy eq 'MANY_SEATS' ) {
+ $occupancy = 1;
+ }
+ elsif ( $occupancy eq 'FEW_SEATS' ) {
+ $occupancy = 2;
+ }
+ elsif ( $occupancy eq 'STANDING_ONLY' ) {
+ $occupancy = 3;
+ }
+ elsif ( $occupancy eq 'FULL' ) {
+ $occupancy = 4;
+ }
+
+ return $symbols[$occupancy] // 'help_outline';
+ }
+ );
+
+ $self->helper(
'load_icon' => sub {
my ( $self, $load ) = @_;
my $first = $load->{FIRST} // 0;
diff --git a/templates/_departures_efa.html.ep b/templates/_departures_efa.html.ep
index 6aec1c8..0abd887 100644
--- a/templates/_departures_efa.html.ep
+++ b/templates/_departures_efa.html.ep
@@ -47,6 +47,9 @@
<%= $checkin->{followee_name} %> → <%= $checkin->{arr_name} // '???' %>
</span>
% }
+ % if ($result->occupancy) {
+ <i class="material-icons tiny" aria-hidden="true"><%= efa_load_icon($result->occupancy) %></i>
+ % }
% }
</span>
</li>
diff --git a/templates/_show_load_icons.html.ep b/templates/_show_load_icons.html.ep
index e69dab5..21093b9 100644
--- a/templates/_show_load_icons.html.ep
+++ b/templates/_show_load_icons.html.ep
@@ -5,3 +5,7 @@
% }
<i class="material-icons tiny" aria-hidden="true"><%= $second %></i>
% }
+% elsif ($station->[2]{efa_load}) {
+ % my ($icon) = efa_load_icon($station->[2]{efa_load});
+ <i class="material-icons tiny" aria-hidden="true"><%= $icon %></i>
+% }