2023-06-13 13:38:59 +01:00
|
|
|
<script>
|
|
|
|
import Menu from '../../components/header.svelte'
|
|
|
|
import Footer from '../../components/footer.svelte'
|
|
|
|
|
|
|
|
import {onMount} from 'svelte'
|
|
|
|
|
|
|
|
const title = "Public Board"
|
|
|
|
const page = "ldb"
|
|
|
|
|
|
|
|
async function getHeadcode() {
|
|
|
|
return new URLSearchParams(window.location.search).get('station');
|
|
|
|
}
|
|
|
|
|
2023-06-14 00:43:06 +01:00
|
|
|
/**
|
|
|
|
* @type {any[]}
|
|
|
|
*/
|
|
|
|
let jsonData = [] // Extract train data from the object to pass to #each
|
|
|
|
|
2023-06-13 13:38:59 +01:00
|
|
|
onMount(async () => {
|
2023-06-13 13:58:04 +01:00
|
|
|
const station = await getHeadcode();
|
|
|
|
document.getElementById('station').textContent = station;
|
2023-06-14 00:43:06 +01:00
|
|
|
const data = await fetch(`https://owlboard.info/api/v1/ldb/${station}`);
|
|
|
|
const jsonData = await data.json();
|
|
|
|
//document.getElementById('data_raw').textContent = JSON.stringify(await data.json());
|
2023-06-13 13:38:59 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<Menu {title} />
|
|
|
|
|
|
|
|
<p>Station: <span id="station"></span></p>
|
2023-06-14 00:43:06 +01:00
|
|
|
{#each jsonData as item}
|
|
|
|
<p>{item.GetStationBoardResult.trainServices.operator}</p>
|
|
|
|
{/each}
|
2023-06-13 13:58:04 +01:00
|
|
|
|
2023-06-13 13:38:59 +01:00
|
|
|
|
|
|
|
<Footer {page} />
|