diff options
author | Birte Kristina Friesel <derf@finalrewind.org> | 2024-07-08 20:47:54 +0200 |
---|---|---|
committer | Birte Kristina Friesel <derf@finalrewind.org> | 2024-07-08 20:47:54 +0200 |
commit | 17563a9284665f5f9852ce9da25b94c8bb9389c2 (patch) | |
tree | 37dc8c2960b251164d00d746b901fdc0d963e4db | |
parent | e04f4cde71003079789236b9b4ccb6b90b2806cb (diff) |
distinguish between 'on time' and 'no realtime data available' in rt=1
-rw-r--r-- | lib/DBInfoscreen.pm | 19 | ||||
-rw-r--r-- | lib/DBInfoscreen/Controller/Stationboard.pm | 20 | ||||
-rw-r--r-- | sass/app.scss | 10 | ||||
-rw-r--r-- | sass/dark.scss | 2 | ||||
-rw-r--r-- | sass/light.scss | 2 | ||||
-rw-r--r-- | templates/app.html.ep | 3 |
6 files changed, 48 insertions, 8 deletions
diff --git a/lib/DBInfoscreen.pm b/lib/DBInfoscreen.pm index 1fd3674..174fc97 100644 --- a/lib/DBInfoscreen.pm +++ b/lib/DBInfoscreen.pm @@ -273,6 +273,25 @@ sub startup { } ); + $self->helper( + 'get_rt_time_class' => sub { + my ( $self, $train ) = @_; + if ( $train->{has_realtime} + and not $train->{is_bit_delayed} + and not $train->{is_delayed} ) + { + return 'on-time'; + } + if ( $train->{is_bit_delayed} ) { + return 'a-bit-delayed'; + } + if ( $train->{is_delayed} ) { + return 'delayed'; + } + return q{}; + } + ); + my $r = $self->routes; $r->get('/_redirect')->to('stationboard#redirect_to_station'); diff --git a/lib/DBInfoscreen/Controller/Stationboard.pm b/lib/DBInfoscreen/Controller/Stationboard.pm index 8e1e7df..f81074b 100644 --- a/lib/DBInfoscreen/Controller/Stationboard.pm +++ b/lib/DBInfoscreen/Controller/Stationboard.pm @@ -1875,11 +1875,15 @@ sub handle_result { } $result->qos_messages ], }, - station => $result->station, - moreinfo => $moreinfo, - delay => $delay, + station => $result->station, + moreinfo => $moreinfo, + delay => $delay, + is_bit_delayed => + ( $delay and $delay > 0 and $delay < 5 ? 1 : 0 ), + is_delayed => ( $delay and $delay >= 5 ? 1 : 0 ), arrival_delay => $result->arrival_delay, departure_delay => $result->departure_delay, + has_realtime => $result->has_realtime, missing_realtime => ( not $result->has_realtime and $result->start < $now ? 1 : 0 @@ -1939,9 +1943,13 @@ sub handle_result { station => $result->station, moreinfo => $moreinfo, delay => $delay, - replaced_by => [], - replacement_for => [], - route_pre => $admode eq 'arr' + is_bit_delayed => + ( $delay and $delay > 0 and $delay < 5 ? 1 : 0 ), + is_delayed => ( $delay and $delay >= 5 ? 1 : 0 ), + has_realtime => defined $delay ? 1 : 0, + replaced_by => [], + replacement_for => [], + route_pre => $admode eq 'arr' ? [ map { $_->loc->name } $result->route ] : [], route_post => $admode eq 'arr' ? [] diff --git a/sass/app.scss b/sass/app.scss index 347133e..4d02ee1 100644 --- a/sass/app.scss +++ b/sass/app.scss @@ -418,6 +418,16 @@ div.app { background-color: transparent; } + &.a-bit-delayed { + color: $smalldelay-color; + background-color: transparent; + } + + &.on-time { + color: $ontime-color; + background-color: transparent; + } + .no-realtime { background-color: transparent; padding-right: 1ex; diff --git a/sass/dark.scss b/sass/dark.scss index c0e8d2b..78b61b0 100644 --- a/sass/dark.scss +++ b/sass/dark.scss @@ -32,9 +32,11 @@ $route-color: #dddddd; $info-color: #ff7777; $delay-color: #ff7777; +$smalldelay-color: #dd9999; $undelay-color: #77ff77; $delaynorm-color: #dd9999; $undelaynorm-color: #99dd99; +$ontime-color: #aaeeaa; $additional-stop-color: #77ff77; $cancelled-stop-color: #ff7777; diff --git a/sass/light.scss b/sass/light.scss index 1dee6a9..60981b1 100644 --- a/sass/light.scss +++ b/sass/light.scss @@ -32,9 +32,11 @@ $route-color: #444444; $info-color: #ff0000; $delay-color: #ff0000; +$smalldelay-color: #bb3333; $undelay-color: #006600; $delaynorm-color: #bb3333; $undelaynorm-color: #338833; +$ontime-color: #227722; $additional-stop-color: #009900; $cancelled-stop-color: #cc0000; diff --git a/templates/app.html.ep b/templates/app.html.ep index e81191b..a499dd7 100644 --- a/templates/app.html.ep +++ b/templates/app.html.ep @@ -100,8 +100,7 @@ %= $departure->{origin} </span> % } - <span class="time <%= ($show_realtime and $departure->{delay} and not - $departure->{is_cancelled}) ? 'delayed' : q{} %>"> + <span class="time <%= $show_realtime ? get_rt_time_class($departure) : q{} %>"> % if ($departure->{delay} and not $departure->{is_cancelled}) { % if ($show_realtime) { % if ($departure->{delay} > ($hide_low_delay ? 4 : 0)) { |