Reformat
This commit is contained in:
@@ -11,17 +11,7 @@
|
||||
}
|
||||
|
||||
function numberAsWord(number) {
|
||||
const words = [
|
||||
'zero',
|
||||
'one',
|
||||
'two',
|
||||
'three',
|
||||
'four',
|
||||
'five',
|
||||
'six',
|
||||
'seven',
|
||||
'eight'
|
||||
];
|
||||
const words = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight'];
|
||||
let word = words[number];
|
||||
if (word) {
|
||||
return word;
|
||||
@@ -45,11 +35,7 @@
|
||||
<p id="arrow" class:displayAlerts>V</p>
|
||||
</div>
|
||||
{#if displayAlerts}
|
||||
<div
|
||||
id="alerts"
|
||||
in:fly={{ y: -200, duration: 500 }}
|
||||
out:fly={{ y: -200, duration: 800 }}
|
||||
>
|
||||
<div id="alerts" in:fly={{ y: -200, duration: 500 }} out:fly={{ y: -200, duration: 800 }}>
|
||||
{#each uniqueAlerts as msg}
|
||||
<p class="alert">{@html msg}</p>
|
||||
{/each}
|
||||
|
||||
@@ -54,9 +54,7 @@
|
||||
isLoading = true; // Set loading state
|
||||
try {
|
||||
console.log(`Requested Station: ${requestedStation}`);
|
||||
const data = await fetch(
|
||||
`https://owlboard.info/api/v1/ldb/${requestedStation}`
|
||||
);
|
||||
const data = await fetch(`https://owlboard.info/api/v1/ldb/${requestedStation}`);
|
||||
jsonData = await data.json();
|
||||
} catch (error) {
|
||||
console.error('Error fetching data:', error);
|
||||
@@ -168,41 +166,25 @@
|
||||
</tr>
|
||||
{#each services as service}
|
||||
<tr>
|
||||
<td
|
||||
class="origdest from"
|
||||
on:click={loadService(service.serviceID)}
|
||||
on:keypress={loadService(service.serviceID)}
|
||||
>
|
||||
<td class="origdest from" on:click={loadService(service.serviceID)} on:keypress={loadService(service.serviceID)}>
|
||||
{#if Array.isArray(service.origin?.location)}
|
||||
{service.origin.location[0]['locationName'] +
|
||||
' & ' +
|
||||
service.origin.location[1]['locationName']}
|
||||
{service.origin.location[0]['locationName'] + ' & ' + service.origin.location[1]['locationName']}
|
||||
{:else}
|
||||
{service.origin?.location?.locationName || ''}
|
||||
{/if}
|
||||
</td>
|
||||
<td
|
||||
class="origdest to"
|
||||
on:click={loadService(service.serviceID)}
|
||||
on:keypress={loadService(service.serviceID)}
|
||||
>
|
||||
<td class="origdest to" on:click={loadService(service.serviceID)} on:keypress={loadService(service.serviceID)}>
|
||||
{#if Array.isArray(service.destination?.location)}
|
||||
{service.destination.location[0]['locationName'] +
|
||||
' & ' +
|
||||
service.destination.location[0]['locationName']}
|
||||
{service.destination.location[0]['locationName'] + ' & ' + service.destination.location[0]['locationName']}
|
||||
{:else}
|
||||
{service.destination?.location?.locationName || ''}
|
||||
{/if}
|
||||
</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.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
|
||||
>
|
||||
<td class="time {parseTime(service.etd).changed}">{parseTime(service.etd).data}</td>
|
||||
</tr>
|
||||
|
||||
<tr
|
||||
@@ -228,11 +210,7 @@
|
||||
{/if}
|
||||
{#if busServices.length}
|
||||
<br />
|
||||
<img
|
||||
class="transport-mode"
|
||||
src="/images/transport-modes/bus.svg"
|
||||
alt="Bus services"
|
||||
/><br />
|
||||
<img class="transport-mode" src="/images/transport-modes/bus.svg" alt="Bus services" /><br />
|
||||
<span class="table-head-text">Bus Services</span>
|
||||
<table class="ldbTable">
|
||||
<tr>
|
||||
@@ -245,26 +223,14 @@
|
||||
</tr>
|
||||
{#each busServices as service}
|
||||
<tr>
|
||||
<td
|
||||
class="origdest from"
|
||||
on:click={loadBusService(service.serviceID)}
|
||||
on:keypress={loadBusService(service.serviceID)}
|
||||
>{service.origin?.location?.locationName || ''}</td
|
||||
>
|
||||
<td
|
||||
class="origdest to"
|
||||
on:click={loadBusService(service.serviceID)}
|
||||
on:keypress={loadBusService(service.serviceID)}
|
||||
<td class="origdest from" on:click={loadBusService(service.serviceID)} on:keypress={loadBusService(service.serviceID)}>{service.origin?.location?.locationName || ''}</td>
|
||||
<td class="origdest to" on:click={loadBusService(service.serviceID)} on:keypress={loadBusService(service.serviceID)}
|
||||
>{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.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
|
||||
>
|
||||
<td class="time {parseTime(service.etd).changed}">{parseTime(service.etd).data}</td>
|
||||
</tr>
|
||||
|
||||
<tr
|
||||
@@ -285,11 +251,7 @@
|
||||
{/if}
|
||||
{#if ferryServices.length}
|
||||
<br />
|
||||
<img
|
||||
class="transport-mode"
|
||||
src="/images/transport-modes/ferry.svg"
|
||||
alt="Bus services"
|
||||
/><br />
|
||||
<img class="transport-mode" src="/images/transport-modes/ferry.svg" alt="Bus services" /><br />
|
||||
<span class="table-head-text">Ferry Services</span>
|
||||
<table class="ldbTable">
|
||||
<tr>
|
||||
@@ -302,20 +264,12 @@
|
||||
</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="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.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
|
||||
>
|
||||
<td class="time {parseTime(service.etd).changed}">{parseTime(service.etd).data}</td>
|
||||
</tr>
|
||||
|
||||
<tr
|
||||
@@ -352,35 +306,17 @@
|
||||
<tr>
|
||||
<td>{prevPoint.locationName}</td>
|
||||
<td>{prevPoint.st}</td>
|
||||
<td
|
||||
class="time {parseTime(prevPoint.at || prevPoint.et).changed}"
|
||||
>{parseTime(prevPoint.at || prevPoint.et).data}</td
|
||||
>
|
||||
<td class="time {parseTime(prevPoint.at || prevPoint.et).changed}">{parseTime(prevPoint.at || prevPoint.et).data}</td>
|
||||
</tr>
|
||||
{/each}
|
||||
{:else}
|
||||
<tr>
|
||||
<td>{serviceDetail.previousCallingPoints.callingPointList.callingPoint.locationName}</td>
|
||||
<td>{serviceDetail.previousCallingPoints.callingPointList.callingPoint.st}</td>
|
||||
<td
|
||||
>{serviceDetail.previousCallingPoints.callingPointList
|
||||
.callingPoint.locationName}</td
|
||||
>
|
||||
<td
|
||||
>{serviceDetail.previousCallingPoints.callingPointList
|
||||
.callingPoint.st}</td
|
||||
>
|
||||
<td
|
||||
class="time {parseTime(
|
||||
serviceDetail.previousCallingPoints.callingPointList
|
||||
.callingPoint.at ||
|
||||
serviceDetail.previousCallingPoints.callingPointList
|
||||
.callingPoint.et
|
||||
).changed}"
|
||||
>{parseTime(
|
||||
serviceDetail.previousCallingPoints.callingPointList
|
||||
.callingPoint.at ||
|
||||
serviceDetail.previousCallingPoints.callingPointList
|
||||
.callingPoint.et
|
||||
).data}</td
|
||||
class="time {parseTime(serviceDetail.previousCallingPoints.callingPointList.callingPoint.at || serviceDetail.previousCallingPoints.callingPointList.callingPoint.et)
|
||||
.changed}"
|
||||
>{parseTime(serviceDetail.previousCallingPoints.callingPointList.callingPoint.at || serviceDetail.previousCallingPoints.callingPointList.callingPoint.et).data}</td
|
||||
>
|
||||
</tr>
|
||||
{/if}
|
||||
@@ -388,11 +324,7 @@
|
||||
<tr class="thisStop">
|
||||
<td>{title}</td>
|
||||
<td>{serviceDetail.std || serviceDetail.sta}</td>
|
||||
<td
|
||||
class="time {parseTime(serviceDetail.etd || serviceDetail.eta)
|
||||
.changed}"
|
||||
>{parseTime(serviceDetail.etd || serviceDetail.eta).data}</td
|
||||
>
|
||||
<td class="time {parseTime(serviceDetail.etd || serviceDetail.eta).changed}">{parseTime(serviceDetail.etd || serviceDetail.eta).data}</td>
|
||||
</tr>
|
||||
{#if serviceDetail?.subsequentCallingPoints?.callingPointList?.callingPoint}
|
||||
{#if Array.isArray(serviceDetail?.subsequentCallingPoints?.callingPointList?.callingPoint)}
|
||||
@@ -400,30 +332,15 @@
|
||||
<tr>
|
||||
<td>{nextPoint.locationName}</td>
|
||||
<td>{nextPoint.st}</td>
|
||||
<td class="time {parseTime(nextPoint.et).changed}"
|
||||
>{parseTime(nextPoint.et).data}</td
|
||||
>
|
||||
<td class="time {parseTime(nextPoint.et).changed}">{parseTime(nextPoint.et).data}</td>
|
||||
</tr>
|
||||
{/each}
|
||||
{:else}
|
||||
<tr class="detailRow">
|
||||
<td
|
||||
>{serviceDetail.subsequentCallingPoints.callingPointList
|
||||
.callingPoint.locationName}</td
|
||||
>
|
||||
<td
|
||||
>{serviceDetail.subsequentCallingPoints.callingPointList
|
||||
.callingPoint.st}</td
|
||||
>
|
||||
<td
|
||||
class="time {parseTime(
|
||||
serviceDetail.subsequentCallingPoints.callingPointList
|
||||
.callingPoint.et
|
||||
).changed}"
|
||||
>{parseTime(
|
||||
serviceDetail.subsequentCallingPoints.callingPointList
|
||||
.callingPoint.et
|
||||
).data}</td
|
||||
<td>{serviceDetail.subsequentCallingPoints.callingPointList.callingPoint.locationName}</td>
|
||||
<td>{serviceDetail.subsequentCallingPoints.callingPointList.callingPoint.st}</td>
|
||||
<td class="time {parseTime(serviceDetail.subsequentCallingPoints.callingPointList.callingPoint.et).changed}"
|
||||
>{parseTime(serviceDetail.subsequentCallingPoints.callingPointList.callingPoint.et).data}</td
|
||||
>
|
||||
</tr>
|
||||
{/if}
|
||||
|
||||
@@ -209,9 +209,7 @@
|
||||
let processedMessages = [];
|
||||
for (const message of arrMessages) {
|
||||
const msgText = message.xhtmlMessage;
|
||||
processedMessages.push(
|
||||
msgText.replace(/[\n\r]/g, '').replace(/<\/?p[^>]*>/g, '')
|
||||
);
|
||||
processedMessages.push(msgText.replace(/[\n\r]/g, '').replace(/<\/?p[^>]*>/g, ''));
|
||||
}
|
||||
return processedMessages;
|
||||
}
|
||||
@@ -228,11 +226,7 @@
|
||||
<AlertBar {alerts} />
|
||||
{/if}
|
||||
<table>
|
||||
<tr
|
||||
><td colspan="8" id="timestamp"
|
||||
>Updated: {dataAge.toLocaleTimeString()} - Staff Boards under development</td
|
||||
></tr
|
||||
>
|
||||
<tr><td colspan="8" id="timestamp">Updated: {dataAge.toLocaleTimeString()} - Staff Boards under development</td></tr>
|
||||
<tr>
|
||||
<th class="id">ID</th>
|
||||
<th class="from">From</th>
|
||||
@@ -254,36 +248,15 @@
|
||||
where 'length' is not provided but 'formation' is. -->
|
||||
<tr>
|
||||
<td class="id id-data data">{service.trainid}</td>
|
||||
<td
|
||||
class="from from-data data {serviceStats.isCancelled && 'can-dat'}"
|
||||
>{serviceStats.from}</td
|
||||
>
|
||||
<td class="to to-data data {serviceStats.isCancelled && 'can-dat'}"
|
||||
>{serviceStats.to}</td
|
||||
>
|
||||
<td
|
||||
class="plat plat-data data {serviceStats.isCancelled &&
|
||||
'can-dat'} {serviceStats.platformHidden && 'hidden'}"
|
||||
>{serviceStats.platform.number || '-'}</td
|
||||
>
|
||||
<td
|
||||
class="time time-data data {serviceStats.isCancelled && 'can-dat'}"
|
||||
>{serviceStats.schArr}</td
|
||||
>
|
||||
<td
|
||||
class="time time-data data {serviceStats.isArrDelayed &&
|
||||
'late'} {serviceStats.isEarlyArr &&
|
||||
'early'} {serviceStats.isLateArr && 'late'}"
|
||||
<td class="from from-data data {serviceStats.isCancelled && 'can-dat'}">{serviceStats.from}</td>
|
||||
<td class="to to-data data {serviceStats.isCancelled && 'can-dat'}">{serviceStats.to}</td>
|
||||
<td class="plat plat-data data {serviceStats.isCancelled && 'can-dat'} {serviceStats.platformHidden && 'hidden'}">{serviceStats.platform.number || '-'}</td>
|
||||
<td class="time time-data data {serviceStats.isCancelled && 'can-dat'}">{serviceStats.schArr}</td>
|
||||
<td class="time time-data data {serviceStats.isArrDelayed && 'late'} {serviceStats.isEarlyArr && 'early'} {serviceStats.isLateArr && 'late'}"
|
||||
>{serviceStats.isArrDelayed ? 'LATE' : serviceStats.expArr}</td
|
||||
>
|
||||
<td
|
||||
class="time time-data data {serviceStats.isCancelled && 'can-dat'}"
|
||||
>{serviceStats.schDep}</td
|
||||
>
|
||||
<td
|
||||
class="time time-data data {serviceStats.isDepDelayed &&
|
||||
'late'} {serviceStats.isEarlyDep &&
|
||||
'early'} {serviceStats.isLateDep && 'late'}"
|
||||
<td class="time time-data data {serviceStats.isCancelled && 'can-dat'}">{serviceStats.schDep}</td>
|
||||
<td class="time time-data data {serviceStats.isDepDelayed && 'late'} {serviceStats.isEarlyDep && 'early'} {serviceStats.isLateDep && 'late'}"
|
||||
>{serviceStats.isDepDelayed ? 'LATE' : serviceStats.expDep}</td
|
||||
>
|
||||
</tr>
|
||||
|
||||
Reference in New Issue
Block a user