diff options
| -rwxr-xr-x | lib/Travelynx/Controller/Traveling.pm | 23 | ||||
| -rw-r--r-- | templates/_suggestions_efa.html.ep | 53 | ||||
| -rw-r--r-- | templates/departures.html.ep | 3 |
3 files changed, 79 insertions, 0 deletions
diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm index 6f8e905..154938d 100755 --- a/lib/Travelynx/Controller/Traveling.pm +++ b/lib/Travelynx/Controller/Traveling.pm @@ -1368,6 +1368,28 @@ sub station { station_name => $status->stop->full_name, related_stations => [], }; + my $backend_id + = $self->stations->get_backend_id( efa => $efa_service ); + my @destinations = $self->journeys->get_connection_targets( + uid => $uid, + backend_id => $backend_id, + eva => $status->{station_eva}, + ); + for my $dep (@results) { + destination: for my $dest (@destinations) { + for my $stop ( $dep->route_post ) { + if ( $stop->full_name eq $dest->{name} ) { + push( @suggestions, [ $dep, $dest ] ); + next destination; + } + } + } + } + + @suggestions = map { $_->[0] } + sort { $a->[1] <=> $b->[1] } + grep { $_->[1] >= $now - 300 and $_->[1] <= $now + 1800 } + map { [ $_, $_->[0]->datetime->epoch ] } @suggestions; } elsif ($motis_service) { @results = map { $_->[0] } @@ -1504,6 +1526,7 @@ sub station { related_stations => $status->{related_stations}, user_status => $user_status, can_check_out => $can_check_out, + suggestions => \@suggestions, title => "travelynx: $status->{station_name}", ); } diff --git a/templates/_suggestions_efa.html.ep b/templates/_suggestions_efa.html.ep new file mode 100644 index 0000000..68fb4a9 --- /dev/null +++ b/templates/_suggestions_efa.html.ep @@ -0,0 +1,53 @@ +<ul class="collection departures connections"> + % for my $res (@{$suggestions}) { + % my ($dep, $dest) = @{$res}; + % my $row_class = ''; + % my $link_class = 'action-checkin'; + % if ($dep->is_cancelled) { + % $row_class = 'cancelled'; + % $link_class = 'action-cancelled-from'; + % } + % if ($checkin_from) { + <li class="collection-item <%= $row_class %> <%= $link_class %>" + data-efa="<%= $efa %>" + data-station="<%= $dep->stop_id_num %>" + data-train="<%= $dep->id %>" + data-ts="<%= ($dep->sched_datetime // $dep->datetime)->epoch %>" + data-dest="<%= $dest->{name} %>"> + % } + % else { + <li class="collection-item <%= $row_class %>"> + % } + <a class="dep-time" href="#"> + % if ($dep->is_cancelled) { + %= $dep->sched_datetime->strftime('%H:%M') + % } + % else { + %= $dep->datetime->strftime('%H:%M') + % } + % if ($dep->delay) { + %= sprintf('(%+d)', $dep->delay) + % } + </a> + <span class="connect-platform-wrapper"> + % if ($dep->platform) { + <span> + % if (($dep->type // q{}) =~ m{ ast | bus | ruf }ix) { + Steig + % } + % else { + Gleis + % } + %= $dep->platform + </span> + % } + <span class="dep-line <%= ($dep->type // q{}) =~ tr{a-zA-Z_-}{}cdr %>"> + %= $dep->line + </span> + </span> + <span class="dep-dest"> + %= $dest->{name} + </span> + </li> + % } +</ul> diff --git a/templates/departures.html.ep b/templates/departures.html.ep index db12422..fafbf0e 100644 --- a/templates/departures.html.ep +++ b/templates/departures.html.ep @@ -103,6 +103,9 @@ % if ($dbris) { %= include '_suggestions_dbris', suggestions => stash('suggestions'), checkin_from => $eva; % } + % elsif ($efa) { + %= include '_suggestions_efa', suggestions => stash('suggestions'), checkin_from => $eva; + % } % } </div> </div> |
