Add Bus and Ferry services to public board

This commit is contained in:
Fred Boniface 2023-06-19 14:21:08 +01:00
parent 847545760b
commit 3c191c4793

View File

@ -1,5 +1,6 @@
<script> <script>
export let station = ""; export let station = "";
export let title = "";
import { onMount } from 'svelte' import { onMount } from 'svelte'
import Loading from '$lib/navigation/loading.svelte'; import Loading from '$lib/navigation/loading.svelte';
import Nav from '$lib/navigation/nav.svelte'; import Nav from '$lib/navigation/nav.svelte';
@ -7,7 +8,7 @@
let requestedStation; let requestedStation;
$: requestedStation = station; $: requestedStation = station;
let jsonData = null; let jsonData = {};
let services = []; let services = [];
let dataAge = null; let dataAge = null;
let isLoading = true; let isLoading = true;
@ -17,15 +18,21 @@
fetchData(); fetchData();
} }
if (jsonData && jsonData.GetStationBoardResult && jsonData.GetStationBoardResult.generatedAt) { if (jsonData?.GetStationBoardResult?.generatedAt) {
dataAge = new Date(jsonData.GetStationBoardResult.generatedAt); dataAge = new Date(jsonData.GetStationBoardResult.generatedAt);
} }
if (jsonData && jsonData.GetStationBoardResult && jsonData.GetStationBoardResult.trainServices && jsonData.GetStationBoardResult.trainServices.service) { if (jsonData?.GetStationBoardResult?.trainServices?.service) {
services = jsonData.GetStationBoardResult.trainServices.service; services = jsonData.GetStationBoardResult.trainServices.service;
} else { } else {
services = []; services = [];
} }
if (jsonData?.GetStationBoardResult?.locationName) {
title = jsonData.GetStationBoardResult.locationName
} else {
title = "Loading Board"
}
} }
async function fetchData() { async function fetchData() {
@ -41,7 +48,7 @@
} }
} }
function parseTime(string){ function parseTime(string = ""){
let output let output
let change let change
switch (string) { switch (string) {