From 663b4dc6d89d21caa6b670d69780754b40910d90 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 29 Oct 2019 21:18:46 +0100 Subject: live update of next station via javascript --- lib/Travelynx.pm | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'lib') diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm index b29d63b..84310d9 100755 --- a/lib/Travelynx.pm +++ b/lib/Travelynx.pm @@ -2405,6 +2405,36 @@ sub startup { } ); + $self->helper( + 'journey_to_ajax_route' => sub { + my ( $self, $journey ) = @_; + + my @route; + + for my $station ( @{ $journey->{route_after} } ) { + my $station_desc = $station->[0]; + if ( $station->[1]{rt_arr} ) { + $station_desc .= $station->[1]{sched_arr}->strftime(';%s'); + $station_desc .= $station->[1]{rt_arr}->strftime(';%s'); + if ( $station->[1]{rt_dep} ) { + $station_desc + .= $station->[1]{sched_dep}->strftime(';%s'); + $station_desc .= $station->[1]{rt_dep}->strftime(';%s'); + } + else { + $station_desc .= ';0;0'; + } + } + else { + $station_desc .= ';0;0;0;0'; + } + push( @route, $station_desc ); + } + + return join( '|', @route ); + } + ); + $self->helper( 'get_user_status' => sub { my ( $self, $uid ) = @_; -- cgit v1.2.3