diff --git a/src/app.css b/src/app.css index 84a7672..4d25d56 100644 --- a/src/app.css +++ b/src/app.css @@ -68,4 +68,7 @@ } p { color: var(--second-text-color) + } + button:hover { + cursor: pointer; } \ No newline at end of file diff --git a/src/lib/islands/quick-link-island.svelte b/src/lib/islands/quick-link-island.svelte index 2c71ae3..b4b4654 100644 --- a/src/lib/islands/quick-link-island.svelte +++ b/src/lib/islands/quick-link-island.svelte @@ -1,19 +1,19 @@ - - {#if !quicklinks.length} + + {#if $ql.length === 0}

Go to settings to add your Quick Links

{/if}
- {#each quicklinks as link} + {#each $ql as link} {#if link.length === 3} {link.toUpperCase()} diff --git a/src/lib/islands/quick-link-set-island.svelte b/src/lib/islands/quick-link-set-island.svelte new file mode 100644 index 0000000..22cd2a2 --- /dev/null +++ b/src/lib/islands/quick-link-set-island.svelte @@ -0,0 +1,104 @@ + + + + {#if $ql.length === 0} +

Click the + button to add links

+ {/if} +
+ {#each qlData as link} + + {/each} + +
+ + +
+ + + \ No newline at end of file diff --git a/src/lib/stores/quick-links.js b/src/lib/stores/quick-links.js new file mode 100644 index 0000000..439735d --- /dev/null +++ b/src/lib/stores/quick-links.js @@ -0,0 +1,29 @@ +import { writable } from 'svelte/store' +import { browser } from '$app/environment'; + +export const ql = writable(fromLocalStorage('ql', [])) +toLocalStorage(ql, 'ql'); + +function fromLocalStorage(storageKey, fallback) { + if (browser) { + const storedValue = localStorage.getItem(storageKey); + if (storedValue !== 'undefined' && storedValue !== null) { + return (typeof fallback === 'object') + ? JSON.parse(storedValue) + : storedValue + } + } + return fallback +} + +function toLocalStorage(store, storageKey) { + if (browser) { + store.subscribe(value => { + let storageValue = (typeof value === 'object') + ? JSON.stringify(value) + : value + + localStorage.setItem(storageKey, storageValue) + }) + } +} \ No newline at end of file diff --git a/src/routes/ldb/+page.svelte b/src/routes/ldb/+page.svelte index ce416cf..14536d2 100644 --- a/src/routes/ldb/+page.svelte +++ b/src/routes/ldb/+page.svelte @@ -10,7 +10,16 @@ return new URLSearchParams(window.location.search).get('station'); } - let jsonData = [] // Extract train data from the object to pass to #each + let jsonData = {}; // Extract train data from the object to pass to #each + let services = []; + + $: { + if (jsonData && jsonData.GetStationBoardResult && jsonData.GetStationBoardResult.trainServices && jsonData.GetStationBoardResult.trainServices.service) { + services = [...jsonData.GetStationBoardResult.trainServices.service]; + } else { + services = ["No train services available"]; + } + } onMount(async () => { const station = await getHeadcode(); @@ -24,7 +33,11 @@

Station:

- +

+{#each services as service} + {service.origin?.location?.locationName || 'Unknown'} +{/each} +

{JSON.stringify(jsonData)}

diff --git a/src/routes/more/+page.svelte b/src/routes/more/+page.svelte index 8f0e950..7218ea1 100644 --- a/src/routes/more/+page.svelte +++ b/src/routes/more/+page.svelte @@ -4,11 +4,12 @@ const title = "More" const links = [ - {title: "Your Data", path: ""}, - {title: "Location Reference Codes", path: ""}, - {title: "Privacy Policy", path: ""}, - {title: "App Versions", path: ""}, - {title: "Statictics", path: ""} + {title: "Your Data", path: "/more/data"}, + {title: "Location Reference Codes", path: "/more/corpus"}, + {title: "Privacy Policy", path: "/more/privacy"}, + {title: "Component Versions", path: "/more/versions"}, + {title: "Statictics", path: "/more/statistics"}, + {title: "Settings", path: "/more/settings"} ] diff --git a/src/routes/more/corpus/+page.svelte b/src/routes/more/corpus/+page.svelte new file mode 100644 index 0000000..5e09942 --- /dev/null +++ b/src/routes/more/corpus/+page.svelte @@ -0,0 +1,12 @@ + + +
+ + + +