1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
% if ($error) {
<div class="row">
<div class="col s12">
<div class="card red darken-4">
<div class="card-content white-text">
<span class="card-title">Fehler</span>
<p>Zugfahrt nicht gefunden.<p/>
</div>
</div>
</div>
</div>
% }
% else {
<div class="row">
<div class="col s12">
<p>
% if ($journey->{cancelled}) {
Ausgefallene Fahrt von
% }
% else {
Fahrt von
% }
<b><%= $journey->{from_name} %></b>
nach
<b><%= $journey->{to_name} %></b>
am
<b><%= $journey->{sched_departure}->strftime('%d.%m.%Y') %></b>
</p>
<table class="striped">
<tr>
<th scope="row">Zug</th>
<td>
<%= $journey->{type} %> <%= $journey->{no} %>
% if ($journey->{line}) {
(Linie <%= $journey->{line} %>)
% }
</td>
</tr>
<tr>
<th scope="row">Abfahrt</th>
<td>
% if ($journey->{cancelled}) {
<i class="material-icons">cancel</i>
(Plan: <%= $journey->{sched_departure}->strftime('%H:%M'); %>)
% }
% elsif ($journey->{rt_departure} != $journey->{sched_departure}) {
%= $journey->{rt_departure}->strftime('%H:%M');
(<%= sprintf('%+d', ($journey->{rt_departure}->epoch - $journey->{sched_departure}->epoch) / 60) %>,
Plan: <%= $journey->{sched_departure}->strftime('%H:%M'); %>)
% }
% else {
%= $journey->{sched_departure}->strftime('%H:%M');
% }
</td>
</tr>
<tr>
<th scope="row">Ankunft</th>
<td>
% if ($journey->{cancelled}) {
<i class="material-icons">cancel</i>
% if ($journey->{sched_arrival}->epoch != 0) {
(Plan: <%= $journey->{sched_arrival}->strftime('%H:%M'); %>)
% }
% }
% elsif ($journey->{rt_arrival}->epoch == 0 and $journey->{sched_arrival}->epoch == 0) {
<i class="material-icons">timer_off</i>
% }
% elsif ($journey->{rt_arrival} != $journey->{sched_arrival}) {
%= $journey->{rt_arrival}->strftime('%H:%M');
(<%= sprintf('%+d', ($journey->{rt_arrival}->epoch - $journey->{sched_arrival}->epoch) / 60) %>,
Plan: <%= $journey->{sched_arrival}->strftime('%H:%M'); %>)
% }
% else {
%= $journey->{sched_arrival}->strftime('%H:%M');
% }
</td>
</tr>
<tr>
<th scope="row">Entfernung</th>
<td>
% my $distance = get_travel_distance($journey->{from_name}, $journey->{to_name}, $journey->{route});
% my $beeline = get_travel_distance($journey->{from_name}, $journey->{to_name}, [$journey->{from_name}, $journey->{to_name}]);
% if ($distance > 0.1) {
ca. <%= sprintf('%.f', $distance) %> km
% }
(Luftlinie: <%= sprintf('%.f', $beeline) %> km)
</td>
</tr>
<tr>
<th scope="row">Meldungen</th>
<td>
% for my $message (@{$journey->{messages} // []}) {
% my ($ts, $msg) = @{$message};
<%= $ts->strftime('%d.%m.%Y %H:%M') %> : <%= $msg %><br/>
% }
</td>
</tr>
<tr>
<th scope="row">Route</th>
<td>
% my $within = 0;
% my $at_startstop = 0;
% for my $station (@{$journey->{route}}) {
% if ($station eq $journey->{from_name}) {
% $within = 1; $at_startstop = 1;
% }
% elsif ($station eq $journey->{to_name}) {
% $within = 0; $at_startstop = 1;
% }
% else {
% $at_startstop = 0;
% }
% if ($at_startstop or $within) {
<%= $station %>
% }
% else {
<span style="color: #666666;"><%= $station %></span>
% }
<br/>
% }
</td>
</tr>
</table>
</div>
</div>
% }
|