diff --git a/src/lib/ldb/public-ldb.svelte b/src/lib/ldb/public-ldb.svelte
index b6e9677..6f0a7cf 100644
--- a/src/lib/ldb/public-ldb.svelte
+++ b/src/lib/ldb/public-ldb.svelte
@@ -13,6 +13,7 @@
let ferryServices = [];
let dataAge = null;
let isLoading = true;
+ let dataExists = false;
$: {
if (jsonData === null && requestedStation) {
@@ -40,11 +41,12 @@
if (jsonData?.GetStationBoardResult?.locationName) {
title = jsonData.GetStationBoardResult.locationName
} else {
- title = "Loading Board"
+ title = requestedStation.toUpperCase()
}
}
async function fetchData() {
+ dataExists = true;
isLoading = true; // Set loading state
try {
console.log(`Requested Station: ${requestedStation}`);
@@ -52,6 +54,8 @@
jsonData = await data.json();
} catch (error) {
console.error("Error fetching data:", error);
+ dataExists = false;
+ title = "Not Found";
} finally {
isLoading = false; // Clear loading state
}
@@ -106,118 +110,122 @@
{#if isLoading}
Updated: {dataAge.toLocaleTimeString()}
- {#if services.length} -From | -To | -Plat. | -Sch Arr. | -Exp Arr. | -Sch Dep. | -Exp Dep. | -
---|
{service.origin?.location?.locationName || ''} | -{service.destination?.location?.locationName || ''} | -{service.platform || '-'} | -{parseTime(service.sta).data} | -{parseTime(service.eta).data} | -{parseTime(service.std).data} | -{parseTime(service.etd).data} | +From | +To | +Plat. | +Sch Arr. | +Exp Arr. | +Sch Dep. | +Exp Dep. |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
{service.origin?.location?.locationName || ''} | +{service.destination?.location?.locationName || ''} | +{service.platform || '-'} | +{parseTime(service.sta).data} | +{parseTime(service.eta).data} | +{parseTime(service.std).data} | +{parseTime(service.etd).data} | +|||||||
- - A {service.operator || 'Unknown'} service - {#if service['length']} - with {service['length'] || 'some'} coaches + | |||||||||||||
+ + A {service.operator || 'Unknown'} service + {#if service['length']} + with {service['length'] || 'some'} coaches + {/if} + + {#if service.delayReason} +{service.delayReason} {/if} - - {#if service.delayReason} -{service.delayReason} - {/if} - {#if service.cancelReason} -{service.cancelReason} - {/if} - |
{service.cancelReason}
+ {/if} + + {/each} +No Scheduled Train Services
+ {/if} + {#if busServices.length} +From | +To | +Sch Arr. | +Exp Arr. | +Sch Dep. | +Exp Dep. | +|
---|---|---|---|---|---|---|
{service.origin?.location?.locationName || ''} | +{service.destination?.location?.locationName || ''} | +{parseTime(service.sta).data} | +{parseTime(service.eta).data} | +{parseTime(service.std).data} | +{parseTime(service.etd).data} | +|
+ + A {service.operator || 'Unknown'} service + + {#if service.delayReason} +{service.delayReason} + {/if} + {#if service.cancelReason} +{service.cancelReason} + {/if} + |
From | +To | +Sch Arr. | +Exp Arr. | +Sch Dep. | +Exp Dep. | +|
---|---|---|---|---|---|---|
{service.origin?.location?.locationName || ''} | +{service.destination?.location?.locationName || ''} | +{parseTime(service.sta).data} | +{parseTime(service.eta).data} | +{parseTime(service.std).data} | +{parseTime(service.etd).data} | +|
+ {#if service.delayReason}
+ {service.delayReason} + {/if} + {#if service.cancelReason} +{service.cancelReason} + {/if} + |
No Scheduled Train Services
- {/if} - {#if busServices.length} -From | -To | -Sch Arr. | -Exp Arr. | -Sch Dep. | -Exp Dep. | -|
---|---|---|---|---|---|---|
{service.origin?.location?.locationName || ''} | -{service.destination?.location?.locationName || ''} | -{parseTime(service.sta).data} | -{parseTime(service.eta).data} | -{parseTime(service.std).data} | -{parseTime(service.etd).data} | -|
- - A {service.operator || 'Unknown'} service - - {#if service.delayReason} -{service.delayReason} - {/if} - {#if service.cancelReason} -{service.cancelReason} - {/if} - |
From | -To | -Sch Arr. | -Exp Arr. | -Sch Dep. | -Exp Dep. | -|
---|---|---|---|---|---|---|
{service.origin?.location?.locationName || ''} | -{service.destination?.location?.locationName || ''} | -{parseTime(service.sta).data} | -{parseTime(service.eta).data} | -{parseTime(service.std).data} | -{parseTime(service.etd).data} | -|
- {#if service.delayReason}
- {service.delayReason} - {/if} - {#if service.cancelReason} -{service.cancelReason} - {/if} - |
Unable to find this station
{/if} {/if} \ No newline at end of file diff --git a/src/routes/ldb/+page.svelte b/src/routes/ldb/+page.svelte index 36d9c9c..1bca81b 100644 --- a/src/routes/ldb/+page.svelte +++ b/src/routes/ldb/+page.svelte @@ -1,6 +1,6 @@