diff options
-rw-r--r-- | index.pl | 24 | ||||
-rw-r--r-- | templates/layouts/default.html.ep | 10 |
2 files changed, 33 insertions, 1 deletions
@@ -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 </div> </div> + <div class="break"></div> + <span class="optional">Nur für IRIS-Backend:</span> + <div class="field"> + <div class="desc"> + Ankunft- oder Abfahrtzeiten anzeigen? + </div> + <div> + %= select_field admode => [['Abfahrt bevorzugen' => 'deparr'], ['Nur Abfahrt' => 'dep'], ['Nur Ankunft' => 'arr']] + </div> + </div> </div> % end |