summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2014-12-04 12:21:48 +0100
committerDaniel Friesel <derf@finalrewind.org>2014-12-04 12:21:48 +0100
commitcbbe35517e92f6cdf926a42eb167fca566881233 (patch)
tree2dea7808c7332f8bf22e98799244e7b3368ea318
parentda0d796885f04271ebca145f3dc378f5c60b5fe3 (diff)
iris+clean: show and sort by actual (estimated) arr/dep times
-rw-r--r--index.pl38
-rw-r--r--public/default.css10
-rw-r--r--templates/clean.html.ep13
-rw-r--r--templates/layouts/default.html.ep8
4 files changed, 63 insertions, 6 deletions
diff --git a/index.pl b/index.pl
index 1665e4f..2d4eb37 100644
--- a/index.pl
+++ b/index.pl
@@ -68,11 +68,12 @@ sub handle_request {
my @platforms = split( /,/, $self->param('platforms') // q{} );
my @lines = split( /,/, $self->param('lines') // q{} );
- my $template = $self->param('mode') // 'multi';
- 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 $template = $self->param('mode') // 'multi';
+ my $hide_low_delay = $self->param('hidelowdelay') // 0;
+ my $hide_opts = $self->param('hide_opts') // 0;
+ my $show_realtime = $self->param('show_realtime') // 0;
+ my $backend = $self->param('backend') // 'ris';
+ my $admode = $self->param('admode') // 'deparr';
my $callback = $self->param('callback');
my $api_version
@@ -173,6 +174,21 @@ sub handle_request {
@results = sort { $a->platform <=> $b->platform } @results;
}
+ if ( $backend eq 'iris' and $show_realtime ) {
+ if ( $admode eq 'arr' ) {
+ @results = sort {
+ ( $a->arrival // $a->departure )
+ <=> ( $b->arrival // $b->depearture )
+ } @results;
+ }
+ else {
+ @results = sort {
+ ( $a->departure // $a->arrival )
+ <=> ( $b->departure // $b->arrival )
+ } @results;
+ }
+ }
+
for my $result (@results) {
my $platform = ( split( / /, $result->platform ) )[0];
my $line = $result->line;
@@ -259,6 +275,17 @@ sub handle_request {
if ( $admode eq 'arr' ) {
$time = $result->sched_arrival->strftime('%H:%M');
}
+
+ if ($show_realtime) {
+ if ( ( $admode eq 'arr' and $result->arrival )
+ or not $result->departure )
+ {
+ $time = $result->arrival->strftime('%H:%M');
+ }
+ else {
+ $time = $result->departure->strftime('%H:%M');
+ }
+ }
}
if ( $info eq '+0' ) {
@@ -324,6 +351,7 @@ sub handle_request {
title => "departures for ${station}",
refresh_interval => $refresh_interval + 3,
hide_opts => $hide_opts,
+ show_realtime => $show_realtime,
);
}
}
diff --git a/public/default.css b/public/default.css
index 350db27..edcb82a 100644
--- a/public/default.css
+++ b/public/default.css
@@ -155,6 +155,12 @@ div.displayclean li .countdown .delay {
padding-right:7px;
}
+div.displayclean li .countdown .delaynorm {
+ font-size:0.9em;
+ color:#BB3333;
+ padding-right:7px;
+}
+
div.displayclean li .countdown .platform {
font-weight: bold;
}
@@ -168,6 +174,10 @@ div.displayclean li .time {
top:5px;
}
+div.displayclean span.delayed {
+ color: #ff0000;
+}
+
div.displaymulti {
border: 0.2em solid #000066;
width: 55em;
diff --git a/templates/clean.html.ep b/templates/clean.html.ep
index 21750d5..f073c2e 100644
--- a/templates/clean.html.ep
+++ b/templates/clean.html.ep
@@ -58,15 +58,26 @@
</span>
<span class="countdown">
% if ($departure->{delay} and not $departure->{is_cancelled}) {
+% if ($show_realtime) {
+<span class="delaynorm">(+<%= $departure->{delay} %>)</span>
+% }
+% else {
<span class="delay">(+<%= $departure->{delay} %>)</span>
% }
+% }
<span class="platform">
%= $departure->{platform}
</span>
</span>
-<span class="time">
+<span class="time <%= ($show_realtime and $departure->{delay} and not $departure->{is_cancelled}) ? 'delayed' : q{} %>">
+% if ($show_realtime and $departure->{delay} and not $departure->{is_cancelled}) {
+<span class="delayed">
+% }
%= $departure->{time}
</span>
+% if ($show_realtime and $departure->{delay} and not $departure->{is_cancelled}) {
+</span>
+% }
</li>
<!--
diff --git a/templates/layouts/default.html.ep b/templates/layouts/default.html.ep
index 85ef48c..a6ffaae 100644
--- a/templates/layouts/default.html.ep
+++ b/templates/layouts/default.html.ep
@@ -123,6 +123,14 @@
%= select_field admode => [['Abfahrt bevorzugen' => 'deparr'], ['Nur Abfahrt' => 'dep'], ['Nur Ankunft' => 'arr']]
</div>
</div>
+ <div class="field">
+ <div class="desc">
+ Erwartete Abfahrtzeiten statt Fahrplandaten verwenden?
+ </div>
+ <div>
+ %= check_box 'show_realtime' => 1
+ </div>
+ </div>
</div>
% end