Train results complete

This commit is contained in:
Fred Boniface 2023-06-20 19:22:59 +01:00
parent 8c9f2de590
commit 6442d698c0

View File

@ -8,6 +8,14 @@
let id = "" let id = ""
let data = []; let data = [];
$: {
if (id) {
title = id.toUpperCase();
} else {
title = "Querying Timetable"
}
}
async function getHeadcode() { async function getHeadcode() {
return new URLSearchParams(window.location.search).get('headcode'); return new URLSearchParams(window.location.search).get('headcode');
} }
@ -33,16 +41,62 @@
<Header {title} /> <Header {title} />
<p>{id.toUpperCase()}</p> <!-- NOT REACTIVE YET -->
{#each data as service} {#each data as service}
<h2>{service.stops[0]['publicDeparture']} {service.stops[0]['tiploc']} to {service.stops[service['stops'].length -1]['tiploc']}</h2> {#if service.stops[0]['publicDeparture']}
<h2>GW: {service.stops[0]['publicDeparture']} {service.stops[0]['tiploc']} to {service.stops[service['stops'].length -1]['tiploc']}</h2>
<p>PIS: {service.pis}</p> <p>PIS: {service.pis}</p>
<table>
<tr>
<th>Location</th>
<th>Sch Arr.</th>
<th>Sch Dep.</th>
</tr>
{#each service.stops as stop} {#each service.stops as stop}
<p>{stop.tiploc}</p> {#if stop.publicArrival || stop.publicDeparture}
<tr>
<td>{stop.tiploc}</td>
<td>{stop.publicArrival || '-'}</td>
<td>{stop.publicDeparture || '-'}</td>
</tr>
{/if}
{/each} {/each}
</table>
{:else}
<h2>GW: {service.stops[0]['wttDeparture']} {service.stops[0]['tiploc']} to {service.stops[service['stops'].length -1]['tiploc']}</h2>
<p>PIS: {service.pis}</p>
<table>
<tr>
<th>Location</th>
<th>Sch Arr.</th>
<th>Sch Dep.</th>
</tr>
{#each service.stops as stop}
<tr>
<td>{stop.tiploc}</td>
<td>{stop.wttArrival}</td>
<td>{stop.wttDeparture}</td>
</tr>
{/each}
</table>
{/if}
{/each} {/each}
<p id="data_raw"></p>
<Nav /> <Nav />
<style>
h2 {
margin-top: 50px;
}
p {
font-size: 20px;
font-weight: 600;
}
table {
margin: auto;
font-size: 20px;
}
th, td {
padding-left: 8px;
padding-right: 8px;
}
</style>