summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2019-10-29 21:18:46 +0100
committerDaniel Friesel <derf@finalrewind.org>2019-10-29 21:18:46 +0100
commit663b4dc6d89d21caa6b670d69780754b40910d90 (patch)
tree17571683194e5c26a036c69e0f2130280ec31457 /lib
parentf13b4755c7db9df079c6fdb0d22679358a9585b9 (diff)
live update of next station via javascript
Diffstat (limited to 'lib')
-rwxr-xr-xlib/Travelynx.pm30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm
index b29d63b..84310d9 100755
--- a/lib/Travelynx.pm
+++ b/lib/Travelynx.pm
@@ -2406,6 +2406,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 ) = @_;