From 7789f8202f60f69ce015b1bc34eb0c076d7545b5 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 24 May 2020 18:38:08 +0200 Subject: animate train position in map --- templates/_error.html.ep | 5 ++++ templates/_map_infobox.html.ep | 61 ++++++++++++++++++++++++++++++++++++++++++ templates/layouts/app.html.ep | 1 + templates/route_map.html.ep | 59 ++-------------------------------------- 4 files changed, 69 insertions(+), 57 deletions(-) create mode 100644 templates/_error.html.ep create mode 100644 templates/_map_infobox.html.ep (limited to 'templates') diff --git a/templates/_error.html.ep b/templates/_error.html.ep new file mode 100644 index 0000000..4abfb4e --- /dev/null +++ b/templates/_error.html.ep @@ -0,0 +1,5 @@ +
Fehler: +
+%= $error
+
+
diff --git a/templates/_map_infobox.html.ep b/templates/_map_infobox.html.ep new file mode 100644 index 0000000..8f66a6f --- /dev/null +++ b/templates/_map_infobox.html.ep @@ -0,0 +1,61 @@ +
+
+ Fahrt + % if (stash('train_no')) { + <%= stash('train_no') %> + % } + von <%= stash('origin')->{name} %> + nach <%= stash('destination')->{name} %> +
+% if (my $next = stash('next_stop')) { +
+ % if ($next->{type} eq 'present' and $next->{station}{dep} and $next->{station}{arr}) { + Aufenthalt in <%= $next->{station}{name} %> + an Gleis <%= $next->{station}{platform} %> + bis <%= $next->{station}{dep}->strftime('%H:%M') %> + % if ($next->{station}{dep_delay}) { + %= sprintf('(%+d)', $next->{station}{dep_delay}) + % } + % } + % elsif ($next->{type} eq 'present' and $next->{station}{dep}) { + Abfahrt in <%= $next->{station}{name} %> + von Gleis <%= $next->{station}{platform} %> + um <%= $next->{station}{dep}->strftime('%H:%M') %> + % if ($next->{station}{dep_delay}) { + %= sprintf('(%+d)', $next->{station}{dep_delay}) + % } + % } + % elsif ($next->{type} eq 'present' and $next->{station}{arr}) { + Endstation erreicht um + <%= $next->{station}{arr}->strftime('%H:%M') %> + auf Gleis <%= $next->{station}{platform} %> + % if ($next->{station}{arr_delay}) { + %= sprintf('(%+d)', $next->{station}{arr_delay}) + % } + % } + % elsif ($next->{type} eq 'present') { + Zug steht in + <%= $next->{station}{arr}->strftime('%H:%M') %> + auf Gleis <%= $next->{station}{platform} %> + % } + % elsif ($next->{type} eq 'next' and $next->{station}{arr}) { + Nächster Halt: + <%= $next->{station}{name} %> + um <%= $next->{station}{arr}->strftime('%H:%M') %> + % if ($next->{station}{arr_delay}) { + %= sprintf('(%+d)', $next->{station}{arr_delay}) + % } + auf Gleis <%= $next->{station}{platform} %> + % } + % elsif ($next->{type} eq 'next') { + Nächster Halt: + <%= $next->{station}{name} %> + auf Gleis <%= $next->{station}{platform} %> + % } +
+% } +
diff --git a/templates/layouts/app.html.ep b/templates/layouts/app.html.ep index d7320de..fc81ba3 100644 --- a/templates/layouts/app.html.ep +++ b/templates/layouts/app.html.ep @@ -61,6 +61,7 @@ % if (stash('with_map')) { %= stylesheet "/static/${av}/leaflet/leaflet.css" %= javascript "/static/${av}/leaflet/leaflet.js" + %= javascript "/static/${av}/js/map-refresh.min.js", defer => undef % } diff --git a/templates/route_map.html.ep b/templates/route_map.html.ep index 6ed1b57..6f5643b 100644 --- a/templates/route_map.html.ep +++ b/templates/route_map.html.ep @@ -1,58 +1,5 @@ % if ($origin and $destination) { -
- Fahrt - % if (stash('train_no')) { - <%= stash('train_no') %> - % } - von <%= $origin->{name} %> - nach <%= $destination->{name} %> - % if (my $next = stash('next_stop')) { -
- % if ($next->{type} eq 'present' and $next->{station}{dep} and $next->{station}{arr}) { - Aufenthalt in <%= $next->{station}{name} %> - an Gleis <%= $next->{station}{platform} %> - bis <%= $next->{station}{dep}->strftime('%H:%M') %> - % if ($next->{station}{dep_delay}) { - %= sprintf('(%+d)', $next->{station}{dep_delay}) - % } - % } - % elsif ($next->{type} eq 'present' and $next->{station}{dep}) { - Abfahrt in <%= $next->{station}{name} %> - von Gleis <%= $next->{station}{platform} %> - um <%= $next->{station}{dep}->strftime('%H:%M') %> - % if ($next->{station}{dep_delay}) { - %= sprintf('(%+d)', $next->{station}{dep_delay}) - % } - % } - % elsif ($next->{type} eq 'present' and $next->{station}{arr}) { - Endstation erreicht um - <%= $next->{station}{arr}->strftime('%H:%M') %> - auf Gleis <%= $next->{station}{platform} %> - % if ($next->{station}{arr_delay}) { - %= sprintf('(%+d)', $next->{station}{arr_delay}) - % } - % } - % elsif ($next->{type} eq 'present') { - Zug steht in - <%= $next->{station}{arr}->strftime('%H:%M') %> - auf Gleis <%= $next->{station}{platform} %> - % } - % elsif ($next->{type} eq 'next' and $next->{station}{arr}) { - Nächster Halt: - <%= $next->{station}{name} %> - um <%= $next->{station}{arr}->strftime('%H:%M') %> - % if ($next->{station}{arr_delay}) { - %= sprintf('(%+d)', $next->{station}{arr_delay}) - % } - auf Gleis <%= $next->{station}{platform} %> - % } - % elsif ($next->{type} eq 'next') { - Nächster Halt: - <%= $next->{station}{name} %> - auf Gleis <%= $next->{station}{platform} %> - % } - % } -
+ %= include '_map_infobox' % }
@@ -135,9 +82,7 @@ var marker; Die eingezeichnete Route stammt aus dem HAFAS und ist im Detail oft fehlerbehaftet.
Die Zugposition auf der Karte ist eine DBF-eigene Schätzung und kann erheblich -von der tatsächlichen Position des Zugs abweichen.
-Live-Tracking mit automatischer Kartenaktualisierung wird noch nicht -unterstützt. +von den tatsächlichen Gegebenheiten abweichen.
% if (my $op = stash('operator')) { -- cgit v1.2.3