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