summaryrefslogtreecommitdiff
path: root/index.pl
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2014-11-28 16:34:20 +0100
committerDaniel Friesel <derf@finalrewind.org>2014-11-28 16:34:20 +0100
commitda0d796885f04271ebca145f3dc378f5c60b5fe3 (patch)
treece165ad9cb5252fb357e5c63d8d84ed7795712e1 /index.pl
parenteeb777112f61ec4f133c8f890ff76aeaabf5729e (diff)
add option to hide arrivals / departures
Diffstat (limited to 'index.pl')
-rw-r--r--index.pl24
1 files changed, 23 insertions, 1 deletions
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,