48 lines
1.2 KiB
Svelte
Raw Normal View History

2023-06-13 13:38:59 +01:00
<script>
import Header from '$lib/navigation/header.svelte'
2023-06-15 18:19:23 +01:00
import Nav from '$lib/navigation/nav.svelte'
2023-06-13 13:38:59 +01:00
import { onMount } from 'svelte'
let title = "Timetable Results"
let id = ""
let data = [];
2023-06-13 13:38:59 +01:00
async function getHeadcode() {
return new URLSearchParams(window.location.search).get('headcode');
}
onMount(async () => {
id = await getHeadcode() || "";
data = await fetchData(id);
2023-06-13 13:38:59 +01:00
})
async function fetchData(id = "") {
const date = 'now';
const searchType = 'headcode'
const url = `https://owlboard.info/api/v2/timetable/train/${date}/${searchType}/${id}`
const res = await fetch(url);
return await res.json();
}
</script>
2023-06-13 13:38:59 +01:00
<svelte:head>
<title>OwlBoard {title}</title>
</svelte:head>
2023-06-13 13:38:59 +01:00
<Header {title} />
2023-06-13 13:38:59 +01:00
<p>{id.toUpperCase()}</p> <!-- NOT REACTIVE YET -->
{#each data as service}
<h2>{service.stops[0]['publicDeparture']} {service.stops[0]['tiploc']} to {service.stops[service['stops'].length -1]['tiploc']}</h2>
<p>PIS: {service.pis}</p>
{#each service.stops as stop}
<p>{stop.tiploc}</p>
{/each}
{/each}
2023-06-13 13:38:59 +01:00
<p id="data_raw"></p>
2023-06-13 13:38:59 +01:00
<Nav />