165 lines
6.8 KiB
Plaintext
165 lines
6.8 KiB
Plaintext
@{
|
|
// ReSharper disable ConditionIsAlwaysTrueOrFalse
|
|
var title = (string) ViewData["title"];
|
|
var station = (string) ViewData["station"];
|
|
var stationId = (string) ViewData["stationId"];
|
|
var via = (string) ViewData["via"];
|
|
var andShowDestination = (string) ViewData["andShowDestination"];
|
|
var fernverkehrOnly = (bool) ViewData["fernverkehrOnly"];
|
|
var onlyDepartures = (bool) ViewData["onlyDepartures"];
|
|
var excludingVia = (string) ViewData["excludingVia"];
|
|
var offset = (int) ViewData["offset"];
|
|
IgnoreBody();
|
|
}
|
|
|
|
@using System.Globalization
|
|
@using System.Linq
|
|
@using ZTravel.API.DBF
|
|
@using ZTravel.Web
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
|
<title>Departures - ZTravel</title>
|
|
<meta http-equiv="refresh" content="30">
|
|
<link rel="stylesheet" href="~/css/fernv.css"/>
|
|
</head>
|
|
<body>
|
|
<div class="navbar-fixed">
|
|
<nav style="color: #ffffff; background-color: #00838f;">
|
|
<div class="nav-wrapper container">
|
|
<span class="brand-logo">@title</span>
|
|
</div>
|
|
</nav>
|
|
</div>
|
|
<div class="app applight">
|
|
<ul>
|
|
@foreach (var dep in DbfApi.GetDepartures("dbf.finalrewind.org", station, via)) {
|
|
if (fernverkehrOnly && !dep.TrainClasses.Contains("F") && dep.Destination != andShowDestination) {
|
|
continue;
|
|
}
|
|
if (onlyDepartures && string.IsNullOrWhiteSpace(dep.ScheduledDeparture)) {
|
|
continue;
|
|
}
|
|
if (dep.Route.Select(r => r.Name).Contains(excludingVia)) {
|
|
continue;
|
|
}
|
|
var typeclass = "bahn";
|
|
if (dep.TrainClasses.Any()) {
|
|
typeclass = dep.TrainClasses.First() switch {
|
|
"S" => "sbahn",
|
|
"F" => "fern",
|
|
_ => "bahn"};
|
|
}
|
|
|
|
var trainclass = dep.Train.Split(" ")[0];
|
|
|
|
DateTime rawtime;
|
|
var delayed = false;
|
|
var undelayed = false;
|
|
var cancelled = dep.IsCancelled == 1;
|
|
var stringtime = "";
|
|
var stringdelay = "";
|
|
if (!string.IsNullOrWhiteSpace(dep.ScheduledDeparture)) {
|
|
rawtime = DateTime.ParseExact(dep.ScheduledDeparture, "HH:mm", CultureInfo.InvariantCulture);
|
|
if (dep.DelayDeparture != null) {
|
|
rawtime += new TimeSpan(0, (int) dep.DelayDeparture, 0);
|
|
if (dep.DelayDeparture > 0) {
|
|
delayed = true;
|
|
stringdelay = $"(+{dep.DelayDeparture})";
|
|
}
|
|
else if (dep.DelayDeparture < 0) {
|
|
undelayed = true;
|
|
stringdelay = $"({dep.DelayDeparture})";
|
|
}
|
|
}
|
|
stringtime = $"{rawtime:HH:mm}";
|
|
}
|
|
else {
|
|
rawtime = DateTime.ParseExact(dep.ScheduledArrival, "HH:mm", CultureInfo.InvariantCulture);
|
|
if (dep.DelayArrival != null) {
|
|
rawtime += new TimeSpan(0, (int) dep.DelayArrival, 0);
|
|
if (dep.DelayArrival > 0) {
|
|
delayed = true;
|
|
stringdelay = $"(+{dep.DelayArrival})";
|
|
}
|
|
else if (dep.DelayArrival < 0) {
|
|
undelayed = true;
|
|
stringdelay = $"({dep.DelayArrival})";
|
|
}
|
|
}
|
|
stringtime = $"(arr) {rawtime:HH:mm}";
|
|
dep.Destination += $" (from {dep.Route.First().Name})";
|
|
}
|
|
|
|
if ((rawtime - DateTime.Now).TotalMinutes < 0) {
|
|
rawtime += new TimeSpan(1, 0, 0, 0);
|
|
}
|
|
if ((rawtime - DateTime.Now).TotalMinutes < offset) {
|
|
continue;
|
|
}
|
|
|
|
<li class="@(cancelled ? " cancelled" : "")" onclick="openInNewTab('https://marudor.de/details/@trainclass @dep.TrainNumber?station=@stationId')">
|
|
<div class="line @typeclass">
|
|
@if (trainclass == "S") {
|
|
@dep.Train
|
|
}
|
|
else {
|
|
@trainclass
|
|
}
|
|
|
|
@if (trainclass == "IC" || trainclass == "ICE") {
|
|
if (Program.TypeMapping.ContainsKey(dep.TrainNumber)) {
|
|
if (!string.IsNullOrWhiteSpace(Program.TypeMapping[dep.TrainNumber].Short)) {
|
|
<span class="trainsubtype">@Program.TypeMapping[dep.TrainNumber].Short</span>
|
|
}
|
|
}
|
|
}
|
|
<span class="trainno">@dep.TrainNumber</span>
|
|
</div>
|
|
@if (dep.Messages.Delay.Any()) {
|
|
if (dep.Messages.Qos.Any()) {
|
|
<span class="info">@(cancelled ? "Fahrt fällt aus: " : "")@dep.Messages.Delay.Select(p => p.Text).Aggregate((s, s1) => $"{s}, {s1}") +++ @dep.Messages.Qos.Select(p => p.Text).Aggregate((s, s1) => $"{s} +++ {s1}")</span>
|
|
}
|
|
else {
|
|
<span class="info">@(cancelled ? "Fahrt fällt aus: " : "")@dep.Messages.Delay.Select(p => p.Text).Aggregate((s, s1) => $"{s}, {s1}")</span>
|
|
}
|
|
}
|
|
else if (dep.Messages.Qos.Any()) {
|
|
<span class="info">@(cancelled ? "Fahrt fällt aus: " : "")@dep.Messages.Qos.Select(p => p.Text).Aggregate((s, s1) => $"{s} +++ {s1}")</span>
|
|
}
|
|
else {
|
|
<span class="route">@(dep.Via.Any() ? dep.Via.Aggregate((s, s1) => $"{s} - {s1}") : "")</span>
|
|
}
|
|
<span class="dest @(cancelled ? " cancelled" : "")">@dep.Destination</span>
|
|
<span class="countdown @(cancelled ? " cancelled" : "")">
|
|
@if (delayed) {
|
|
<span class="delaynorm">@stringdelay</span>
|
|
}
|
|
else if (undelayed) {
|
|
<span class="undelaynorm">@stringdelay</span>
|
|
}
|
|
<span class="@(dep.Platform != dep.ScheduledPlatform && !string.IsNullOrWhiteSpace(dep.ScheduledPlatform) ? "platform changed-platform" : "platform")">@dep.Platform</span>
|
|
</span>
|
|
@if (delayed) {
|
|
<span class="time delayed">@stringtime</span>
|
|
}
|
|
else if (undelayed) {
|
|
<span class="time undelayed">@stringtime</span>
|
|
}
|
|
else {
|
|
<span class="time">@stringtime</span>
|
|
}
|
|
</li>
|
|
}
|
|
</ul>
|
|
</div>
|
|
<script>
|
|
function openInNewTab(url) {
|
|
var win = window.open(url, '_blank');
|
|
win.focus();
|
|
}
|
|
</script>
|
|
</body>
|
|
</html> |