Add bus & ferry to public ldb
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
{link.toUpperCase()}
|
||||
</a>
|
||||
{:else if link.length === 4}
|
||||
<a class="link" href="/result-timetable?headcode={link}">
|
||||
<a class="link" href="/train?headcode={link}">
|
||||
{link.toUpperCase()}
|
||||
</a>
|
||||
{/if}
|
||||
|
||||
@@ -18,4 +18,10 @@
|
||||
<p>{line}</p>
|
||||
{/each}
|
||||
|
||||
</Island>
|
||||
</Island>
|
||||
|
||||
<style>
|
||||
p {
|
||||
color: white;
|
||||
}
|
||||
</style>
|
||||
@@ -1,5 +1,6 @@
|
||||
<script>
|
||||
export let station = "";
|
||||
export let title = "Loading...";
|
||||
import { onMount } from 'svelte'
|
||||
import Loading from '$lib/navigation/loading.svelte';
|
||||
|
||||
@@ -8,24 +9,40 @@
|
||||
|
||||
let jsonData = null;
|
||||
let services = [];
|
||||
let busServices = [];
|
||||
let ferryServices = [];
|
||||
let dataAge = null;
|
||||
let isLoading = true;
|
||||
|
||||
$: {
|
||||
if (jsonData === null && requestedStation) {
|
||||
fetchData();
|
||||
}
|
||||
if (jsonData === null && requestedStation) {
|
||||
fetchData();
|
||||
}
|
||||
|
||||
if (jsonData?.GetStationBoardResult?.generatedAt) {
|
||||
dataAge = new Date(jsonData.GetStationBoardResult.generatedAt);
|
||||
}
|
||||
|
||||
if (jsonData?.GetStationBoardResult?.trainServices?.service) {
|
||||
services = jsonData.GetStationBoardResult.trainServices.service;
|
||||
} else {
|
||||
services = [];
|
||||
}
|
||||
|
||||
if (jsonData && jsonData.GetStationBoardResult && jsonData.GetStationBoardResult.generatedAt) {
|
||||
dataAge = new Date(jsonData.GetStationBoardResult.generatedAt);
|
||||
}
|
||||
if (jsonData?.GetStationBoardResult?.busServices?.service) {
|
||||
busServices = jsonData.GetStationBoardResult.busServices.service;
|
||||
}
|
||||
|
||||
if (jsonData && jsonData.GetStationBoardResult && jsonData.GetStationBoardResult.trainServices && jsonData.GetStationBoardResult.trainServices.service) {
|
||||
services = jsonData.GetStationBoardResult.trainServices.service;
|
||||
} else {
|
||||
services = [];
|
||||
if (jsonData?.GetStationBoardResult?.ferryServices?.service) {
|
||||
ferryServices = jsonData.GetStationBoardResult.ferryServices.service;
|
||||
}
|
||||
|
||||
if (jsonData?.GetStationBoardResult?.locationName) {
|
||||
title = jsonData.GetStationBoardResult.locationName
|
||||
} else {
|
||||
title = "Loading Board"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchData() {
|
||||
isLoading = true; // Set loading state
|
||||
@@ -90,48 +107,119 @@
|
||||
<Loading />
|
||||
{:else}
|
||||
<p id="timestamp">Updated: {dataAge.toLocaleTimeString()}</p>
|
||||
<p>Public LDB for {station}</p>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th class="from">From</th>
|
||||
<th class="to">To</th>
|
||||
<th class="plat">Plat.</th>
|
||||
<th class="time">Sch Arr.</th>
|
||||
<th class="time">Exp Arr.</th>
|
||||
<th class="time">Sch Dep.</th>
|
||||
<th class="time">Exp Dep.</th>
|
||||
</tr>
|
||||
{#each services as service}
|
||||
{#if services.length}
|
||||
<table>
|
||||
<tr>
|
||||
<td class="origdest from">{service.origin?.location?.locationName || ''}</td>
|
||||
<td class="origdest to">{service.destination?.location?.locationName || ''}</td>
|
||||
<td class="plat">{service.platform || '-'}</td>
|
||||
<td class="time">{parseTime(service.sta).data}</td>
|
||||
<td class="time {parseTime(service.eta).changed}">{parseTime(service.eta).data}</td>
|
||||
<td class="time">{parseTime(service.std).data}</td>
|
||||
<td class="time {parseTime(service.etd).changed}">{parseTime(service.etd).data}</td>
|
||||
<th class="from">From</th>
|
||||
<th class="to">To</th>
|
||||
<th class="plat">Plat.</th>
|
||||
<th class="time">Sch Arr.</th>
|
||||
<th class="time">Exp Arr.</th>
|
||||
<th class="time">Sch Dep.</th>
|
||||
<th class="time">Exp Dep.</th>
|
||||
</tr>
|
||||
<!-- service-detail elements are currently contained within the 'From' column
|
||||
It should be underneath the row. I will need to look at the vanilla interface
|
||||
to establish what I did differently there. Or, I can insert a new row
|
||||
with colspan="7" to add a row spanning all columns.-->
|
||||
<tr><td colspan="7">
|
||||
<p class="service-detail">
|
||||
A {service.operator || 'Unknown'} service
|
||||
{#if service['length']}
|
||||
with {service['length'] || 'some'} coaches
|
||||
{#each services as service}
|
||||
<tr>
|
||||
<td class="origdest from">{service.origin?.location?.locationName || ''}</td>
|
||||
<td class="origdest to">{service.destination?.location?.locationName || ''}</td>
|
||||
<td class="plat">{service.platform || '-'}</td>
|
||||
<td class="time">{parseTime(service.sta).data}</td>
|
||||
<td class="time {parseTime(service.eta).changed}">{parseTime(service.eta).data}</td>
|
||||
<td class="time">{parseTime(service.std).data}</td>
|
||||
<td class="time {parseTime(service.etd).changed}">{parseTime(service.etd).data}</td>
|
||||
</tr>
|
||||
|
||||
<tr><td colspan="7">
|
||||
<p class="service-detail">
|
||||
A {service.operator || 'Unknown'} service
|
||||
{#if service['length']}
|
||||
with {service['length'] || 'some'} coaches
|
||||
{/if}
|
||||
</p>
|
||||
{#if service.delayReason}
|
||||
<p class="service-detail">{service.delayReason}</p>
|
||||
{/if}
|
||||
</p>
|
||||
{#if service.delayReason}
|
||||
<p class="service-detail">{service.delayReason}</p>
|
||||
{/if}
|
||||
{#if service.cancelReason}
|
||||
<p class="service-detail">{service.cancelReason}</p>
|
||||
{/if}
|
||||
</td></tr>
|
||||
{/each}
|
||||
</table>
|
||||
{#if service.cancelReason}
|
||||
<p class="service-detail">{service.cancelReason}</p>
|
||||
{/if}
|
||||
</td></tr>
|
||||
{/each}
|
||||
</table>
|
||||
{:else}
|
||||
<p>No Scheduled Train Services</p>
|
||||
{/if}
|
||||
{#if busServices.length}
|
||||
<table>
|
||||
<tr>
|
||||
<th class="from">From</th>
|
||||
<th class="to">To</th>
|
||||
<th class="time">Sch Arr.</th>
|
||||
<th class="time">Exp Arr.</th>
|
||||
<th class="time">Sch Dep.</th>
|
||||
<th class="time">Exp Dep.</th>
|
||||
</tr>
|
||||
{#each busServices as service}
|
||||
<tr>
|
||||
<td class="origdest from">{service.origin?.location?.locationName || ''}</td>
|
||||
<td class="origdest to">{service.destination?.location?.locationName || ''}</td>
|
||||
<td class="time">{parseTime(service.sta).data}</td>
|
||||
<td class="time {parseTime(service.eta).changed}">{parseTime(service.eta).data}</td>
|
||||
<td class="time">{parseTime(service.std).data}</td>
|
||||
<td class="time {parseTime(service.etd).changed}">{parseTime(service.etd).data}</td>
|
||||
</tr>
|
||||
|
||||
<tr><td colspan="7">
|
||||
<p class="service-detail">
|
||||
A {service.operator || 'Unknown'} service
|
||||
</p>
|
||||
{#if service.delayReason}
|
||||
<p class="service-detail">{service.delayReason}</p>
|
||||
{/if}
|
||||
{#if service.cancelReason}
|
||||
<p class="service-detail">{service.cancelReason}</p>
|
||||
{/if}
|
||||
</td></tr>
|
||||
{/each}
|
||||
</table>
|
||||
{:else}
|
||||
<p>No Scheduled Bus Services</p>
|
||||
{/if}
|
||||
{#if ferryServices.length}
|
||||
<table>
|
||||
<tr>
|
||||
<th class="from">From</th>
|
||||
<th class="to">To</th>
|
||||
<th class="time">Sch Arr.</th>
|
||||
<th class="time">Exp Arr.</th>
|
||||
<th class="time">Sch Dep.</th>
|
||||
<th class="time">Exp Dep.</th>
|
||||
</tr>
|
||||
{#each ferryServices as service}
|
||||
<tr>
|
||||
<td class="origdest from">{service.origin?.location?.locationName || ''}</td>
|
||||
<td class="origdest to">{service.destination?.location?.locationName || ''}</td>
|
||||
<td class="time">{parseTime(service.sta).data}</td>
|
||||
<td class="time {parseTime(service.eta).changed}">{parseTime(service.eta).data}</td>
|
||||
<td class="time">{parseTime(service.std).data}</td>
|
||||
<td class="time {parseTime(service.etd).changed}">{parseTime(service.etd).data}</td>
|
||||
</tr>
|
||||
|
||||
<tr><td colspan="7">
|
||||
<p class="service-detail">
|
||||
A {service.operator || 'Unknown'} service
|
||||
</p>
|
||||
{#if service.delayReason}
|
||||
<p class="service-detail">{service.delayReason}</p>
|
||||
{/if}
|
||||
{#if service.cancelReason}
|
||||
<p class="service-detail">{service.cancelReason}</p>
|
||||
{/if}
|
||||
</td></tr>
|
||||
{/each}
|
||||
</table>
|
||||
{:else}
|
||||
<p>No Scheduled Ferry Serices</p>
|
||||
{/if}
|
||||
{/if}
|
||||
<style>
|
||||
#timestamp {
|
||||
|
||||
Reference in New Issue
Block a user