summaryrefslogtreecommitdiff
path: root/templates/_checked_in.html.ep
blob: f91576966fd7827d1a3b3cd84ef8b650a520c53f (plain)
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
<div class="autorefresh">
	<div class="card">
		<div class="card-content">
			<i class="material-icons small right sync-failed-marker grey-text" style="display: none;">sync_problem</i>
			<span class="card-title">Eingecheckt in <%= $journey->{train_type} %> <%= $journey->{train_no} %></span>
			% if ($journey->{comment}) {
				<p><%= $journey->{comment} %></p>
			% }
			<p>
				<div class="center-align countdown"
					data-journey="<%= $journey->{real_departure}->epoch %>;<%= <%= $journey->{real_arrival}->epoch %>"
					data-route="<%= journey_to_ajax_route($journey) %>"
					data-dest="<%= $journey->{arr_name} %>"
					>
					% if ($journey->{boarding_countdown} > 120) {
						Einfahrt in <%= sprintf('%.f', $journey->{boarding_countdown} / 60) %> Minuten<br/>
					% }
					% elsif ($journey->{boarding_countdown} > 60) {
						Einfahrt in einer Minute<br/>
					% }
					% elsif ($journey->{boarding_countdown} > 0) {
						Zug fährt ein<br/>
					% }
					% if ($journey->{departure_countdown} > 120) {
						Abfahrt in <%= sprintf('%.f', $journey->{departure_countdown} / 60) %> Minuten
					% }
					% elsif ($journey->{departure_countdown} > 60) {
						Abfahrt in einer Minute
					% }
					% elsif ($journey->{departure_countdown} > 0) {
						Abfahrt in weniger als einer Minute
					% }
					% elsif (defined $journey->{arrival_countdown}) {
						% if ($journey->{arrival_countdown} > 60) {
							Ankunft in <%= sprintf('%.f', $journey->{arrival_countdown} / 60) %>
							Minute<%= sprintf('%.f', $journey->{arrival_countdown} / 60) == 1 ? '' : 'n' %>
						% }
						% elsif ($journey->{arrival_countdown} > 0) {
							Ankunft in weniger als einer Minute
						% }
						% else {
							Ziel erreicht
						% }
						% if ($journey->{arrival_countdown} < (60 * 15) and $journey->{arr_platform}) {
							% if ($journey->{arr_direction} and $journey->{arr_direction} eq 'r') {
								<br/>Gleis <%= $journey->{arr_platform} %> ▶
							% }
							% elsif ($journey->{arr_direction} and $journey->{arr_direction} eq 'l') {
								<br/>◀ Gleis <%= $journey->{arr_platform} %>
							% }
							% else {
								<br/>auf Gleis <%= $journey->{arr_platform} %>
							% }
						% }
					% }
					% elsif ($journey->{arr_name}) {
						Ankunft in mehr als zwei Stunden
					% }
					% if ($journey->{departure_countdown} > 0 and $journey->{dep_platform}) {
						% if ($journey->{dep_direction} and $journey->{dep_direction} eq 'r') {
							<br/>Gleis <%= $journey->{dep_platform} %> ▶
						% }
						% elsif ($journey->{dep_direction} and $journey->{dep_direction} eq 'l') {
							<br/>◀ Gleis <%= $journey->{dep_platform} %>
						% }
						% else {
							<br/>von Gleis <%= $journey->{dep_platform} %>
						% }
					% }
					% if (my $wr = $journey->{wagonorder}) {
						<br/>
						% my @wagons = $wr->wagons;
						% my $direction = $wr->direction == 100 ? '→' : '←';
						% if ($journey->{dep_direction}) {
							% $direction = $journey->{dep_direction} eq 'l' ? '◀' : '▶';
							% if (($journey->{dep_direction} eq 'l' ? 0 : 100) != $wr->direction) {
								% @wagons = reverse @wagons;
							% }
						% }
						<a href="https://marudor.de/details/<%= $journey->{train_type} %>%20<%= $journey->{train_no} %>/<%= DateTime->now(time_zone => 'Europe/Berlin')->epoch %>000">
						%= $direction
						% for my $wagon (@wagons) {
							% if (not ($wagon->is_locomotive or $wagon->is_powercar)) {
								%= $wagon->number || $wagon->type
							% }
						% }
						%= $direction
						</a>
					% }
				</div>
				<div class="progress" style="height: 1ex;">
					<div class="determinate" style="width: <%= sprintf('%.2f', 100 * ($journey->{journey_completion} // 0)); %>%;"></div>
				</div>
			</p>
			% if ($journey->{arr_name}) {
				<p>
					<div style="float: left;">
						<b><%= $journey->{dep_name} %></b><br/>
						<b><%= $journey->{real_departure}->strftime('%H:%M') %></b>
						% if ($journey->{real_departure}->epoch != $journey->{sched_departure}->epoch) {
							(<%= sprintf('%+d', ($journey->{real_departure}->epoch - $journey->{sched_departure}->epoch)/60) %>)
						% }
					</div>
					<div style="float: right; text-align: right;">
						<b><%= $journey->{arr_name} %></b><br/>
						% if ($journey->{real_arrival}->epoch) {
							<b><%= $journey->{real_arrival}->strftime('%H:%M') %></b>
							% if ($journey->{real_arrival}->epoch != $journey->{sched_arrival}->epoch) {
								(<%= sprintf('%+d', ($journey->{real_arrival}->epoch - $journey->{sched_arrival}->epoch)/60) %>)
							% }
						% }
						% else {
							noch nicht bekannt
						% }
					</div>
					<div class="center-align hide-on-small-only next-stop">
						% for my $station (@{$journey->{route_after}}) {
							% if ($station->[0] eq $journey->{arr_name}) {
								% last;
							% }
							% if (($station->[1]{rt_arr_countdown} // 0) > 0) {
								<%= $station->[0] %><br/><%= $station->[1]{rt_arr}->strftime('%H:%M') %>
								% if ($station->[1]{sched_arr}->epoch != $station->[1]{rt_arr}->epoch) {
									%= sprintf('(%+d)', ($station->[1]{rt_arr}->epoch - $station->[1]{sched_arr}->epoch ) / 60);
								% }
								% last;
							% }
							% if (($station->[1]{rt_dep_countdown} // 0) > 0) {
								<%= $station->[0] %><br/>
								<%= $station->[1]{rt_arr}->strftime('%H:%M') %> →
								<%= $station->[1]{rt_dep}->strftime('%H:%M') %>
								% if ($station->[1]{sched_dep}->epoch != $station->[1]{rt_dep}->epoch) {
									%= sprintf('(%+d)', ($station->[1]{rt_dep}->epoch - $station->[1]{sched_dep}->epoch ) / 60);
								% }
								% last;
							% }
						% }
					</div>
					<div style="clear: both;">
					</div>
					<div class="hide-on-med-and-up next-stop" style="margin-top: 2ex;">
						% for my $station (@{$journey->{route_after}}) {
							% if ($station->[0] eq $journey->{arr_name}) {
								% last;
							% }
							% if (($station->[1]{rt_arr_countdown} // 0) > 0) {
								<%= $station->[0] %><br/><%= $station->[1]{rt_arr}->strftime('%H:%M') %>
								% if ($station->[1]{sched_arr}->epoch != $station->[1]{rt_arr}->epoch) {
									%= sprintf('(%+d)', ($station->[1]{rt_arr}->epoch - $station->[1]{sched_arr}->epoch ) / 60);
								% }
								% last;
							% }
							% if (($station->[1]{rt_dep_countdown} // 0) > 0) {
								<%= $station->[0] %><br/>
								<%= $station->[1]{rt_arr}->strftime('%H:%M') %> →
								<%= $station->[1]{rt_dep}->strftime('%H:%M') %>
								% if ($station->[1]{sched_dep}->epoch != $station->[1]{rt_dep}->epoch) {
									%= sprintf('(%+d)', ($station->[1]{rt_dep}->epoch - $station->[1]{sched_dep}->epoch ) / 60);
								% }
								% last;
							% }
						% }
					</div>
				</p>
			% }
			% if (@{$journey->{messages} // []} or @{$journey->{extra_data}{him_msg} // []} or @{$journey->{extra_data}{qos_msg} // []}) {
				<p style="margin-bottom: 2ex;">
					<ul>
						% for my $message (reverse @{$journey->{messages} // []}) {
							% if ($journey->{sched_departure}->epoch - $message->[0]->epoch < 1800) {
								<li> <i class="material-icons tiny">warning</i> <%= $message->[0]->strftime('%H:%M') %>: <%= $message->[1] %></li>
							% }
						% }
						% if ($journey->{departure_countdown} > 0) {
							% for my $message (@{$journey->{extra_data}{qos_msg} // []}) {
								<li> <i class="material-icons tiny">info</i> <%= $message->[0]->strftime('%H:%M') %>: <%= $message->[1] %></li>
							% }
						% }
						% for my $message (@{$journey->{extra_data}{him_msg} // []}) {
							<li> <i class="material-icons tiny">info</i> <%= $message->{header} %> <%= $message->{lead} %></li>
						% }
					</ul>
				</p>
			% }
			% if (defined $journey->{arrival_countdown} and $journey->{arrival_countdown} < (20*60)) {
				% if (my @connections = get_connecting_trains()) {
					<span class="card-title" style="margin-top: 2ex;">Verbindungen</span>
					% if ($journey->{arrival_countdown} < 0) {
						<p>Zug auswählen zum Einchecken mit Zielwahl.</p>
					% }
					%= include '_connections', connections => \@connections, checkin_from => $journey->{arrival_countdown} < 0 ? $journey->{arr_ds100} : undef;
				% }
			% }
			% if (defined $journey->{arrival_countdown} and $journey->{arrival_countdown} <= 0) {
				<p style="margin-top: 2ex;">
					Der automatische Checkout erfolgt wegen gelegentlich veralteter
					IRIS-Daten erst etwa zehn Minuten nach der Ankunft.
				</p>
			% }
			% elsif (not $journey->{arr_name}) {
				<p>Ziel wählen:</p>
				<table>
					<tbody>
						% for my $station (@{$journey->{route_after}}) {
							<tr><td><a class="action-checkout" data-station="<%= $station->[0] %>"><%= $station->[0] %>
								% if ($station->[2] and $station->[2] eq 'cancelled') {
									<span style="float: right;">entfällt</span>
								% }
								% elsif ($station->[1]{rt_arr}) {
									<span style="float: right;"><%= $station->[1]{rt_arr}->strftime('%H:%M') %></span>
								% }
								% elsif ($station->[2] and $station->[2] eq 'additional') {
									<span style="float: right;">Zusatzhalt</span>
								% }
							</a></td></tr>
						% }
					</tbody>
				</table>
			% }
		</div>
		<div class="card-action">
			% if ($journey->{arr_name}) {
				<a style="margin-right: 0;" href="/journey/comment">
					<i class="material-icons left">comment</i> Kommentar
				</a>
			% }
			% else {
				<a class="action-undo blue-text" data-id="in_transit" style="margin-right: 0;">
					<i class="material-icons left">undo</i> Checkin Rückgängig
				</a>
			% }
			% if (defined $journey->{arrival_countdown} and $journey->{arrival_countdown} <= 0) {
				<a
					class="action-checkout right"
					style="margin-right: 0;"
					data-station="<%= $journey->{arr_name}%>">
						<i class="material-icons left">done</i>
						Jetzt auschecken
					</a>
			% }
			% elsif ($journey->{arr_name}) {
				% my $attrib = 'im';
				% if ($journey->{train_type} =~ m{ ^ (?: S | RB ) $ }x) {
					% $attrib = 'in der';
				% }
				<a class="action-share blue-text right"
					style="margin-right: 0;"
					data-text="Ich bin gerade <%= $attrib %> <%= $journey->{train_type} %> <%= $journey->{train_no} %> nach <%= $journey->{arr_name} %> #NowTräwelling #dbl"
					% if (current_user()->{is_public} & 0x02) {
						data-url="<%= url_for('/status')->to_abs->scheme('https') %>/<%= current_user->{name} %>/<%= $journey->{sched_departure}->epoch %>"
					% }
					>
					<i class="material-icons left">share</i> Teilen
				</a>
			% }
		</div>
	</div>
	% if ($journey->{arr_name}) {
		<div class="card" style="margin-top: 3em;">
			<div class="card-content">
				<i class="material-icons small right sync-failed-marker grey-text" style="display: none;">sync_problem</i>
				<span class="card-title">Ziel ändern?</span>
				<table>
					<tbody>
						% for my $station (@{$journey->{route_after}}) {
							% my $is_dest = ($journey->{arr_name} and $station->[0] eq $journey->{arr_name});
							<tr><td><a style="<%= $is_dest? 'font-weight: bold;' : '' %>" class="action-checkout" data-station="<%= $station->[0] %>"><%= $station->[0] %>
								% if ($station->[2] and $station->[2] eq 'cancelled') {
									<span style="float: right;">entfällt</span>
								% }
								% elsif ($station->[1]{rt_arr}) {
									<span style="float: right;"><%= $station->[1]{rt_arr}->strftime('%H:%M') %></span>
								% }
								% elsif ($station->[2] and $station->[2] eq 'additional') {
									<span style="float: right;">Zusatzhalt</span>
								% }
							</a></td></tr>
						% }
					</tbody>
				</table>
				<p>
					Falls das Backend ausgefallen ist oder der Zug aus anderen
					Gründen verloren ging: <a class="action-checkout"
					data-force="1" data-station="<%= $journey->{arr_name}
					%>">Ohne Echtzeitdaten in <%= $journey->{arr_name} %>
					auschecken</a>.
				</p>
			</div>
			<div class="card-action">
				<a class="action-undo blue-text" data-id="in_transit" style="margin-right: 0;">
					<i class="material-icons left">undo</i> Checkin Rückgängig
				</a>
			</div>
		</div>
	% }
</div>