From da0d796885f04271ebca145f3dc378f5c60b5fe3 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 28 Nov 2014 16:34:20 +0100 Subject: add option to hide arrivals / departures --- index.pl | 24 +++++++++++++++++++++++- templates/layouts/default.html.ep | 10 ++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/index.pl b/index.pl index 9b4b3ea..1665e4f 100644 --- a/index.pl +++ b/index.pl @@ -72,6 +72,7 @@ sub handle_request { my $hide_low_delay = $self->param('hidelowdelay') // 0; my $hide_opts = $self->param('hide_opts') // 0; my $backend = $self->param('backend') // 'ris'; + my $admode = $self->param('admode') // 'deparr'; my $callback = $self->param('callback'); my $api_version @@ -191,6 +192,16 @@ sub handle_request { if ( @lines and not( any { $line =~ m{^$_} } @lines ) ) { next; } + if ( $backend eq 'iris' and $admode eq 'arr' and not $result->arrival ) + { + next; + } + if ( $backend eq 'iris' + and $admode eq 'dep' + and not $result->departure ) + { + next; + } my ( $info, $moreinfo ); if ( $backend eq 'iris' ) { my $delaymsg @@ -239,6 +250,17 @@ sub handle_request { } } + my $time = $result->time; + + if ( $backend eq 'iris' ) { + + # ->time defaults to dep, so we only need to overwrite $time + # if we want arrival times + if ( $admode eq 'arr' ) { + $time = $result->sched_arrival->strftime('%H:%M'); + } + } + if ( $info eq '+0' ) { $info = undef; } @@ -257,7 +279,7 @@ sub handle_request { push( @departures, { - time => $result->time, + time => $time, train => $result->train, via => [ $result->route_interesting(3) ], destination => $result->destination, diff --git a/templates/layouts/default.html.ep b/templates/layouts/default.html.ep index 17181e0..85ef48c 100644 --- a/templates/layouts/default.html.ep +++ b/templates/layouts/default.html.ep @@ -113,6 +113,16 @@ %= check_box 'hide_opts' => 1 +
+ Nur für IRIS-Backend: +
+
+ Ankunft- oder Abfahrtzeiten anzeigen? +
+
+ %= select_field admode => [['Abfahrt bevorzugen' => 'deparr'], ['Nur Abfahrt' => 'dep'], ['Nur Ankunft' => 'arr']] +
+
% end -- cgit v1.2.3