From af58e923de2def8856c10526c22b5361d0ec8f13 Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Tue, 30 Apr 2024 11:17:06 +0100 Subject: [PATCH] Update prettier settings --- .eslintrc.cjs | 46 +- .prettierrc | 18 +- package.json | 66 +- src/app.d.ts | 12 +- src/app.html | 14 +- src/lib/DevBanner.svelte | 32 +- src/lib/Tooltip.svelte | 88 +- src/lib/images/large-logo.svelte | 12 +- src/lib/islands/input-island-form.svelte | 78 +- src/lib/islands/island.svelte | 40 +- src/lib/islands/overlay-island.svelte | 54 +- src/lib/islands/quick-link-island.svelte | 92 +- src/lib/islands/quick-link-set-island.svelte | 208 ++--- src/lib/islands/result-island.svelte | 40 +- src/lib/ldb/nrcc/alert-bar.svelte | 206 ++-- src/lib/ldb/public-ldb.svelte | 879 +++++++++--------- src/lib/ldb/staff/fetch.ts | 54 +- src/lib/ldb/staff/staff-ldb.svelte | 142 +-- .../ldb/staff/table/table-generator.svelte | 564 +++++------ src/lib/ldb/staff/train-detail.svelte | 526 +++++------ src/lib/ldb/staff/train-detail.ts | 36 +- src/lib/libauth.ts | 110 +-- src/lib/main.css | 84 +- src/lib/navigation/LogoutButton.svelte | 34 +- src/lib/navigation/done.svelte | 54 +- src/lib/navigation/header.svelte | 86 +- src/lib/navigation/loading-text.svelte | 22 +- src/lib/navigation/loading.svelte | 88 +- src/lib/navigation/nav-ldb.svelte | 158 ++-- src/lib/navigation/nav.svelte | 116 +-- src/lib/overlays/welcome.svelte | 176 ++-- src/lib/raw-fetchers/reason.svelte | 82 +- src/lib/scripts/apiFetch.ts | 82 +- src/lib/scripts/upstream.ts | 16 +- src/lib/stores/quick-links.ts | 32 +- src/lib/stores/tocMap.ts | 84 +- src/lib/stores/uuid.js | 30 +- src/lib/stores/version.ts | 4 +- src/lib/stores/welcome.ts | 30 +- src/lib/themes.css | 36 +- src/lib/train/pis-handler.svelte | 46 +- src/lib/train/styles-toc.svelte | 424 ++++----- src/lib/train/train-detail.svelte | 344 +++---- src/lib/train/trainIcons.svelte | 34 +- src/routes/+error.svelte | 24 +- src/routes/+layout.svelte | 40 +- src/routes/+page.svelte | 50 +- src/routes/err/404/+page.svelte | 18 +- src/routes/err/50x/+page.svelte | 18 +- src/routes/ldb/+page.svelte | 56 +- src/routes/more/+page.svelte | 136 +-- src/routes/more/about/+page.svelte | 30 +- src/routes/more/corpus/+page.svelte | 228 ++--- src/routes/more/data/+page.svelte | 94 +- src/routes/more/help/+page.svelte | 10 +- src/routes/more/privacy/+page.svelte | 88 +- src/routes/more/reasons/+page.svelte | 188 ++-- src/routes/more/reg/+page.svelte | 254 ++--- src/routes/more/reg/submit/+page.svelte | 214 ++--- src/routes/more/report/+page.svelte | 330 +++---- src/routes/more/settings/+page.svelte | 8 +- src/routes/more/statistics/+page.svelte | 122 +-- src/routes/more/versions/+page.svelte | 128 +-- src/routes/pis/+page.svelte | 312 +++---- src/routes/train/+page.svelte | 158 ++-- src/service-worker.js | 78 +- static/manifest.json | 198 ++-- static/sw.js | 26 +- svelte.config.js | 22 +- tsconfig.json | 32 +- vite.config.ts | 6 +- 71 files changed, 4133 insertions(+), 4114 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 7f883f5..0234578 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -1,25 +1,25 @@ module.exports = { - root: true, - extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:svelte/recommended', 'prettier'], - parser: '@typescript-eslint/parser', - plugins: ['@typescript-eslint'], - parserOptions: { - sourceType: 'module', - ecmaVersion: 2020, - extraFileExtensions: ['.svelte'] - }, - env: { - browser: true, - es2017: true, - node: true - }, - overrides: [ - { - files: ['*.svelte'], - parser: 'svelte-eslint-parser', - parserOptions: { - parser: '@typescript-eslint/parser' - } - } - ] + root: true, + extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:svelte/recommended", "prettier"], + parser: "@typescript-eslint/parser", + plugins: ["@typescript-eslint"], + parserOptions: { + sourceType: "module", + ecmaVersion: 2020, + extraFileExtensions: [".svelte"] + }, + env: { + browser: true, + es2017: true, + node: true + }, + overrides: [ + { + files: ["*.svelte"], + parser: "svelte-eslint-parser", + parserOptions: { + parser: "@typescript-eslint/parser" + } + } + ] }; diff --git a/.prettierrc b/.prettierrc index 02869a6..9a07748 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,11 +1,11 @@ { - "useTabs": false, - "tabWidth": 2, - "semi": true, - "singleQuote": true, - "trailingComma": "none", - "printWidth": 180, - "plugins": ["prettier-plugin-svelte"], - "pluginSearchDirs": ["."], - "overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }] + "useTabs": false, + "tabWidth": 4, + "semi": true, + "singleQuote": false, + "trailingComma": "none", + "printWidth": 180, + "plugins": ["prettier-plugin-svelte"], + "pluginSearchDirs": ["."], + "overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }] } diff --git a/package.json b/package.json index 69c0f54..f6fe46e 100644 --- a/package.json +++ b/package.json @@ -1,35 +1,35 @@ { - "name": "owlboard-svelte", - "version": "2024.03.2", - "private": true, - "scripts": { - "dev": "vite dev", - "build": "vite build", - "postbuild": "npx svelte-sitemap --domain https://owlboard.info --ignore '**/err/**' --ignore '**/reg/submit'", - "preview": "vite preview", - "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", - "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", - "lint": "prettier --plugin-search-dir . --check . && eslint .", - "format": "prettier --plugin-search-dir . --write ." - }, - "devDependencies": { - "@owlboard/ts-types": "^1.1.0", - "@sveltejs/adapter-auto": "^2.0.0", - "@sveltejs/adapter-static": "^2.0.2", - "@sveltejs/kit": "^1.5.0", - "eslint": "^8.28.0", - "eslint-config-prettier": "^8.5.0", - "eslint-plugin-svelte": "^2.26.0", - "prettier": "^2.8.0", - "prettier-plugin-svelte": "^2.8.1", - "svelte": "^3.54.0", - "svelte-check": "^3.0.1", - "svelte-sitemap": "^2.6.0", - "typescript": "^5.0.0", - "vite": "^4.3.0" - }, - "type": "module", - "dependencies": { - "@tabler/icons-svelte": "^3.2.0" - } + "name": "owlboard-svelte", + "version": "2024.03.2", + "private": true, + "scripts": { + "dev": "vite dev", + "build": "vite build", + "postbuild": "npx svelte-sitemap --domain https://owlboard.info --ignore '**/err/**' --ignore '**/reg/submit'", + "preview": "vite preview", + "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", + "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", + "lint": "prettier --plugin-search-dir . --check . && eslint .", + "format": "prettier --plugin-search-dir . --write ." + }, + "devDependencies": { + "@owlboard/ts-types": "^1.1.0", + "@sveltejs/adapter-auto": "^2.0.0", + "@sveltejs/adapter-static": "^2.0.2", + "@sveltejs/kit": "^1.5.0", + "eslint": "^8.28.0", + "eslint-config-prettier": "^8.5.0", + "eslint-plugin-svelte": "^2.26.0", + "prettier": "^2.8.0", + "prettier-plugin-svelte": "^2.8.1", + "svelte": "^3.54.0", + "svelte-check": "^3.0.1", + "svelte-sitemap": "^2.6.0", + "typescript": "^5.0.0", + "vite": "^4.3.0" + }, + "type": "module", + "dependencies": { + "@tabler/icons-svelte": "^3.2.0" + } } diff --git a/src/app.d.ts b/src/app.d.ts index 899c7e8..addc02a 100644 --- a/src/app.d.ts +++ b/src/app.d.ts @@ -1,12 +1,12 @@ // See https://kit.svelte.dev/docs/types#app // for information about these interfaces declare global { - namespace App { - // interface Error {} - // interface Locals {} - // interface PageData {} - // interface Platform {} - } + namespace App { + // interface Error {} + // interface Locals {} + // interface PageData {} + // interface Platform {} + } } export {}; diff --git a/src/app.html b/src/app.html index 4f1cdbd..c74868b 100644 --- a/src/app.html +++ b/src/app.html @@ -1,10 +1,10 @@ - - - %sveltekit.head% - - -
%sveltekit.body%
- + + + %sveltekit.head% + + +
%sveltekit.body%
+ diff --git a/src/lib/DevBanner.svelte b/src/lib/DevBanner.svelte index 1ea8ca9..96a5ac7 100644 --- a/src/lib/DevBanner.svelte +++ b/src/lib/DevBanner.svelte @@ -1,20 +1,20 @@ diff --git a/src/lib/Tooltip.svelte b/src/lib/Tooltip.svelte index 0992014..e8f0cef 100644 --- a/src/lib/Tooltip.svelte +++ b/src/lib/Tooltip.svelte @@ -1,58 +1,58 @@
- - {text} + + {text}
diff --git a/src/lib/images/large-logo.svelte b/src/lib/images/large-logo.svelte index 0221ec9..fc8a10e 100644 --- a/src/lib/images/large-logo.svelte +++ b/src/lib/images/large-logo.svelte @@ -1,10 +1,10 @@ Logo diff --git a/src/lib/islands/input-island-form.svelte b/src/lib/islands/input-island-form.svelte index 223ec7e..0b3b58c 100644 --- a/src/lib/islands/input-island-form.svelte +++ b/src/lib/islands/input-island-form.svelte @@ -1,47 +1,47 @@ -
- -
- -
+
+ +
+ +
diff --git a/src/lib/islands/island.svelte b/src/lib/islands/island.svelte index aafdaae..e5c2d2a 100644 --- a/src/lib/islands/island.svelte +++ b/src/lib/islands/island.svelte @@ -1,29 +1,29 @@
- {variables.title} - + {variables.title} +
diff --git a/src/lib/islands/overlay-island.svelte b/src/lib/islands/overlay-island.svelte index 9a6b18d..2d4924d 100644 --- a/src/lib/islands/overlay-island.svelte +++ b/src/lib/islands/overlay-island.svelte @@ -1,36 +1,36 @@
- {variables.title} - + {variables.title} +
diff --git a/src/lib/islands/quick-link-island.svelte b/src/lib/islands/quick-link-island.svelte index 5507074..6e27c38 100644 --- a/src/lib/islands/quick-link-island.svelte +++ b/src/lib/islands/quick-link-island.svelte @@ -1,54 +1,54 @@ - {#if $ql.length === 0} -

Go to settings to add your Quick Links

- {/if} -
- {#each $ql as link} - {#if link.length === 3} - - {link.toUpperCase()} - - {:else if link.length === 4} - - {link.toUpperCase()} - - {/if} - {/each} -
+ {#if $ql.length === 0} +

Go to settings to add your Quick Links

+ {/if} +
+ {#each $ql as link} + {#if link.length === 3} + + {link.toUpperCase()} + + {:else if link.length === 4} + + {link.toUpperCase()} + + {/if} + {/each} +
diff --git a/src/lib/islands/quick-link-set-island.svelte b/src/lib/islands/quick-link-set-island.svelte index c5d945a..a8eff7a 100644 --- a/src/lib/islands/quick-link-set-island.svelte +++ b/src/lib/islands/quick-link-set-island.svelte @@ -1,117 +1,117 @@ - {#if $ql.length === 0} -

Click the + button to add links

- {/if} -
-

Quick links can be CRS Codes or Headcodes

- {#each qlData as link} - - {/each} - -
- - + {#if $ql.length === 0} +

Click the + button to add links

+ {/if} +
+

Quick links can be CRS Codes or Headcodes

+ {#each qlData as link} + + {/each} + +
+ +
diff --git a/src/lib/islands/result-island.svelte b/src/lib/islands/result-island.svelte index 0b33306..b77cf82 100644 --- a/src/lib/islands/result-island.svelte +++ b/src/lib/islands/result-island.svelte @@ -1,31 +1,31 @@ - {#each resultObject.resultLines as line} -

{line}

- {/each} + {#each resultObject.resultLines as line} +

{line}

+ {/each}
diff --git a/src/lib/ldb/nrcc/alert-bar.svelte b/src/lib/ldb/nrcc/alert-bar.svelte index 44d5ec5..ee32a59 100644 --- a/src/lib/ldb/nrcc/alert-bar.svelte +++ b/src/lib/ldb/nrcc/alert-bar.svelte @@ -1,118 +1,118 @@
- - {#if uniqueAlerts.length == 1} -

There is one active alert

- {:else if uniqueAlerts.length > 1} -

- There are {numberAsWord(uniqueAlerts.length)} active alerts -

- {:else} -

There are no active alerts

- {/if} -

V

+ + {#if uniqueAlerts.length == 1} +

There is one active alert

+ {:else if uniqueAlerts.length > 1} +

+ There are {numberAsWord(uniqueAlerts.length)} active alerts +

+ {:else} +

There are no active alerts

+ {/if} +

V

{#if displayAlerts} -
- {#each uniqueAlerts as msg} -

{@html msg}

- {/each} -
+
+ {#each uniqueAlerts as msg} +

{@html msg}

+ {/each} +
{/if} diff --git a/src/lib/ldb/public-ldb.svelte b/src/lib/ldb/public-ldb.svelte index 718d9e4..e676b70 100644 --- a/src/lib/ldb/public-ldb.svelte +++ b/src/lib/ldb/public-ldb.svelte @@ -1,486 +1,491 @@ {#if alerts.length} - + {/if} {#if isLoading} - + {:else if dataAge} -

Updated: {dataAge.toLocaleTimeString()}

- {#if services.length} - - - - - - - - - - - {#each services as service} - - - - - - - - - +

Updated: {dataAge.toLocaleTimeString()}

+ {#if services.length} +
FromToPlat.Sch Arr.Exp Arr.Sch Dep.Exp Dep.
- {#if Array.isArray(service.origin?.location)} - {service.origin.location[0]['locationName'] + ' & ' + service.origin.location[1]['locationName']} - {:else} - {service.origin?.location?.locationName || ''} - {/if} - - {#if Array.isArray(service.destination?.location)} - {service.destination.location[0]['locationName'] + ' & ' + service.destination.location[0]['locationName']} - {:else} - {service.destination?.location?.locationName || ''} - {/if} - {service.platform || '-'}{parseTime(service.sta).data}{parseTime(service.eta).data}{parseTime(service.std).data}{parseTime(service.etd).data}
+ + + + + + + + + + {#each services as service} + + + + + + + + + - - {/each} -
FromToPlat.Sch Arr.Exp Arr.Sch Dep.Exp Dep.
+ {#if Array.isArray(service.origin?.location)} + {service.origin.location[0]["locationName"] + " & " + service.origin.location[1]["locationName"]} + {:else} + {service.origin?.location?.locationName || ""} + {/if} + + {#if Array.isArray(service.destination?.location)} + {service.destination.location[0]["locationName"] + " & " + service.destination.location[0]["locationName"]} + {:else} + {service.destination?.location?.locationName || ""} + {/if} + {service.platform || "-"}{parseTime(service.sta).data}{parseTime(service.eta).data}{parseTime(service.std).data}{parseTime(service.etd).data}
-

- A {service.operator || 'Unknown'} service - {#if service['length']} - with {service['length'] || 'some'} coaches - {/if} -

- {#if service.delayReason} -

{service.delayReason}

- {/if} - {#if service.cancelReason} -

{service.cancelReason}

- {/if} -
- {:else} -

No Scheduled Train Services

- {/if} - {#if busServices.length} -
- Bus services
- Bus Services - - - - - - - - - - {#each busServices as service} - - - - - - - - + + {/each} +
FromToSch Arr.Exp Arr.Sch Dep.Exp Dep.
{service.origin?.location?.locationName || ''}{service.destination?.location?.locationName || ''}{parseTime(service.sta).data}{parseTime(service.eta).data}{parseTime(service.std).data}{parseTime(service.etd).data}
+

+ A {service.operator || "Unknown"} service + {#if service["length"]} + with {service["length"] || "some"} coaches + {/if} +

+ {#if service.delayReason} +

{service.delayReason}

+ {/if} + {#if service.cancelReason} +

{service.cancelReason}

+ {/if} +
+ {:else} +

No Scheduled Train Services

+ {/if} + {#if busServices.length} +
+ Bus services
+ Bus Services + + + + + + + + + + {#each busServices as service} + + + + + + + + - - {/each} -
FromToSch Arr.Exp Arr.Sch Dep.Exp Dep.
{service.origin?.location?.locationName || ""}{service.destination?.location?.locationName || ""}{parseTime(service.sta).data}{parseTime(service.eta).data}{parseTime(service.std).data}{parseTime(service.etd).data}
-

- A {service.operator || 'Unknown'} service -

- {#if service.delayReason} -

{service.delayReason}

- {/if} - {#if service.cancelReason} -

{service.cancelReason}

- {/if} -
- {/if} - {#if ferryServices.length} -
- Bus services
- Ferry Services - - - - - - - - - - {#each ferryServices as service} - - - - - - - - + + {/each} +
FromToSch Arr.Exp Arr.Sch Dep.Exp Dep.
{service.origin?.location?.locationName || ''}{service.destination?.location?.locationName || ''}{parseTime(service.sta).data}{parseTime(service.eta).data}{parseTime(service.std).data}{parseTime(service.etd).data}
+

+ A {service.operator || "Unknown"} service +

+ {#if service.delayReason} +

{service.delayReason}

+ {/if} + {#if service.cancelReason} +

{service.cancelReason}

+ {/if} +
+ {/if} + {#if ferryServices.length} +
+ Bus services
+ Ferry Services + + + + + + + + + + {#each ferryServices as service} + + + + + + + + - - {/each} -
FromToSch Arr.Exp Arr.Sch Dep.Exp Dep.
{service.origin?.location?.locationName || ""}{service.destination?.location?.locationName || ""}{parseTime(service.sta).data}{parseTime(service.eta).data}{parseTime(service.std).data}{parseTime(service.etd).data}
- {#if service.delayReason} -

{service.delayReason}

- {/if} - {#if service.cancelReason} -

{service.cancelReason}

- {/if} -
- {/if} + + {#if service.delayReason} +

{service.delayReason}

+ {/if} + {#if service.cancelReason} +

{service.cancelReason}

+ {/if} + + {/each} + + {/if} {:else} - -

Unable to load data

-
+ +

Unable to load data

+
{/if} {#if serviceDetail} - -
-
Service Detail
- - - - - - - - {#if serviceDetail?.previousCallingPoints?.callingPointList?.callingPoint} - {#if Array.isArray(serviceDetail?.previousCallingPoints?.callingPointList?.callingPoint)} - {#each serviceDetail.previousCallingPoints.callingPointList.callingPoint as prevPoint} - - - - - - {/each} - {:else} - - - - - - {/if} - {/if} - - - - - - {#if serviceDetail?.subsequentCallingPoints?.callingPointList?.callingPoint} - {#if Array.isArray(serviceDetail?.subsequentCallingPoints?.callingPointList?.callingPoint)} - {#each serviceDetail.subsequentCallingPoints.callingPointList.callingPoint as nextPoint} - - - - - - {/each} - {:else} - - - - - - {/if} - {/if} -
LocationSchExp
{prevPoint.locationName}{prevPoint.st}{parseTime(prevPoint.at || prevPoint.et).data}
{serviceDetail.previousCallingPoints.callingPointList.callingPoint.locationName}{serviceDetail.previousCallingPoints.callingPointList.callingPoint.st}{parseTime(serviceDetail.previousCallingPoints.callingPointList.callingPoint.at || serviceDetail.previousCallingPoints.callingPointList.callingPoint.et).data}
{title}{serviceDetail.std || serviceDetail.sta}{parseTime(serviceDetail.etd || serviceDetail.eta).data}
{nextPoint.locationName}{nextPoint.st}{parseTime(nextPoint.et).data}
{serviceDetail.subsequentCallingPoints.callingPointList.callingPoint.locationName}{serviceDetail.subsequentCallingPoints.callingPointList.callingPoint.st}{parseTime(serviceDetail.subsequentCallingPoints.callingPointList.callingPoint.et).data}
-
-
+ +
+
Service Detail
+ + + + + + + + {#if serviceDetail?.previousCallingPoints?.callingPointList?.callingPoint} + {#if Array.isArray(serviceDetail?.previousCallingPoints?.callingPointList?.callingPoint)} + {#each serviceDetail.previousCallingPoints.callingPointList.callingPoint as prevPoint} + + + + + + {/each} + {:else} + + + + + + {/if} + {/if} + + + + + + {#if serviceDetail?.subsequentCallingPoints?.callingPointList?.callingPoint} + {#if Array.isArray(serviceDetail?.subsequentCallingPoints?.callingPointList?.callingPoint)} + {#each serviceDetail.subsequentCallingPoints.callingPointList.callingPoint as nextPoint} + + + + + + {/each} + {:else} + + + + + + {/if} + {/if} +
LocationSchExp
{prevPoint.locationName}{prevPoint.st}{parseTime(prevPoint.at || prevPoint.et).data}
{serviceDetail.previousCallingPoints.callingPointList.callingPoint.locationName}{serviceDetail.previousCallingPoints.callingPointList.callingPoint.st}{parseTime( + serviceDetail.previousCallingPoints.callingPointList.callingPoint.at || serviceDetail.previousCallingPoints.callingPointList.callingPoint.et + ).data}
{title}{serviceDetail.std || serviceDetail.sta}{parseTime(serviceDetail.etd || serviceDetail.eta).data}
{nextPoint.locationName}{nextPoint.st}{parseTime(nextPoint.et).data}
{serviceDetail.subsequentCallingPoints.callingPointList.callingPoint.locationName}{serviceDetail.subsequentCallingPoints.callingPointList.callingPoint.st}{parseTime(serviceDetail.subsequentCallingPoints.callingPointList.callingPoint.et).data}
+
+
{/if} diff --git a/src/lib/ldb/staff/fetch.ts b/src/lib/ldb/staff/fetch.ts index e497ddc..d6cc8fd 100644 --- a/src/lib/ldb/staff/fetch.ts +++ b/src/lib/ldb/staff/fetch.ts @@ -1,39 +1,39 @@ // Fetches StaffLDB Data, correctly formats DATE fields and returns the data -import { getApiUrl } from '$lib/scripts/upstream'; -import { uuid } from '$lib/stores/uuid'; -import type { ApiResponse, StaffLdb } from '@owlboard/ts-types'; +import { getApiUrl } from "$lib/scripts/upstream"; +import { uuid } from "$lib/stores/uuid"; +import type { ApiResponse, StaffLdb } from "@owlboard/ts-types"; // Fetch StaffLDB Data, and returns the data after hydration (convert date types etc.) export async function fetchStaffLdb(station: string): Promise> { - const url = `${getApiUrl()}/api/v2/live/station/${station}/staff`; + const url = `${getApiUrl()}/api/v2/live/station/${station}/staff`; - let uuid_value: string = ''; - const unsubscribe = uuid.subscribe((value) => { - uuid_value = value; - }); + let uuid_value: string = ""; + const unsubscribe = uuid.subscribe((value) => { + uuid_value = value; + }); - const fetchOpts = { - method: 'GET', - headers: { - uuid: uuid_value - } - }; - const res = await fetch(url, fetchOpts); - unsubscribe(); - const resJs = await res.json(); - return parseFormat(JSON.stringify(resJs)); + const fetchOpts = { + method: "GET", + headers: { + uuid: uuid_value + } + }; + const res = await fetch(url, fetchOpts); + unsubscribe(); + const resJs = await res.json(); + return parseFormat(JSON.stringify(resJs)); } // Parse dates within the JSON response function parseFormat(jsonString: any): ApiResponse { - return JSON.parse(jsonString, (key, value) => { - if (typeof value === 'string') { - const dateRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z$/; - if (dateRegex.test(value)) { - return new Date(value); - } - } - return value; - }); + return JSON.parse(jsonString, (key, value) => { + if (typeof value === "string") { + const dateRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z$/; + if (dateRegex.test(value)) { + return new Date(value); + } + } + return value; + }); } diff --git a/src/lib/ldb/staff/staff-ldb.svelte b/src/lib/ldb/staff/staff-ldb.svelte index 3e4ca88..d9e5692 100644 --- a/src/lib/ldb/staff/staff-ldb.svelte +++ b/src/lib/ldb/staff/staff-ldb.svelte @@ -1,89 +1,89 @@ {#key detail} - {#if detail.show} - - {/if} + {#if detail.show} + + {/if} {/key} {#await callFetch(station)} - + {:then data} - {#if data} -

Updated: {new Date(data.generatedAt).toLocaleTimeString()}

- {#if data.trainServices?.length} - + {#if data} +

Updated: {new Date(data.generatedAt).toLocaleTimeString()}

+ {#if data.trainServices?.length} + + {/if} + {#if data.busServices?.length} + Bus services
+ Bus Services + + {/if} + {#if data.ferryServices?.length} + Ferry services
+ Ferry Services + + {/if} + {#if nrcc.length} + + {/if} + {/if} - {#if data.busServices?.length} - Bus services
- Bus Services - - {/if} - {#if data.ferryServices?.length} - Ferry services
- Ferry Services - - {/if} - {#if nrcc.length} - - {/if} - - {/if} {:catch} -

Error

-

ERR-CODE: {errorDetail.code}

-

Message:
{errorDetail.message}

+

Error

+

ERR-CODE: {errorDetail.code}

+

Message:
{errorDetail.message}

{/await} diff --git a/src/lib/ldb/staff/table/table-generator.svelte b/src/lib/ldb/staff/table/table-generator.svelte index 340ae8e..a17926e 100644 --- a/src/lib/ldb/staff/table/table-generator.svelte +++ b/src/lib/ldb/staff/table/table-generator.svelte @@ -1,319 +1,319 @@

Your display is too small to view this data

Try rotating your device

- - - - - - - - - - - - - - - {#each services as service} - detail(event, service.rid, service.uid, service.trainid)} - on:keypress={(event) => detail(event, service.rid, service.uid, service.trainid)} - > - {#await classGenerator(service) then classes} - - - - - - - - - - - - - - - - - {/await} + + + + + + + + + - + + - {/each} + {#each services as service} + detail(event, service.rid, service.uid, service.trainid)} + on:keypress={(event) => detail(event, service.rid, service.uid, service.trainid)} + > + {#await classGenerator(service) then classes} + + + + + + + + + + + + + + + + + {/await} + + + + + {/each}
IDFromToPlatSchExpSchExp
- ArrivalDeparture
{service.trainid}{#await formatLocations(service.origin) then origin}{origin}{/await}{#await formatLocations(service.destination) then dest}{dest}{/await}{service.platform || '-'}{fmtTime(service?.sta) || '-'}{fmtTime(service.eta) || fmtTime(service.ata) || '-'}{fmtTime(service.std) || '-'}{fmtTime(service.etd) || fmtTime(service.atd) || '-'}
IDFromToPlatSchExpSchExp
- - {#if service.destination?.[0] && service.destination[0].via}{service.destination[0].via}
{/if} - {tocMap.get(service.operatorCode.toLowerCase()) || service.operatorCode} - {#if service.length} | {service.length} carriages{/if} - {#if service.delayReason} -
- - - - {/if} - {#if service.cancelReason} -
- - - - {/if} -
+ ArrivalDeparture
{service.trainid}{#await formatLocations(service.origin) then origin}{origin}{/await}{#await formatLocations(service.destination) then dest}{dest}{/await}{service.platform || "-"}{fmtTime(service?.sta) || "-"}{fmtTime(service.eta) || fmtTime(service.ata) || "-"}{fmtTime(service.std) || "-"}{fmtTime(service.etd) || fmtTime(service.atd) || "-"}
+ + {#if service.destination?.[0] && service.destination[0].via}{service.destination[0].via}
{/if} + {tocMap.get(service.operatorCode.toLowerCase()) || service.operatorCode} + {#if service.length} | {service.length} carriages{/if} + {#if service.delayReason} +
+ + + + {/if} + {#if service.cancelReason} +
+ + + + {/if} +
diff --git a/src/lib/ldb/staff/train-detail.svelte b/src/lib/ldb/staff/train-detail.svelte index 6db90dc..51d379a 100644 --- a/src/lib/ldb/staff/train-detail.svelte +++ b/src/lib/ldb/staff/train-detail.svelte @@ -1,286 +1,286 @@ -
- - {#await getTrain(detail.rid)} -
{detail.headcode}
-

Loading Data...

- {:then train} -
{detail.headcode}
-

- Locations in grey are not scheduled stops -
- Times in yellow are estimated times -

- {#if train.GetServiceDetailsResult.delayReason} -

- -

- {/if} - {#if train.GetServiceDetailsResult.cancelReason} -

- -

- {/if} - - - - - - - - - - - - - - {#each train.GetServiceDetailsResult.locations.location as location} - - - - {#await parseTimes(location)} - - - - - {/await} - {#await parseDelay(location)} - - {:then delay} - - {/await} - - {/each} -
Loc.Pl.SchEst/
Act
SchEst/
Act
-
- ArrivalDeparture -
{location.tiploc}{location.platform || ''} - - - - {:then times} - {times.sta}{times.eata}{times.std}{times.eatd}-{delay.string}
- {:catch} -
Error loading data
- {/await} -
+
+ + {#await getTrain(detail.rid)} +
{detail.headcode}
+

Loading Data...

+ {:then train} +
{detail.headcode}
+

+ Locations in grey are not scheduled stops +
+ Times in yellow are estimated times +

+ {#if train.GetServiceDetailsResult.delayReason} +

+ +

+ {/if} + {#if train.GetServiceDetailsResult.cancelReason} +

+ +

+ {/if} + + + + + + + + + + + + + + {#each train.GetServiceDetailsResult.locations.location as location} + + + + {#await parseTimes(location)} + + + + + {/await} + {#await parseDelay(location)} + + {:then delay} + + {/await} + + {/each} +
Loc.Pl.SchEst/
Act
SchEst/
Act
+
+ ArrivalDeparture +
{location.tiploc}{location.platform || ""} + + + + {:then times} + {times.sta}{times.eata}{times.std}{times.eatd}-{delay.string}
+ {:catch} +
Error loading data
+ {/await} +
diff --git a/src/lib/ldb/staff/train-detail.ts b/src/lib/ldb/staff/train-detail.ts index 1d39bc1..f6feae9 100644 --- a/src/lib/ldb/staff/train-detail.ts +++ b/src/lib/ldb/staff/train-detail.ts @@ -1,29 +1,29 @@ // Contains the details required to lookup train details export interface Detail { - show: boolean; - headcode: string; - rid: string; - uid: string; + show: boolean; + headcode: string; + rid: string; + uid: string; } // Initiates/Resets a `Detail` interface export function detailInit(): Detail { - const detail: Detail = { - show: false, - headcode: '', - rid: '', - uid: '' - }; - return detail; + const detail: Detail = { + show: false, + headcode: "", + rid: "", + uid: "" + }; + return detail; } // Initiates/Updates a `Detail` interface using the given values export function defineDetail(rid: string, uid: string, tid: string) { - const detail: Detail = { - rid: rid, - uid: uid, - headcode: tid, - show: true - }; - return detail; + const detail: Detail = { + rid: rid, + uid: uid, + headcode: tid, + show: true + }; + return detail; } diff --git a/src/lib/libauth.ts b/src/lib/libauth.ts index 4860ddb..b5d380f 100644 --- a/src/lib/libauth.ts +++ b/src/lib/libauth.ts @@ -1,77 +1,77 @@ -import { getApiUrl } from './scripts/upstream'; -import { uuid } from './stores/uuid'; +import { getApiUrl } from "./scripts/upstream"; +import { uuid } from "./stores/uuid"; export interface libauthResponse { - uuidPresent?: boolean; - serverAuthCheck?: boolean; - uuidValue?: string; - serverAuthCheckResponseCode?: number; + uuidPresent?: boolean; + serverAuthCheck?: boolean; + uuidValue?: string; + serverAuthCheckResponseCode?: number; } interface uuidCheckRes { - uuidValue?: string; - uuidPresent?: boolean; + uuidValue?: string; + uuidPresent?: boolean; } export async function checkAuth(): Promise { - let result: libauthResponse = {}; - const uuidCheck = await checkUuid(); - result.uuidPresent = uuidCheck?.uuidPresent; - result.uuidValue = uuidCheck?.uuidValue; + let result: libauthResponse = {}; + const uuidCheck = await checkUuid(); + result.uuidPresent = uuidCheck?.uuidPresent; + result.uuidValue = uuidCheck?.uuidValue; - const serverCheck = await checkServerAuth(result.uuidValue || ''); - result.serverAuthCheck = serverCheck.authOk; - result.serverAuthCheckResponseCode = serverCheck.status; + const serverCheck = await checkServerAuth(result.uuidValue || ""); + result.serverAuthCheck = serverCheck.authOk; + result.serverAuthCheckResponseCode = serverCheck.status; - return result; + return result; } async function checkUuid(): Promise { - let uuid_value: string = ''; - const unsubscribe = uuid.subscribe((value) => { - uuid_value = value; - }); - let res: uuidCheckRes = { - uuidValue: uuid_value - }; - console.log('uuid-value is: ', uuid_value); - if (uuid_value && uuid_value != 'null') { - res = { - uuidPresent: true, - uuidValue: uuid_value + let uuid_value: string = ""; + const unsubscribe = uuid.subscribe((value) => { + uuid_value = value; + }); + let res: uuidCheckRes = { + uuidValue: uuid_value }; - } else { - res = { - uuidPresent: false, - uuidValue: uuid_value - }; - } - unsubscribe(); - return res; + console.log("uuid-value is: ", uuid_value); + if (uuid_value && uuid_value != "null") { + res = { + uuidPresent: true, + uuidValue: uuid_value + }; + } else { + res = { + uuidPresent: false, + uuidValue: uuid_value + }; + } + unsubscribe(); + return res; } async function checkServerAuth(uuidString: string) { - const url = `${getApiUrl()}/api/v2/user/checkAuth`; - const options = { - method: 'GET', - headers: { - uuid: uuidString + const url = `${getApiUrl()}/api/v2/user/checkAuth`; + const options = { + method: "GET", + headers: { + uuid: uuidString + } + }; + const res = await fetch(url, options); + let ok: boolean; + if (res.status !== 401) { + ok = true; + } else { + ok = false; } - }; - const res = await fetch(url, options); - let ok: boolean; - if (res.status !== 401) { - ok = true; - } else { - ok = false; - } - return { - authOk: ok, - status: res.status - }; + return { + authOk: ok, + status: res.status + }; } export async function logout(): Promise { - uuid.set(null); - return true; + uuid.set(null); + return true; } diff --git a/src/lib/main.css b/src/lib/main.css index 33f8861..bd05a13 100644 --- a/src/lib/main.css +++ b/src/lib/main.css @@ -1,67 +1,67 @@ /* FONTS */ @font-face { - font-family: 'firamono'; - src: url('/font/firamono/firamono-regular.woff2') format('woff2'), url('/font/firamono/firamono-regular.woff') format('woff'), - url('/font/firamono/firamono-regular.ttf') format('truetype'); - font-weight: normal; - font-style: normal; + font-family: "firamono"; + src: url("/font/firamono/firamono-regular.woff2") format("woff2"), url("/font/firamono/firamono-regular.woff") format("woff"), + url("/font/firamono/firamono-regular.ttf") format("truetype"); + font-weight: normal; + font-style: normal; } @font-face { - font-family: 'firamono'; - src: url('/font/firamono/firamono-500.woff2') format('woff2'), url('/font/firamono/firamono-500.woff') format('woff'), url('/font/firamono/firamono-500.ttf') format('truetype'); - font-weight: 500; - font-style: normal; + font-family: "firamono"; + src: url("/font/firamono/firamono-500.woff2") format("woff2"), url("/font/firamono/firamono-500.woff") format("woff"), url("/font/firamono/firamono-500.ttf") format("truetype"); + font-weight: 500; + font-style: normal; } @font-face { - font-family: 'urwgothic'; - src: url('/font/urwgothic/urwgothic.woff2') format('woff2'), url('/font/urwgothic/urwgothic.woff') format('woff'), url('/font/urwgothic/urwgothic.ttf') format('truetype'); - font-weight: normal; - font-style: normal; + font-family: "urwgothic"; + src: url("/font/urwgothic/urwgothic.woff2") format("woff2"), url("/font/urwgothic/urwgothic.woff") format("woff"), url("/font/urwgothic/urwgothic.ttf") format("truetype"); + font-weight: normal; + font-style: normal; } @font-face { - font-family: 'urwgothic'; - src: url('/font/urwgothic/urwgothicDemi.woff2') format('woff2'), url('/font/urwgothic/urwgothicDemi.woff') format('woff'), - url('/font/urwgothic/urwgothicDemi.ttf') format('truetype'); - font-weight: 900; - font-style: normal; + font-family: "urwgothic"; + src: url("/font/urwgothic/urwgothicDemi.woff2") format("woff2"), url("/font/urwgothic/urwgothicDemi.woff") format("woff"), + url("/font/urwgothic/urwgothicDemi.ttf") format("truetype"); + font-weight: 900; + font-style: normal; } @font-face { - font-family: 'ubuntu'; - src: url('/font/ubuntumono/ubuntumono-regular.woff2') format('woff2'), url('/font/ubuntumono/ubuntumono-regular.woff') format('woff'), - url('/font/ubuntumono/ubuntumono-regular.ttf') format('truetype'); - font-weight: 400; - font-style: normal; + font-family: "ubuntu"; + src: url("/font/ubuntumono/ubuntumono-regular.woff2") format("woff2"), url("/font/ubuntumono/ubuntumono-regular.woff") format("woff"), + url("/font/ubuntumono/ubuntumono-regular.ttf") format("truetype"); + font-weight: 400; + font-style: normal; } html { - width: 100%; - height: 100%; + width: 100%; + height: 100%; } body { - background-color: var(--main-bg-color); - background-image: radial-gradient(var(--second-bg-color), var(--main-bg-color)); - color: var(--main-text-color); - font-family: urwgothic, sans-serif; - text-align: center; - margin: auto; - width: 100%; - padding-bottom: 65px; + background-color: var(--main-bg-color); + background-image: radial-gradient(var(--second-bg-color), var(--main-bg-color)); + color: var(--main-text-color); + font-family: urwgothic, sans-serif; + text-align: center; + margin: auto; + width: 100%; + padding-bottom: 65px; } a { - color: var(--main-link-color); + color: var(--main-link-color); } button:hover { - cursor: pointer; + cursor: pointer; } button { - -webkit-touch-callout: none; - -webkit-user-select: none; - -khtml-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; - -webkit-tap-highlight-color: transparent; + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + -webkit-tap-highlight-color: transparent; } diff --git a/src/lib/navigation/LogoutButton.svelte b/src/lib/navigation/LogoutButton.svelte index 90c7a9f..206850a 100644 --- a/src/lib/navigation/LogoutButton.svelte +++ b/src/lib/navigation/LogoutButton.svelte @@ -1,25 +1,25 @@ diff --git a/src/lib/navigation/done.svelte b/src/lib/navigation/done.svelte index 3372b14..ebc0cf5 100644 --- a/src/lib/navigation/done.svelte +++ b/src/lib/navigation/done.svelte @@ -1,32 +1,32 @@
-

-

Done

+

+

Done

diff --git a/src/lib/navigation/header.svelte b/src/lib/navigation/header.svelte index 0c639da..a1a1226 100644 --- a/src/lib/navigation/header.svelte +++ b/src/lib/navigation/header.svelte @@ -1,56 +1,56 @@
- - - - OwlBoard Logo - - -
{title}
+ + + + OwlBoard Logo + + +
{title}
- +
diff --git a/src/lib/navigation/loading-text.svelte b/src/lib/navigation/loading-text.svelte index 8641412..d3347ab 100644 --- a/src/lib/navigation/loading-text.svelte +++ b/src/lib/navigation/loading-text.svelte @@ -1,16 +1,16 @@

Loading...

diff --git a/src/lib/navigation/loading.svelte b/src/lib/navigation/loading.svelte index bd18803..40b86ed 100644 --- a/src/lib/navigation/loading.svelte +++ b/src/lib/navigation/loading.svelte @@ -1,54 +1,54 @@
-
-

Loading...

+
+

Loading...

diff --git a/src/lib/navigation/nav-ldb.svelte b/src/lib/navigation/nav-ldb.svelte index d875e38..c36d935 100644 --- a/src/lib/navigation/nav-ldb.svelte +++ b/src/lib/navigation/nav-ldb.svelte @@ -1,93 +1,93 @@ diff --git a/src/lib/navigation/nav.svelte b/src/lib/navigation/nav.svelte index 7644136..42fa987 100644 --- a/src/lib/navigation/nav.svelte +++ b/src/lib/navigation/nav.svelte @@ -1,69 +1,69 @@ diff --git a/src/lib/overlays/welcome.svelte b/src/lib/overlays/welcome.svelte index 88bb0b2..d5d28bd 100644 --- a/src/lib/overlays/welcome.svelte +++ b/src/lib/overlays/welcome.svelte @@ -1,106 +1,106 @@ diff --git a/src/lib/raw-fetchers/reason.svelte b/src/lib/raw-fetchers/reason.svelte index fd3eb12..c7fab3b 100644 --- a/src/lib/raw-fetchers/reason.svelte +++ b/src/lib/raw-fetchers/reason.svelte @@ -1,49 +1,49 @@ -{#if type === 'cancel'} - {#await getCancel(code)} - This train has been cancelled - {:then reason} - {reason} - {:catch} - This train has been cancelled - {/await} -{:else if type === 'delay'} - {#await getDelay(code)} - This train has been delayed - {:then reason} - {reason} - {:catch} - This train has been delayed - {/await} +{#if type === "cancel"} + {#await getCancel(code)} + This train has been cancelled + {:then reason} + {reason} + {:catch} + This train has been cancelled + {/await} +{:else if type === "delay"} + {#await getDelay(code)} + This train has been delayed + {:then reason} + {reason} + {:catch} + This train has been delayed + {/await} {/if} diff --git a/src/lib/scripts/apiFetch.ts b/src/lib/scripts/apiFetch.ts index 32f8198..ec82a94 100644 --- a/src/lib/scripts/apiFetch.ts +++ b/src/lib/scripts/apiFetch.ts @@ -1,51 +1,51 @@ -import { dev } from '$app/environment'; -import { uuid } from '$lib/stores/uuid'; -import type { Unsubscriber } from 'svelte/store'; +import { dev } from "$app/environment"; +import { uuid } from "$lib/stores/uuid"; +import type { Unsubscriber } from "svelte/store"; function getUrlString(): string { - if (dev) { - const testUrl: string = 'http://localhost:8460'; - console.info('DEVMODE active, using testing URL: ', testUrl); - return testUrl; - } else { - const currentUrl: string = `https://${window.location.host}`; - return currentUrl; - } + if (dev) { + const testUrl: string = "http://localhost:8460"; + console.info("DEVMODE active, using testing URL: ", testUrl); + return testUrl; + } else { + const currentUrl: string = `https://${window.location.host}`; + return currentUrl; + } } export async function apiGet(path: string): Promise { - let uuidString: string = ''; - let unsubscribe: Unsubscriber; - try { - unsubscribe = uuid.subscribe((value) => { - uuidString = value; - }); - } catch (err) { - throw new Error('Unable to read UUID'); - } - - const options = { - method: 'GET', - headers: { - uuid: uuidString + let uuidString: string = ""; + let unsubscribe: Unsubscriber; + try { + unsubscribe = uuid.subscribe((value) => { + uuidString = value; + }); + } catch (err) { + throw new Error("Unable to read UUID"); } - }; - try { - const res = await fetch(getUrlString() + path, options); + const options = { + method: "GET", + headers: { + uuid: uuidString + } + }; - if (!res.ok) { - throw new Error('Network response not ok'); + try { + const res = await fetch(getUrlString() + path, options); + + if (!res.ok) { + throw new Error("Network response not ok"); + } + const contentType = res.headers.get("content-type"); + if (!contentType || !contentType.includes("application/json")) { + throw new Error("Invalid response. Require JSON."); + } + return await res.json(); + } catch (err) { + console.error("Error fetching data:", err); + throw err; + } finally { + unsubscribe(); } - const contentType = res.headers.get('content-type'); - if (!contentType || !contentType.includes('application/json')) { - throw new Error('Invalid response. Require JSON.'); - } - return await res.json(); - } catch (err) { - console.error('Error fetching data:', err); - throw err; - } finally { - unsubscribe(); - } } diff --git a/src/lib/scripts/upstream.ts b/src/lib/scripts/upstream.ts index abb0aa0..94ee000 100644 --- a/src/lib/scripts/upstream.ts +++ b/src/lib/scripts/upstream.ts @@ -1,12 +1,12 @@ -import { dev } from '$app/environment'; +import { dev } from "$app/environment"; -const testUrl: string = 'http://localhost:8460'; -const prodUrl: string = 'https://owlboard.info'; +const testUrl: string = "http://localhost:8460"; +const prodUrl: string = "https://owlboard.info"; export function getApiUrl() { - if (dev) { - console.info('DEVMODE active, using testing URL: ', testUrl); - return testUrl; - } - return prodUrl; + if (dev) { + console.info("DEVMODE active, using testing URL: ", testUrl); + return testUrl; + } + return prodUrl; } diff --git a/src/lib/stores/quick-links.ts b/src/lib/stores/quick-links.ts index 47ff599..35c447b 100644 --- a/src/lib/stores/quick-links.ts +++ b/src/lib/stores/quick-links.ts @@ -1,25 +1,25 @@ -import { writable, type Writable } from 'svelte/store'; -import { browser } from '$app/environment'; +import { writable, type Writable } from "svelte/store"; +import { browser } from "$app/environment"; -export const ql = writable(fromLocalStorage('ql', [])); -toLocalStorage(ql, 'ql'); +export const ql = writable(fromLocalStorage("ql", [])); +toLocalStorage(ql, "ql"); function fromLocalStorage(storageKey: string, fallback: string[]): string[] { - if (browser) { - const storedValue = localStorage.getItem(storageKey); - if (storedValue !== 'undefined' && storedValue !== null) { - return typeof fallback === 'object' ? JSON.parse(storedValue) : storedValue; + if (browser) { + const storedValue = localStorage.getItem(storageKey); + if (storedValue !== "undefined" && storedValue !== null) { + return typeof fallback === "object" ? JSON.parse(storedValue) : storedValue; + } } - } - return fallback; + return fallback; } function toLocalStorage(store: Writable, storageKey: string) { - if (browser) { - store.subscribe((value) => { - let storageValue = typeof value === 'object' ? JSON.stringify(value.sort()) : value; + if (browser) { + store.subscribe((value) => { + let storageValue = typeof value === "object" ? JSON.stringify(value.sort()) : value; - localStorage.setItem(storageKey, storageValue); - }); - } + localStorage.setItem(storageKey, storageValue); + }); + } } diff --git a/src/lib/stores/tocMap.ts b/src/lib/stores/tocMap.ts index 7f36c36..58a12a0 100644 --- a/src/lib/stores/tocMap.ts +++ b/src/lib/stores/tocMap.ts @@ -1,44 +1,44 @@ export const tocs = new Map([ - ['gw', 'Great Western Railway'], - ['sw', 'South Western Railway'], - ['il', 'Island Line'], - ['nt', 'Northern'], - ['aw', 'Trafnidiaeth Cymru'], - ['cc', 'c2c'], - ['cs', 'Caledonian Sleeper'], - ['ch', 'Chiltern Railways'], - ['xc', 'CrossCountry'], - ['em', 'East Midlands Railway'], - ['es', 'Eurostar'], - ['ht', 'Hull Trains'], - ['tl', 'Thameslink'], - ['gc', 'Grand Central'], - ['gx', 'Gatwick Express'], - ['hx', 'Heathrow Express'], - ['ls', 'Locomotive Services Limited'], - ['me', 'Merseyrail'], - ['lr', 'Network Rail OTM'], - ['xr', 'TfL Elizabeth Line'], - ['se', 'Southeastern'], - ['sn', 'Southern'], - ['le', 'Greater Anglia'], - ['ga', 'Greater Anglia'], - ['lm', 'West Midlands Railway (LM)'], - ['sr', 'ScotRail'], - ['gn', 'Great Northern'], - ['lt', 'TfL London Underground'], - ['lo', 'TfL London Overground'], - ['sj', 'SuperTram (Sheffield)'], - ['tp', 'TransPennine Express'], - ['vt', 'Avanti West Coast'], - ['gr', 'LNER'], - ['wr', 'West Coast Railway'], - ['ty', 'Vintage Trains'], - ['tw', 'Nexus (Tyne & Wear Metro)'], - ['ld', 'Lumo'], - ['so', 'Rail Adventure'], - ['ln', 'Grand Union Trains'], - ['zz', 'Freight/Charter Company'], - ['wm', 'West Midlands Railway (WM)'], - ['uk', 'Unknown Operator'] + ["gw", "Great Western Railway"], + ["sw", "South Western Railway"], + ["il", "Island Line"], + ["nt", "Northern"], + ["aw", "Trafnidiaeth Cymru"], + ["cc", "c2c"], + ["cs", "Caledonian Sleeper"], + ["ch", "Chiltern Railways"], + ["xc", "CrossCountry"], + ["em", "East Midlands Railway"], + ["es", "Eurostar"], + ["ht", "Hull Trains"], + ["tl", "Thameslink"], + ["gc", "Grand Central"], + ["gx", "Gatwick Express"], + ["hx", "Heathrow Express"], + ["ls", "Locomotive Services Limited"], + ["me", "Merseyrail"], + ["lr", "Network Rail OTM"], + ["xr", "TfL Elizabeth Line"], + ["se", "Southeastern"], + ["sn", "Southern"], + ["le", "Greater Anglia"], + ["ga", "Greater Anglia"], + ["lm", "West Midlands Railway (LM)"], + ["sr", "ScotRail"], + ["gn", "Great Northern"], + ["lt", "TfL London Underground"], + ["lo", "TfL London Overground"], + ["sj", "SuperTram (Sheffield)"], + ["tp", "TransPennine Express"], + ["vt", "Avanti West Coast"], + ["gr", "LNER"], + ["wr", "West Coast Railway"], + ["ty", "Vintage Trains"], + ["tw", "Nexus (Tyne & Wear Metro)"], + ["ld", "Lumo"], + ["so", "Rail Adventure"], + ["ln", "Grand Union Trains"], + ["zz", "Freight/Charter Company"], + ["wm", "West Midlands Railway (WM)"], + ["uk", "Unknown Operator"] ]); diff --git a/src/lib/stores/uuid.js b/src/lib/stores/uuid.js index aec8d8d..d4e20f1 100644 --- a/src/lib/stores/uuid.js +++ b/src/lib/stores/uuid.js @@ -1,23 +1,23 @@ -import { writable } from 'svelte/store'; -import { browser } from '$app/environment'; +import { writable } from "svelte/store"; +import { browser } from "$app/environment"; -export const uuid = writable(fromLocalStorage('uuid', null)); -toLocalStorage(uuid, 'uuid'); +export const uuid = writable(fromLocalStorage("uuid", null)); +toLocalStorage(uuid, "uuid"); function fromLocalStorage(storageKey, fallback) { - if (browser) { - const storedValue = localStorage.getItem(storageKey); - if (storedValue !== 'undefined') { - return storedValue; + if (browser) { + const storedValue = localStorage.getItem(storageKey); + if (storedValue !== "undefined") { + return storedValue; + } } - } - return fallback; + return fallback; } function toLocalStorage(store, storageKey) { - if (browser) { - store.subscribe((value) => { - localStorage.setItem(storageKey, value); - }); - } + if (browser) { + store.subscribe((value) => { + localStorage.setItem(storageKey, value); + }); + } } diff --git a/src/lib/stores/version.ts b/src/lib/stores/version.ts index 29c0041..ce16d9a 100644 --- a/src/lib/stores/version.ts +++ b/src/lib/stores/version.ts @@ -1,3 +1,3 @@ -export const version: string = '2024.04.5'; -export const versionTag: string = ''; +export const version: string = "2024.04.5"; +export const versionTag: string = ""; export const showWelcome: boolean = false; diff --git a/src/lib/stores/welcome.ts b/src/lib/stores/welcome.ts index 415a4e5..27152b5 100644 --- a/src/lib/stores/welcome.ts +++ b/src/lib/stores/welcome.ts @@ -1,23 +1,23 @@ -import { writable, type Writable } from 'svelte/store'; -import { browser } from '$app/environment'; +import { writable, type Writable } from "svelte/store"; +import { browser } from "$app/environment"; -export const welcome = writable(fromLocalStorage('welcome', '0')); -toLocalStorage(welcome, 'welcome'); +export const welcome = writable(fromLocalStorage("welcome", "0")); +toLocalStorage(welcome, "welcome"); function fromLocalStorage(storageKey: string, fallback: string) { - if (browser) { - const storedValue = localStorage.getItem(storageKey); - if (storedValue !== 'undefined') { - return storedValue; + if (browser) { + const storedValue = localStorage.getItem(storageKey); + if (storedValue !== "undefined") { + return storedValue; + } } - } - return fallback; + return fallback; } function toLocalStorage(store: Writable, storageKey: string) { - if (browser) { - store.subscribe((value: string) => { - localStorage.setItem(storageKey, value); - }); - } + if (browser) { + store.subscribe((value: string) => { + localStorage.setItem(storageKey, value); + }); + } } diff --git a/src/lib/themes.css b/src/lib/themes.css index a3433a8..2508064 100644 --- a/src/lib/themes.css +++ b/src/lib/themes.css @@ -19,24 +19,24 @@ /* Main Theme */ :root { - --main-bg-color: #404c55; - --second-bg-color: #2b343c; - --main-header-color: #dff3f3; - --main-text-color: #cce9e9; - --secondary-text-color: #02fcfc; - --main-link-color: #00b7b7; - --island-bg-color: #3c6f79de; - --island-bg-solid: #3c6f79; - --island-button-color: #404c55; - --island-link-color: #e1ebeb; - --island-header-color: #4fd1d1; - --island-text-color: #e1ebeb; - --overlay-island-bg-color: #3c6f79; - --box-shadow-color: rgba(0, 0, 0, 0.19); - --box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.19); - --main-alert-color: #ed6d00; - --second-alert-color: #e77f00; - --main-warning-color: orange; + --main-bg-color: #404c55; + --second-bg-color: #2b343c; + --main-header-color: #dff3f3; + --main-text-color: #cce9e9; + --secondary-text-color: #02fcfc; + --main-link-color: #00b7b7; + --island-bg-color: #3c6f79de; + --island-bg-solid: #3c6f79; + --island-button-color: #404c55; + --island-link-color: #e1ebeb; + --island-header-color: #4fd1d1; + --island-text-color: #e1ebeb; + --overlay-island-bg-color: #3c6f79; + --box-shadow-color: rgba(0, 0, 0, 0.19); + --box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.19); + --main-alert-color: #ed6d00; + --second-alert-color: #e77f00; + --main-warning-color: orange; } /* Christmas Theme diff --git a/src/lib/train/pis-handler.svelte b/src/lib/train/pis-handler.svelte index d475c68..378f9b2 100644 --- a/src/lib/train/pis-handler.svelte +++ b/src/lib/train/pis-handler.svelte @@ -1,33 +1,33 @@ {#if pisObject} - {#if typeof pisObject === 'string' || typeof pisObject === 'number'} - PIS: {pisObject} - {:else if pisObject['skipCount'] === 0} - PIS: {pisObject.code} - {:else if pisObject['skipCount'] > 0} - PIS: {pisObject.code} -
- (skip {pisObject.skipType}{#if pisObject.skipCount > 1} {' ' + pisObject.skipCount} stops{:else} stop{/if}) - {/if} + {#if typeof pisObject === "string" || typeof pisObject === "number"} + PIS: {pisObject} + {:else if pisObject["skipCount"] === 0} + PIS: {pisObject.code} + {:else if pisObject["skipCount"] > 0} + PIS: {pisObject.code} +
+ (skip {pisObject.skipType}{#if pisObject.skipCount > 1} {" " + pisObject.skipCount} stops{:else} stop{/if}) + {/if} {/if} diff --git a/src/lib/train/styles-toc.svelte b/src/lib/train/styles-toc.svelte index db37f7f..db5bc0f 100644 --- a/src/lib/train/styles-toc.svelte +++ b/src/lib/train/styles-toc.svelte @@ -1,223 +1,223 @@ {text} diff --git a/src/lib/train/train-detail.svelte b/src/lib/train/train-detail.svelte index f48f294..8a9b10a 100644 --- a/src/lib/train/train-detail.svelte +++ b/src/lib/train/train-detail.svelte @@ -1,187 +1,187 @@
-
- - {service?.stops[0]['publicDeparture'] || service?.stops[0]['wttDeparture']} - {service?.stops[0]['tiploc']} to {service?.stops[service['stops'].length - 1]['tiploc']} - V -
- {#if isExpanded} -
- {#await getTrainByUID(service.trainUid)} - - {:then serviceDetail} - {#if serviceDetail.stpIndicator === 'C'} -

This has been removed from the timetable for today.

-

The service may have been retimed, re-routed or removed from todays timetable completely.

-

If it has been retimed or re-routed, there is likely to be another service with the same headcode booked to run.

- {:else} -
- - - {#if serviceDetail.pis} - - {/if} -

- Planned Type: {parseInt(serviceDetail.planSpeed) || '--'}mph {serviceDetail.powerType || 'Non-Rail vehicle'} -

-

- Days Run: {serviceDetail?.daysRun.join(', ').toUpperCase() || 'Unknown'} -

-

- Valid From: {new Date(serviceDetail.scheduleStart).toLocaleDateString('en-GB', { - timeZone: 'UTC' - })} - {new Date(serviceDetail.scheduleEnd).toLocaleDateString('en-GB', { - timeZone: 'UTC' - })} -

- - - - - - - - - {#each serviceDetail.stops as stop} - - {#if stop.publicArrival || stop.publicDeparture} - - - - - {:else if stop.wttArrival || stop.wttDeparture} - - - - - {:else} - - - - - {/if} - - {/each} -
Italics are 'pass' times, grey times are non-passenger stops
LocationPlt.Sch Arr.Sch Dep.
{stop.tiploc}{stop.platform || '-'}{stop.publicArrival || '-'}{stop.publicDeparture || '-'}{stop.tiploc}{stop.platform || stop.depLine || stop.arrLine || '-'}{stop.wttArrival || '-'}{stop.wttDeparture || '-'}{stop.tiploc}{stop.platform || stop.depLine || stop.arrLine || '-'}-{stop.pass || '-'}
- {/if} - {:catch} -

Unable to fetch train data

- {/await} +
+ + {service?.stops[0]["publicDeparture"] || service?.stops[0]["wttDeparture"]} + {service?.stops[0]["tiploc"]} to {service?.stops[service["stops"].length - 1]["tiploc"]} + V
- {/if} + {#if isExpanded} +
+ {#await getTrainByUID(service.trainUid)} + + {:then serviceDetail} + {#if serviceDetail.stpIndicator === "C"} +

This has been removed from the timetable for today.

+

The service may have been retimed, re-routed or removed from todays timetable completely.

+

If it has been retimed or re-routed, there is likely to be another service with the same headcode booked to run.

+ {:else} +
+ + + {#if serviceDetail.pis} + + {/if} +

+ Planned Type: {parseInt(serviceDetail.planSpeed) || "--"}mph {serviceDetail.powerType || "Non-Rail vehicle"} +

+

+ Days Run: {serviceDetail?.daysRun.join(", ").toUpperCase() || "Unknown"} +

+

+ Valid From: {new Date(serviceDetail.scheduleStart).toLocaleDateString("en-GB", { + timeZone: "UTC" + })} - {new Date(serviceDetail.scheduleEnd).toLocaleDateString("en-GB", { + timeZone: "UTC" + })} +

+ + + + + + + + + {#each serviceDetail.stops as stop} + + {#if stop.publicArrival || stop.publicDeparture} + + + + + {:else if stop.wttArrival || stop.wttDeparture} + + + + + {:else} + + + + + {/if} + + {/each} +
Italics are 'pass' times, grey times are non-passenger stops
LocationPlt.Sch Arr.Sch Dep.
{stop.tiploc}{stop.platform || "-"}{stop.publicArrival || "-"}{stop.publicDeparture || "-"}{stop.tiploc}{stop.platform || stop.depLine || stop.arrLine || "-"}{stop.wttArrival || "-"}{stop.wttDeparture || "-"}{stop.tiploc}{stop.platform || stop.depLine || stop.arrLine || "-"}-{stop.pass || "-"}
+ {/if} + {:catch} +

Unable to fetch train data

+ {/await} +
+ {/if}
diff --git a/src/lib/train/trainIcons.svelte b/src/lib/train/trainIcons.svelte index 436cb2b..49abd2d 100644 --- a/src/lib/train/trainIcons.svelte +++ b/src/lib/train/trainIcons.svelte @@ -1,38 +1,38 @@ {#if serviceDetails.firstClass} - - - + + + {/if} {#if serviceDetails.catering} - - - + + + {/if} {#if serviceDetails.sleeper} - - - + + + {/if} {#if serviceDetails.vstp} - - - + + + {/if} {#if serviceDetails.firstClass || serviceDetails.catering || serviceDetails.sleeper || serviceDetails.vstp} -
+
{/if} diff --git a/src/routes/err/50x/+page.svelte b/src/routes/err/50x/+page.svelte index 379322f..98f752c 100644 --- a/src/routes/err/50x/+page.svelte +++ b/src/routes/err/50x/+page.svelte @@ -1,8 +1,8 @@
@@ -14,10 +14,10 @@