Compare commits

..

No commits in common. "main" and "2024.2.1" have entirely different histories.

144 changed files with 6860 additions and 7878 deletions

View File

@ -1,9 +0,0 @@
.DS_Store
node_modules
/build
/package
.env
.env.*
!.env.example
vite.config.js.timestamp-*
vite.config.ts.timestamp-*

View File

@ -1,25 +1,25 @@
module.exports = { module.exports = {
root: true, root: true,
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:svelte/recommended", "prettier"], extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:svelte/recommended', 'prettier'],
parser: "@typescript-eslint/parser", parser: '@typescript-eslint/parser',
plugins: ["@typescript-eslint"], plugins: ['@typescript-eslint'],
parserOptions: { parserOptions: {
sourceType: "module", sourceType: 'module',
ecmaVersion: 2020, ecmaVersion: 2020,
extraFileExtensions: [".svelte"], extraFileExtensions: ['.svelte']
}, },
env: { env: {
browser: true, browser: true,
es2017: true, es2017: true,
node: true, node: true
}, },
overrides: [ overrides: [
{ {
files: ["*.svelte"], files: ['*.svelte'],
parser: "svelte-eslint-parser", parser: 'svelte-eslint-parser',
parserOptions: { parserOptions: {
parser: "@typescript-eslint/parser", parser: '@typescript-eslint/parser'
}, }
}, }
], ]
}; };

View File

@ -1,7 +1,11 @@
{ {
"tabWidth": 4, "useTabs": false,
"printWidth": 180, "tabWidth": 2,
"plugins": ["prettier-plugin-svelte"], "semi": true,
"pluginSearchDirs": ["."], "singleQuote": true,
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }] "trailingComma": "none",
"printWidth": 180,
"plugins": ["prettier-plugin-svelte"],
"pluginSearchDirs": ["."],
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
} }

View File

@ -1,5 +1,4 @@
load_module modules/ngx_http_brotli_static_module.so; load_module modules/ngx_http_brotli_static_module.so;
load_module modules/ngx_http_brotli_filter_module.so;
user nginx; user nginx;
worker_processes auto; worker_processes auto;
@ -21,7 +20,7 @@ http {
'$status $body_bytes_sent "$http_referer" ' '$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'; '"$http_user_agent" "$http_x_forwarded_for"';
access_log /dev/stdout main; access_log /var/log/nginx/access.log main;
sendfile on; sendfile on;
@ -32,14 +31,7 @@ http {
proxy_cache_path /var/cache/nginx keys_zone=owl_cache:20m inactive=24h; proxy_cache_path /var/cache/nginx keys_zone=owl_cache:20m inactive=24h;
upstream backend { upstream backend {
# Within Kubernetes: server owlboard-backend:8460;
#server owlboard-backend:8460;
# External to Kubernetes:
#server 172.30.129.19:8460;
# Within Docker:
server backend:8460;
} }
server { server {
@ -52,33 +44,29 @@ http {
location / { location / {
root /usr/share/nginx/html; root /usr/share/nginx/html;
index /index.html; index index;
gzip_static on; gzip_static on;
brotli_static on; brotli_static on;
error_page 500 502 503 504 /err/50x.html; error_page 500 502 503 504 /err/50x.html;
try_files $uri $uri/ $uri.html /index.html; error_page 404 /err/404;
try_files $uri.html $uri $uri/index.html $uri/ =404;
add_header Cache-Control "public, no-transform, max-age=1209600"; add_header Cache-Control "public, no-transform, max-age=1209600";
if ($uri ~* \.html$) {
return 404;
}
} }
location /misc/ { location /misc/ {
proxy_pass http://backend; proxy_pass http://backend;
brotli on;
brotli_comp_level 6;
brotli_types *;
gzip on;
gzip_comp_level 6;
gzip_types *;
} }
location /api/ { location /api/ {
proxy_pass http://backend; proxy_pass http://backend;
brotli on;
brotli_comp_level 6;
brotli_types *;
gzip on;
gzip_comp_level 6;
gzip_types *;
proxy_cache_key $scheme://$host$uri$is_args$query_string; proxy_cache_key $scheme://$host$uri$is_args$query_string;
proxy_ignore_headers Cache-Control;
proxy_cache_valid 200 2m; # Evaluate whether 2m or 1m is more appropriate
add_header Cache-Control "private, no-transform, max-age=120";
} }
} }

5669
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,34 +1,32 @@
{ {
"name": "owlboard-svelte", "name": "owlboard-svelte",
"version": "2024.03.2", "version": "2024.2.1",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "vite dev", "dev": "vite dev",
"build": "vite build", "build": "vite build",
"postbuild": "npx svelte-sitemap --domain https://owlboard.info --ignore '**/err/**' --ignore '**/reg/submit'", "postbuild": "npx svelte-sitemap --domain https://owlboard.info --ignore '**/err/**' --ignore '**/reg/submit'",
"preview": "vite preview", "preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --plugin-search-dir . --check . && eslint .", "lint": "prettier --plugin-search-dir . --check . && eslint .",
"format": "prettier --plugin-search-dir . --write ." "format": "prettier --plugin-search-dir . --write ."
}, },
"devDependencies": { "devDependencies": {
"@owlboard/ts-types": "^1.2.0", "@owlboard/ts-types": "^0.1.8",
"@sveltejs/adapter-auto": "^2.0.0", "@sveltejs/adapter-auto": "^2.0.0",
"@sveltejs/adapter-static": "^2.0.2", "@sveltejs/adapter-static": "^2.0.2",
"@sveltejs/kit": "^1.5.0", "@sveltejs/kit": "^1.5.0",
"eslint": "^8.28.0", "eslint": "^8.28.0",
"eslint-config-prettier": "^8.5.0", "eslint-config-prettier": "^8.5.0",
"eslint-plugin-svelte": "^2.26.0", "eslint-plugin-svelte": "^2.26.0",
"prettier": "^2.8.0", "prettier": "^2.8.0",
"prettier-plugin-svelte": "^2.8.1", "prettier-plugin-svelte": "^2.8.1",
"svelte": "^3.54.0", "svelte": "^3.54.0",
"svelte-check": "^3.0.1", "svelte-check": "^3.0.1",
"svelte-french-toast": "^1.2.0", "svelte-sitemap": "^2.6.0",
"svelte-sitemap": "^2.6.0", "typescript": "^5.0.0",
"typescript": "^5.0.0", "vite": "^4.3.0"
"vite": "^4.3.0", },
"@tabler/icons-svelte": "^3.2.0" "type": "module"
},
"type": "module"
} }

12
src/app.d.ts vendored
View File

@ -1,12 +1,12 @@
// See https://kit.svelte.dev/docs/types#app // See https://kit.svelte.dev/docs/types#app
// for information about these interfaces // for information about these interfaces
declare global { declare global {
namespace App { namespace App {
// interface Error {} // interface Error {}
// interface Locals {} // interface Locals {}
// interface PageData {} // interface PageData {}
// interface Platform {} // interface Platform {}
} }
} }
export {}; export {};

View File

@ -1,10 +1,10 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
%sveltekit.head% %sveltekit.head%
</head> </head>
<body data-sveltekit-preload-data="hover"> <body data-sveltekit-preload-data="hover">
<div style="display: contents">%sveltekit.body%</div> <div style="display: contents">%sveltekit.body%</div>
</body> </body>
</html> </html>

View File

@ -1,20 +1,20 @@
<div id="banner">DEVMODE</div> <div id="banner">DEVMODE</div>
<style> <style>
#banner { #banner {
width: 200px; width: 200px;
background: rgba(255, 0, 0, 0.5); background: red;
color: #ffffff7a; color: #fff;
position: fixed; position: fixed;
text-align: center; text-align: center;
top: 25px; top: 25px;
line-height: 40px; line-height: 40px;
right: -50px; right: -50px;
left: auto; left: auto;
-ms-transform: rotate(45deg); -ms-transform: rotate(45deg);
-webkit-transform: rotate(45deg); -webkit-transform: rotate(45deg);
transform: rotate(45deg); transform: rotate(45deg);
z-index: 100; z-index: 100;
box-shadow: 5px 5px 30px rgba(0, 0, 0, 0.451); box-shadow: 5px 5px 30px rgba(0, 0, 0, 0.451);
} }
</style> </style>

View File

@ -1,58 +0,0 @@
<script lang="ts">
import { onMount, onDestroy } from "svelte";
export let text: string;
let isVisible: boolean = false;
let timer: number;
function showTooltip() {
isVisible = true;
timer = setTimeout(() => {
isVisible = false;
}, 2000);
}
function hideTooltip() {
isVisible = false;
clearTimeout(timer);
}
onDestroy(() => {
clearTimeout(timer);
});
</script>
<div class="tooltip" on:touchstart={showTooltip} on:touchend={hideTooltip} on:touchcancel={hideTooltip}>
<slot />
<span class="tooltiptext">{text}</span>
</div>
<style>
.tooltip {
position: relative;
display: inline-block;
cursor: pointer;
}
.tooltip .tooltiptext {
visibility: hidden;
width: 120px;
background-color: var(--island-button-color);
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px;
position: absolute;
z-index: 1;
bottom: 125%;
left: 50%;
margin-left: -60px;
opacity: 0;
transition: opacity 0.3s;
}
.tooltip:hover .tooltiptext {
visibility: visible;
opacity: 1;
}
</style>

View File

@ -1,35 +0,0 @@
<script lang="ts">
export let link: string;
export let text: string;
</script>
<a class="link-button" href={link}>{text}</a>
<style>
.link-button {
color: aliceblue;
border: none;
border-radius: 20px;
text-decoration: none;
margin: 5px;
background-color: var(--island-button-color);
font-family: urwgothic, "Lucida Sans", "Lucida Sans Regular", "Lucida Grande", "Lucida Sans Unicode", Geneva, Verdana, sans-serif;
padding: 5px 25px;
min-width: 40px;
width: fit-content;
height: 22px;
font-size: 16px;
font-weight: 400;
box-shadow: var(--box-shadow);
transition: all 0.3s ease;
cursor: pointer;
display: flex;
justify-content: center;
align-items: center;
}
.link-button:hover {
box-shadow: var(--box-shadow-dark);
background-color: rgb(45, 45, 45);
}
</style>

View File

@ -1,34 +0,0 @@
<script lang="ts">
export let fn = () => {};
export let text: string;
</script>
<button class="script-button" on:click={fn} on:keypress={fn}>{text}</button>
<style>
.script-button {
color: aliceblue;
border: none;
border-radius: 20px;
text-decoration: none;
margin: 5px;
font-family: urwgothic, "Lucida Sans", "Lucida Sans Regular", "Lucida Grande", "Lucida Sans Unicode", Geneva, Verdana, sans-serif;
background-color: var(--island-button-color);
padding: 20px;
min-width: 40px;
height: 25px;
font-size: 16px;
font-weight: 400;
box-shadow: var(--box-shadow);
transition: all 0.3s ease;
cursor: pointer;
display: flex;
justify-content: center;
align-items: center;
}
.script-button:hover {
box-shadow: var(--box-shadow-dark);
background-color: rgb(45, 45, 45);
}
</style>

View File

@ -1,108 +0,0 @@
<script lang="ts">
import { fade } from "svelte/transition";
import type { CardConfig } from "./Card.types";
import { IconHelpCircle, IconRefresh } from "@tabler/icons-svelte";
import Tooltip from "$lib/Tooltip.svelte";
export let config: CardConfig;
</script>
<div class="card" in:fade={{ duration: 250 }}>
<div class="header">
<h2 class="title">{config.title}</h2>
<div class="actions">
{#if config.showHelp}
<Tooltip text={config.helpText}>
<button aria-label="Help">
<IconHelpCircle />
</button>
</Tooltip>
{/if}
{#if config.showRefresh}
<button class:refreshing={config.refreshing} on:click={config.onRefresh} aria-label="Refresh">
<IconRefresh />
</button>
{/if}
</div>
</div>
<div class="content">
<slot />
</div>
</div>
<style>
.card {
width: 85%;
max-width: 400px;
margin: auto;
margin-top: 10px;
margin-bottom: 20px;
padding: 10px 5px 5px 5px;
background-color: var(--island-bg-color);
border-radius: 10px;
box-shadow: 5px 5px 30px rgba(0, 0, 0, 0.29);
min-height: 75px;
}
.header {
color: var(--island-header-color);
font-size: 14px;
display: flex;
margin: 0;
width: 100%;
justify-content: center;
align-items: center;
position: relative;
text-shadow: 2px 1px 10px rgba(0, 0, 0, 0.29);
}
.title {
flex-grow: 1;
text-align: center;
margin: 0;
}
.actions {
display: flex;
position: absolute;
top: 5px;
right: 0;
display: flex;
gap: 0px;
}
.refreshing {
animation: spin 1.5s linear infinite;
transform-origin: 50% 45%;
}
.content {
margin-top: 5px;
}
button {
cursor: pointer;
color: white;
background: none;
border: none;
transition: all 0.3s ease;
}
button:hover {
color: var(--island-header-color);
}
@keyframes spin {
0% {
transform: rotate(0deg);
color: white;
}
50% {
color: rgb(185, 185, 255);
}
100% {
transform: rotate(-360deg);
color: white;
}
}
</style>

View File

@ -1,17 +0,0 @@
export interface CardConfig {
title: string;
showHelp: boolean;
showRefresh: boolean;
helpText: string;
onRefresh: () => void;
refreshing: boolean;
}
export interface LookupCardConfig {
title: string;
formAction: string;
maxLen: number;
placeholder: string;
helpText: string;
fieldName: string;
}

View File

@ -1,64 +0,0 @@
<script lang="ts">
import Card from "./Card.svelte";
import type { CardConfig, LookupCardConfig } from "./Card.types";
export let config: LookupCardConfig;
let upstreamConfig: CardConfig = {
title: config.title,
showHelp: false, // If enabled without showRefresh, cards will be shifted to left!
showRefresh: false,
helpText: config.helpText,
onRefresh: () => {},
refreshing: false,
};
</script>
<Card config={upstreamConfig}>
<form action={config.formAction}>
<input type="text" name={config.fieldName} placeholder={config.placeholder} maxlength={config.maxLen} autocomplete="off" />
<br />
<button type="submit">Submit</button>
</form>
</Card>
<style>
input {
margin: 4px;
width: 75%;
max-width: 250px;
text-align: center;
text-transform: uppercase;
font-family: urwgothic, "Lucida Sans", "Lucida Sans Regular", "Lucida Grande", "Lucida Sans Unicode", Geneva, Verdana, sans-serif;
font-size: 15px;
height: 30px;
border: none;
border-radius: 20px;
box-shadow: var(--box-shadow);
transition: all 0.3s ease;
}
button {
margin: 5px;
background-color: var(--island-button-color);
color: white;
border: none;
border-radius: 20px;
font-family: urwgothic, "Lucida Sans", "Lucida Sans Regular", "Lucida Grande", "Lucida Sans Unicode", Geneva, Verdana, sans-serif;
font-size: 16px;
width: 40%;
max-width: 200px;
height: 30px;
box-shadow: var(--box-shadow);
transition: all 0.3s ease;
}
input:hover {
box-shadow: var(--box-shadow-dark);
}
button:hover {
background-color: rgb(45, 45, 45);
box-shadow: var(--box-shadow-dark);
}
</style>

View File

@ -1,107 +0,0 @@
<script lang="ts">
import { getCurrentLocation } from "$lib/scripts/getLocation";
import toast from "svelte-french-toast";
import Card from "./Card.svelte";
import type { CardConfig } from "./Card.types";
import type { NearestStationResponse } from "@owlboard/ts-types";
import { uuid } from "$lib/stores/uuid";
import { location } from "$lib/stores/location";
import InLineLoading from "$lib/navigation/InLineLoading.svelte";
import { apiGet } from "$lib/scripts/apiFetch";
import { onMount } from "svelte";
import { nearToMeCache } from "$lib/stores/nearToMeCache";
import LinkButton from "$lib/buttons/LinkButton.svelte";
import ScriptButton from "$lib/buttons/ScriptButton.svelte";
let errorMessage: string;
let stations: NearestStationResponse[] = [];
let blockLoading: boolean = true;
let config: CardConfig = {
title: "Near to Me",
showHelp: true,
showRefresh: true,
helpText: "Your location may not be accurate on desktop and laptop devices.",
onRefresh: getNearestStations,
refreshing: false,
};
function turnOnLocation() {
location.set(true);
getCurrentLocation();
toast.success("Done\nTo disable location, go to settings");
}
async function getNearestStations() {
// Get location, then fetch nearest stations and push to `stations` variable
config.refreshing = true;
const currentLocation = await getCurrentLocation();
const apiPath: string = `/api/v2/live/station/nearest/${currentLocation.latitude}/${currentLocation.longitude}`;
try {
const apiResponse = (await apiGet(apiPath)) as NearestStationResponse[];
stations = apiResponse;
nearToMeCache.set(apiResponse);
} catch (err) {
errorMessage = err as string;
} finally {
config.refreshing = false;
}
}
onMount(() => {
if ($location) {
if (!$uuid || $uuid === "null") {
errorMessage = "Register to use this feature";
} else {
if ($nearToMeCache.length) {
stations = $nearToMeCache;
}
getNearestStations();
}
}
blockLoading = false;
});
</script>
<Card {config}>
{#if blockLoading}
<InLineLoading />
{:else}
<div id="buttons">
{#if !$uuid || $uuid === "null"}
<LinkButton text="Register to use this feature" link="/more/reg" />
{:else if $location}
{#if !stations.length}
{#if errorMessage}
<p>{errorMessage}</p>
{:else}
<InLineLoading />
{/if}
{:else}
{#each stations as station}
<LinkButton text={`${station.NLCDESC} - ${station.miles}mi`} link={`/ldb?station=${station["3ALPHA"]}`} />
{/each}
{/if}
{:else}
<ScriptButton text={"Turn on Location"} fn={turnOnLocation} />
{/if}
</div>
{/if}
</Card>
<style>
#buttons {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
width: 95%;
margin: auto;
padding-top: 5px;
}
p {
text-align: center;
margin: auto;
}
</style>

View File

@ -1,45 +0,0 @@
<script lang="ts">
import Card from "./Card.svelte";
import type { CardConfig } from "./Card.types";
import { ql } from "$lib/stores/quick-links";
import LinkButton from "$lib/buttons/LinkButton.svelte";
let upstreamProps: CardConfig = {
title: "Quick Links",
showHelp: false,
showRefresh: false,
helpText: "",
onRefresh: () => {},
refreshing: false,
};
</script>
<Card config={upstreamProps}>
<div class="quick-links">
{#if !$ql.length}
<LinkButton text={"Add Quick Links"} link={"/more/settings"} />
{:else}
{#each $ql as link}
{#if link.length === 3}
<LinkButton text={link.toUpperCase()} link={`/ldb?station=${link.toLowerCase()}`} />
{:else if link.length === 4}
<LinkButton text={link.toUpperCase()} link={`/train?headcode=${link.toLowerCase()}`} />
{/if}
{/each}
{/if}
</div>
</Card>
<style>
.quick-links {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
width: 90%;
margin: auto;
padding-top: 5px;
}
</style>

View File

@ -1,10 +1,10 @@
<img src="/images/logo/wide_logo.svg" alt="Logo" /> <img src="/images/logo/wide_logo.svg" alt="Logo" />
<style> <style>
img { img {
width: 50%; width: 50%;
max-width: 250px; max-width: 250px;
margin-top: 55px; margin-top: 55px;
margin-bottom: 55px; margin-bottom: 55px;
} }
</style> </style>

View File

@ -0,0 +1,47 @@
<script lang="ts">
import Island from '$lib/islands/island.svelte';
export let variables = {
title: 'Uninitialised',
action: '/',
placeholder: 'Uninitialised',
queryName: 'uninitiailsed'
};
</script>
<Island {variables}>
<form action={variables.action}>
<input class="form-input" type="text" id="input-headcode" name={variables.queryName} placeholder={variables.placeholder} autocomplete="off" />
<br />
<button type="submit">Submit</button>
</form>
</Island>
<style>
.form-input {
width: 75%;
height: 32px;
margin-top: 5px;
margin-bottom: 5px;
border-radius: 50px;
border: none;
text-align: center;
font-family: urwgothic, 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
text-transform: uppercase;
font-size: 15px;
box-shadow: var(--box-shadow);
}
button {
width: 50%;
margin-bottom: 5px;
margin-top: 5px;
border: none;
border-radius: 20px;
padding: 5px;
font-family: urwgothic, 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
font-size: 16px;
font-weight: 400;
background-color: var(--island-button-color);
color: var(--island-link-color);
box-shadow: var(--box-shadow);
}
</style>

View File

@ -1,29 +1,29 @@
<script lang="ts"> <script lang="ts">
import { fade } from "svelte/transition"; import { fade } from 'svelte/transition';
export let variables = { title: "" }; export let variables = { title: '' };
</script> </script>
<div in:fade={{ duration: 250 }}> <div in:fade={{ duration: 250 }}>
<span>{variables.title}</span> <span>{variables.title}</span>
<slot /> <slot />
</div> </div>
<style> <style>
span { span {
font-family: urwgothic, "Lucida Sans", "Lucida Sans Regular", "Lucida Grande", "Lucida Sans Unicode", Geneva, Verdana, sans-serif; font-family: urwgothic, 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
font-weight: 600; font-weight: 600;
font-size: 20px; font-size: 20px;
color: var(--island-header-color); color: var(--island-header-color);
} }
div { div {
width: 85%; width: 85%;
max-width: 400px; max-width: 400px;
margin: auto; margin: auto;
margin-top: 25px; margin-top: 25px;
padding: 10px; padding: 10px;
background-color: var(--island-bg-color); background-color: var(--island-bg-color);
border-radius: 10px; border-radius: 10px;
box-shadow: 5px 5px 30px rgba(0, 0, 0, 0.29); box-shadow: 5px 5px 30px rgba(0, 0, 0, 0.29);
} }
</style> </style>

View File

@ -1,36 +1,36 @@
<script lang="ts"> <script lang="ts">
import { fade } from "svelte/transition"; import { fade } from 'svelte/transition';
export let variables = { title: "" }; export let variables = { title: '' };
</script> </script>
<div in:fade={{ duration: 150 }} out:fade={{ duration: 150 }}> <div in:fade={{ duration: 150 }} out:fade={{ duration: 150 }}>
<span>{variables.title}</span> <span>{variables.title}</span>
<slot /> <slot />
</div> </div>
<style> <style>
span { span {
font-family: urwgothic, "Lucida Sans", "Lucida Sans Regular", "Lucida Grande", "Lucida Sans Unicode", Geneva, Verdana, sans-serif; font-family: urwgothic, 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
color: var(--island-header-color); color: var(--island-header-color);
font-weight: 600; font-weight: 600;
font-size: 20px; font-size: 20px;
} }
div { div {
position: fixed; position: fixed;
top: 50%; top: 50%;
left: 50%; left: 50%;
transform: translateY(-50%) translateX(-50%); transform: translateY(-50%) translateX(-50%);
width: 85%; width: 85%;
height: auto; height: auto;
max-height: 75vh; max-height: 75vh;
overflow-y: auto; overflow-y: auto;
max-width: 400px; max-width: 400px;
margin: auto; margin: auto;
margin-top: 25px; margin-top: 25px;
padding: 10px; padding: 10px;
background-color: var(--island-bg-solid); background-color: var(--island-bg-solid);
border-radius: 10px; border-radius: 10px;
z-index: 1000; z-index: 1000;
} }
</style> </style>

View File

@ -0,0 +1,54 @@
<script lang="ts">
import Island from '$lib/islands/island.svelte';
import { ql } from '$lib/stores/quick-links';
export let variables = {
title: 'Quick Links'
};
</script>
<Island {variables}>
{#if $ql.length === 0}
<p>Go to <a href="/more/settings">settings</a> to add your Quick Links</p>
{/if}
<div class="buttons">
{#each $ql as link}
{#if link.length === 3}
<a class="link" href="/ldb?station={link}">
{link.toUpperCase()}
</a>
{:else if link.length === 4}
<a class="link" href="/train?headcode={link}">
{link.toUpperCase()}
</a>
{/if}
{/each}
</div>
</Island>
<style>
.buttons {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
width: 90%;
margin: auto;
padding-top: 5px;
}
.link {
flex: 1;
width: 20%;
min-width: 50px;
margin: 5px;
border: none;
border-radius: 20px;
padding: 5px;
font-family: urwgothic, 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
font-size: 16px;
font-weight: 400;
text-decoration: none;
background-color: var(--island-button-color);
color: var(--island-link-color);
box-shadow: var(--box-shadow);
}
</style>

View File

@ -1,126 +1,117 @@
<script lang="ts"> <script lang="ts">
import Island from "$lib/islands/island.svelte"; import Island from '$lib/islands/island.svelte';
import { ql } from "$lib/stores/quick-links"; import { ql } from '$lib/stores/quick-links';
import toast from "svelte-french-toast"; export let variables = {
export let variables = { title: 'Quick Links'
title: "Quick Links", };
};
let qlData: string[] = []; let qlData: string[] = [];
$: { $: {
qlData = $ql; qlData = $ql;
console.log(qlData); console.log(qlData);
}
let saveButton = 'Save';
async function timeout(ms: number): Promise<any> {
return new Promise((resolve) => setTimeout(resolve, ms));
}
async function saveQl() {
// Fetch the content of all text entries within the island then run ql.set([ARRAY OF INPUT CONTENT])
const inputs = document.getElementsByClassName('qlInput');
let inputLinks: string[] = [];
for (let item of inputs) {
let text = (<HTMLInputElement>item)?.value;
if (text !== '') {
inputLinks.push(text);
}
} }
console.log(inputLinks);
ql.set(inputLinks);
saveButton = '&#10004;';
await timeout(3000);
saveButton = 'Saved';
}
let saveButton = "Save"; function clearQl() {
ql.set([]);
saveButton = 'Saved';
}
async function timeout(ms: number): Promise<any> { function addQlBox() {
return new Promise((resolve) => setTimeout(resolve, ms)); saveButton = 'Save';
} const updatedQl = [...$ql, ''];
$ql = updatedQl;
ql.set(updatedQl);
}
function save() { function handleClick(event: any) {
toast.promise(saveQl(), { // Handle the click event here
loading: "Saving...", console.log('Island Clicked');
success: "Quick Links saved!", // You can access the `variables` passed to the Island component here if needed
error: "Failed to save.", }
});
}
async function saveQl() {
// Fetch the content of all text entries within the island then run ql.set([ARRAY OF INPUT CONTENT])
const inputs = document.getElementsByClassName("qlInput");
let inputLinks: string[] = [];
for (let item of inputs) {
let text = (<HTMLInputElement>item)?.value;
if (text !== "") {
inputLinks.push(text);
}
}
console.log(inputLinks);
ql.set(inputLinks);
await timeout(1000);
saveButton = "Saved";
}
function clearQl() {
ql.set([]);
saveButton = "Saved";
toast.success("Cleared Quick Links.");
}
function addQlBox() {
saveButton = "Save";
const updatedQl = [...$ql, ""];
$ql = updatedQl;
ql.set(updatedQl);
}
function handleClick(event: any) {
// Handle the click event here
console.log("Island Clicked");
// You can access the `variables` passed to the Island component here if needed
}
</script> </script>
<Island on:click={handleClick} {variables}> <Island on:click={handleClick} {variables}>
{#if $ql.length === 0} {#if $ql.length === 0}
<p>Click the + button to add links</p> <p>Click the + button to add links</p>
{/if} {/if}
<div id="buttons" class="buttons"> <div id="buttons" class="buttons">
<p>Quick links can be CRS Codes or Headcodes</p> <p>Quick links can be CRS Codes or Headcodes</p>
{#each qlData as link} {#each qlData as link}
<input class="qlInput" type="text" value={link} /> <input class="qlInput" type="text" value={link} />
{/each} {/each}
<button on:click={addQlBox} id="qlAdd">+</button> <button on:click={addQlBox} id="qlAdd">+</button>
</div> </div>
<button on:click={save}>{@html saveButton}</button> <button on:click={saveQl}>{@html saveButton}</button>
<button on:click={clearQl}>Clear</button> <button on:click={clearQl}>Clear</button>
</Island> </Island>
<style> <style>
p { p {
margin-bottom: 0; margin-bottom: 0;
} }
#qlAdd { #qlAdd {
width: 40px; width: 40px;
} }
.buttons { .buttons {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
width: 90%; width: 90%;
margin: auto; margin: auto;
padding-top: 5px; padding-top: 5px;
} }
input { input {
flex: 1; flex: 1;
width: 20%; width: 20%;
min-width: 50px; min-width: 50px;
margin: 5px; margin: 5px;
border: none; border: none;
border-radius: 20px; border-radius: 20px;
padding: 5px; padding: 5px;
font-family: urwgothic, "Lucida Sans", "Lucida Sans Regular", "Lucida Grande", "Lucida Sans Unicode", Geneva, Verdana, sans-serif; font-family: urwgothic, 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
font-size: 16px; font-size: 16px;
font-weight: 400; font-weight: 400;
text-decoration: none; text-decoration: none;
text-align: center; text-align: center;
text-transform: uppercase; text-transform: uppercase;
box-shadow: var(--box-shadow); box-shadow: var(--box-shadow);
} }
button { button {
width: 30%; width: 30%;
margin-bottom: 5px; margin-bottom: 5px;
margin-top: 10px; margin-top: 10px;
border: none; border: none;
border-radius: 20px; border-radius: 20px;
padding: 5px; padding: 5px;
font-family: urwgothic, "Lucida Sans", "Lucida Sans Regular", "Lucida Grande", "Lucida Sans Unicode", Geneva, Verdana, sans-serif; font-family: urwgothic, 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
font-size: 16px; font-size: 16px;
font-weight: 400; font-weight: 400;
background-color: var(--island-button-color); background-color: var(--island-button-color);
color: var(--island-link-color); color: var(--island-link-color);
box-shadow: var(--box-shadow); box-shadow: var(--box-shadow);
} }
</style> </style>

View File

@ -0,0 +1,31 @@
<script lang="ts">
import Island from '$lib/islands/island.svelte';
interface resultObj {
results: boolean;
title: string;
resultLines: string[];
}
export let resultObject: resultObj = {
results: true,
title: '',
resultLines: []
};
let variables = {
title: resultObject.title
};
</script>
<Island {variables}>
{#each resultObject.resultLines as line}
<p>{line}</p>
{/each}
</Island>
<style>
p {
color: var(--island-text-color);
}
</style>

View File

@ -1,106 +0,0 @@
<script>
import { IconAlertCircle } from "@tabler/icons-svelte";
import { fly } from "svelte/transition";
export let alerts = [];
$: uniqueAlerts = [...new Set(alerts)];
let displayAlerts = false;
async function alertsToggle() {
displayAlerts = !displayAlerts;
}
function numberAsWord(number = 0) {
const words = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"];
let word = words[number];
if (word) {
return word;
}
return number;
}
</script>
<div id="bar" on:click={alertsToggle} on:keypress={alertsToggle}>
<span class="image"><IconAlertCircle /></span>
{#if uniqueAlerts.length == 1}
<p id="bartext">There is one active alert</p>
{:else}
<p id="bartext">
There are {numberAsWord(uniqueAlerts.length)} active alerts
</p>
{/if}
<p id="arrow" class:displayAlerts>V</p>
</div>
{#if displayAlerts}
<div id="alerts" in:fly={{ y: -200, duration: 500 }} out:fly={{ y: -200, duration: 800 }}>
{#each uniqueAlerts as msg}
<p class="alert">{@html msg}</p>
{/each}
</div>
{/if}
<style>
#bar {
position: relative;
margin-top: 0;
padding: 0;
width: 100%;
height: 40px;
background-color: var(--main-alert-color);
display: flex;
justify-content: space-between;
align-items: center;
z-index: 2;
}
.image {
margin-left: 15px;
margin-top: 4px;
}
#bartext {
color: white;
margin: auto;
font-weight: 600;
margin: 0 0 0 0;
padding: 0;
}
#arrow {
color: white;
font-family: Arial, Helvetica, sans-serif;
font-weight: 900;
border: none;
margin-right: 15px;
background-color: transparent;
transition-duration: 500ms;
transition-delay: 00ms;
}
#arrow:focus {
background-color: transparent;
}
#alerts {
position: absolute;
background-color: var(--main-alert-color);
opacity: 0.9;
width: 100%;
max-height: 80vh;
overflow-y: auto;
overflow-x: clip;
left: 0;
top: 89px;
z-index: 1;
}
.alert {
color: white;
text-align: center;
width: 80%;
margin: auto;
margin-top: 10px;
margin-bottom: 10px;
font-weight: 600;
}
.displayAlerts {
transition-duration: 500ms;
transition-delay: 400ms;
transform: rotate(180deg);
}
</style>

View File

@ -0,0 +1,118 @@
<script>
import { fly } from 'svelte/transition';
export let alerts = [];
$: uniqueAlerts = [...new Set(alerts)];
let displayAlerts = false;
async function alertsToggle() {
displayAlerts = !displayAlerts;
}
function numberAsWord(number) {
const words = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'];
let word = words[number];
if (word) {
return word;
}
return number;
}
</script>
<div id="block"><!--Prevent content slipping underneath the bar--></div>
<div id="bar" on:click={alertsToggle} on:keypress={alertsToggle}>
<img src="/images/navigation/alert.svg" alt="" />
{#if uniqueAlerts.length == 1}
<p id="bartext">There is one active alert</p>
{:else if uniqueAlerts.length > 1}
<p id="bartext">
There are {numberAsWord(uniqueAlerts.length)} active alerts
</p>
{:else}
<p id="bartext">There are no active alerts</p>
{/if}
<p id="arrow" class:displayAlerts>V</p>
</div>
{#if displayAlerts}
<div id="alerts" in:fly={{ y: -200, duration: 500 }} out:fly={{ y: -200, duration: 800 }}>
{#each uniqueAlerts as msg}
<p class="alert">{@html msg}</p>
{/each}
</div>
{/if}
<style>
#block {
height: 40px;
}
#bar {
width: 100%;
height: 40px;
background-color: var(--main-alert-color);
opacity: 1;
position: fixed;
width: 100%;
top: 50px;
left: 0px;
z-index: 10;
}
img {
height: 25px;
width: 25px;
position: absolute;
left: 8px;
top: 8px;
margin: 0;
padding: 0;
}
#bartext {
color: white;
margin: auto;
font-weight: 600;
margin-top: 8px;
margin-bottom: 0px;
padding: 0px;
}
#arrow {
color: white;
font-family: Arial, Helvetica, sans-serif;
font-weight: 900;
position: absolute;
margin-top: 0;
right: 15px;
top: 11px;
border: none;
background-color: transparent;
transition-duration: 500ms;
transition-delay: 00ms;
}
#arrow:focus {
background-color: transparent;
}
#alerts {
position: fixed;
background-color: var(--main-alert-color);
opacity: 0.9;
width: 100%;
max-height: 80vh;
overflow-y: auto;
overflow-x: clip;
left: 0;
top: 89px;
}
.alert {
color: white;
text-align: center;
width: 80%;
margin: auto;
margin-top: 10px;
margin-bottom: 10px;
font-weight: 600;
}
.displayAlerts {
transition-duration: 500ms;
transition-delay: 400ms;
transform: rotate(180deg);
}
</style>

View File

@ -1,488 +1,486 @@
<script> <script>
export let station = ""; export let station = '';
export let title = "Loading..."; export let title = 'Loading...';
import { onMount } from "svelte"; import { onMount } from 'svelte';
import Loading from "$lib/navigation/loading.svelte"; import Loading from '$lib/navigation/loading.svelte';
import OverlayIsland from "$lib/islands/overlay-island.svelte"; import OverlayIsland from '$lib/islands/overlay-island.svelte';
import AlertBar from "$lib/ldb/common/nrcc/alert-bar.svelte"; import AlertBar from '$lib/ldb/nrcc/alert-bar.svelte';
import Island from "$lib/islands/island.svelte"; import Island from '$lib/islands/island.svelte';
import { getApiUrl } from "$lib/scripts/upstream"; import { getApiUrl } from '$lib/scripts/upstream';
import TimeBar from "$lib/navigation/TimeBar.svelte";
import { IconBus, IconSailboat } from "@tabler/icons-svelte";
import toast from "svelte-french-toast";
let requestedStation; let requestedStation;
$: requestedStation = station; $: requestedStation = station;
let jsonData = null; let jsonData = null;
let services = []; let services = [];
let busServices = []; let busServices = [];
let ferryServices = []; let ferryServices = [];
let dataAge = null; let dataAge = null;
let isLoading = true; let isLoading = true;
let dataExists = false; let dataExists = false;
let alerts = []; let alerts = [];
let serviceDetail; let serviceDetail;
$: { $: {
if (jsonData === null && requestedStation) { if (jsonData === null && requestedStation) {
fetchData(); fetchData();
}
if (jsonData?.GetStationBoardResult?.generatedAt) {
dataAge = new Date(jsonData.GetStationBoardResult.generatedAt);
}
if (jsonData?.GetStationBoardResult?.trainServices?.service) {
services = jsonData.GetStationBoardResult.trainServices.service;
} else {
services = [];
}
if (jsonData?.GetStationBoardResult?.busServices?.service) {
busServices = jsonData.GetStationBoardResult.busServices.service;
}
if (jsonData?.GetStationBoardResult?.ferryServices?.service) {
ferryServices = jsonData.GetStationBoardResult.ferryServices.service;
}
if (jsonData?.GetStationBoardResult?.locationName) {
title = jsonData.GetStationBoardResult.locationName;
} else {
title = requestedStation.toUpperCase();
}
} }
async function fetchData() { if (jsonData?.GetStationBoardResult?.generatedAt) {
dataExists = true; dataAge = new Date(jsonData.GetStationBoardResult.generatedAt);
isLoading = true; // Set loading state
try {
console.log(`Requested Station: ${requestedStation}`);
const data = await fetch(`${getApiUrl()}/api/v2/live/station/${requestedStation}/public`);
jsonData = await data.json();
} catch (error) {
console.error("Error fetching data:", error);
dataExists = false;
title = "Not Found";
} finally {
isLoading = false; // Clear loading state
}
prepareNrcc();
} }
function parseTime(string) { if (jsonData?.GetStationBoardResult?.trainServices?.service) {
let output; services = jsonData.GetStationBoardResult.trainServices.service;
let change; } else {
switch (string) { services = [];
case "Delayed":
output = "LATE";
change = "changed";
break;
case "Cancelled":
output = "CANC";
change = "cancelled";
break;
case "On Time":
case "On time":
output = "RT";
change = "";
break;
case "":
output = "-";
change = "";
break;
case undefined:
output = "-";
change = "";
break;
case "No report":
output = "-";
change = "";
break;
case "undefined":
output = false;
change = "";
break;
default:
output = string;
change = "changed";
}
return { data: output, changed: change };
} }
async function loadService(sid) { if (jsonData?.GetStationBoardResult?.busServices?.service) {
for (const service of services) { busServices = jsonData.GetStationBoardResult.busServices.service;
if (service.serviceID == sid) {
serviceDetail = service;
}
}
} }
async function loadBusService(sid) { if (jsonData?.GetStationBoardResult?.ferryServices?.service) {
for (const service of busServices) { ferryServices = jsonData.GetStationBoardResult.ferryServices.service;
if (service.serviceID == sid) {
serviceDetail = service;
}
}
} }
async function closeService() { if (jsonData?.GetStationBoardResult?.locationName) {
serviceDetail = null; title = jsonData.GetStationBoardResult.locationName;
} else {
title = requestedStation.toUpperCase();
} }
}
async function prepareNrcc() { async function fetchData() {
if (jsonData?.GetStationBoardResult?.nrccMessages?.message) { dataExists = true;
const nrcc = jsonData.GetStationBoardResult.nrccMessages.message; isLoading = true; // Set loading state
if (Array.isArray(nrcc)) { try {
alerts = nrcc; console.log(`Requested Station: ${requestedStation}`);
return; const data = await fetch(`${getApiUrl()}/api/v2/live/station/${requestedStation}/public`);
} jsonData = await data.json();
alerts.push(nrcc); } catch (error) {
return; console.error('Error fetching data:', error);
} dataExists = false;
title = 'Not Found';
} finally {
isLoading = false; // Clear loading state
} }
prepareNrcc();
}
onMount(() => { function parseTime(string) {
toast("Register for more detailed departure boards") let output;
if (requestedStation && jsonData === null) { let change;
fetchData(); switch (string) {
} case 'Delayed':
}); output = 'LATE';
change = 'changed';
break;
case 'Cancelled':
output = 'CANC';
change = 'cancelled';
break;
case 'On Time':
case 'On time':
output = 'RT';
change = '';
break;
case '':
output = '-';
change = '';
break;
case undefined:
output = '-';
change = '';
break;
case 'No report':
output = '-';
change = '';
break;
case 'undefined':
output = false;
change = '';
break;
default:
output = string;
change = 'changed';
}
return { data: output, changed: change };
}
async function loadService(sid) {
for (const service of services) {
if (service.serviceID == sid) {
serviceDetail = service;
}
}
}
async function loadBusService(sid) {
for (const service of busServices) {
if (service.serviceID == sid) {
serviceDetail = service;
}
}
}
async function closeService() {
serviceDetail = null;
}
async function prepareNrcc() {
if (jsonData?.GetStationBoardResult?.nrccMessages?.message) {
const nrcc = jsonData.GetStationBoardResult.nrccMessages.message;
if (Array.isArray(nrcc)) {
alerts = nrcc;
return;
}
alerts.push(nrcc);
return;
}
}
onMount(() => {
if (requestedStation && jsonData === null) {
fetchData();
}
});
</script> </script>
{#if alerts.length} {#if alerts.length}
<AlertBar {alerts} /> <AlertBar {alerts} />
{/if} {/if}
<TimeBar updatedTime={dataAge} />
{#if isLoading} {#if isLoading}
<Loading /> <Loading />
{:else if dataAge} {:else if dataAge}
{#if services.length} <p id="timestamp">Updated: {dataAge.toLocaleTimeString()}</p>
<table class="ldbTable"> {#if services.length}
<tr> <table class="ldbTable">
<th class="from">From</th> <tr>
<th class="to">To</th> <th class="from">From</th>
<th class="plat">Plat.</th> <th class="to">To</th>
<th class="time">Sch Arr.</th> <th class="plat">Plat.</th>
<th class="time">Exp Arr.</th> <th class="time">Sch Arr.</th>
<th class="time">Sch Dep.</th> <th class="time">Exp Arr.</th>
<th class="time">Exp Dep.</th> <th class="time">Sch Dep.</th>
</tr> <th class="time">Exp Dep.</th>
{#each services as service} </tr>
<tr> {#each services as service}
<td class="origdest from" on:click={loadService(service.serviceID)} on:keypress={loadService(service.serviceID)}> <tr>
{#if Array.isArray(service.origin?.location)} <td class="origdest from" on:click={loadService(service.serviceID)} on:keypress={loadService(service.serviceID)}>
{service.origin.location[0]["locationName"] + " & " + service.origin.location[1]["locationName"]} {#if Array.isArray(service.origin?.location)}
{:else} {service.origin.location[0]['locationName'] + ' & ' + service.origin.location[1]['locationName']}
{service.origin?.location?.locationName || ""} {:else}
{/if} {service.origin?.location?.locationName || ''}
</td> {/if}
<td class="origdest to" on:click={loadService(service.serviceID)} on:keypress={loadService(service.serviceID)}> </td>
{#if Array.isArray(service.destination?.location)} <td class="origdest to" on:click={loadService(service.serviceID)} on:keypress={loadService(service.serviceID)}>
{service.destination.location[0]["locationName"] + " & " + service.destination.location[0]["locationName"]} {#if Array.isArray(service.destination?.location)}
{:else} {service.destination.location[0]['locationName'] + ' & ' + service.destination.location[0]['locationName']}
{service.destination?.location?.locationName || ""} {:else}
{/if} {service.destination?.location?.locationName || ''}
</td> {/if}
<td class="plat">{service.platform || "-"}</td> </td>
<td class="time">{parseTime(service.sta).data}</td> <td class="plat">{service.platform || '-'}</td>
<td class="time {parseTime(service.eta).changed}">{parseTime(service.eta).data}</td> <td class="time">{parseTime(service.sta).data}</td>
<td class="time">{parseTime(service.std).data}</td> <td class="time {parseTime(service.eta).changed}">{parseTime(service.eta).data}</td>
<td class="time {parseTime(service.etd).changed}">{parseTime(service.etd).data}</td> <td class="time">{parseTime(service.std).data}</td>
</tr> <td class="time {parseTime(service.etd).changed}">{parseTime(service.etd).data}</td>
</tr>
<tr <tr
><td colspan="7"> ><td colspan="7">
<p class="service-detail"> <p class="service-detail">
A {service.operator || "Unknown"} service A {service.operator || 'Unknown'} service
{#if service["length"]} {#if service['length']}
with {service["length"] || "some"} coaches with {service['length'] || 'some'} coaches
{/if} {/if}
</p> </p>
{#if service.delayReason} {#if service.delayReason}
<p class="service-detail">{service.delayReason}</p> <p class="service-detail">{service.delayReason}</p>
{/if} {/if}
{#if service.cancelReason} {#if service.cancelReason}
<p class="service-detail">{service.cancelReason}</p> <p class="service-detail">{service.cancelReason}</p>
{/if} {/if}
</td></tr </td></tr
> >
{/each} {/each}
</table> </table>
{:else} {:else}
<p class="table-head-text">No Scheduled Train Services</p> <p class="table-head-text">No Scheduled Train Services</p>
{/if} {/if}
{#if busServices.length} {#if busServices.length}
<br /> <br />
<IconBus /><br /> <img class="transport-mode" src="/images/transport-modes/bus.svg" alt="Bus services" /><br />
<span class="table-head-text">Bus Services</span> <span class="table-head-text">Bus Services</span>
<table class="ldbTable"> <table class="ldbTable">
<tr> <tr>
<th class="from">From</th> <th class="from">From</th>
<th class="to">To</th> <th class="to">To</th>
<th class="time">Sch Arr.</th> <th class="time">Sch Arr.</th>
<th class="time">Exp Arr.</th> <th class="time">Exp Arr.</th>
<th class="time">Sch Dep.</th> <th class="time">Sch Dep.</th>
<th class="time">Exp Dep.</th> <th class="time">Exp Dep.</th>
</tr> </tr>
{#each busServices as service} {#each busServices as service}
<tr> <tr>
<td class="origdest from" on:click={loadBusService(service.serviceID)} on:keypress={loadBusService(service.serviceID)} <td class="origdest from" on:click={loadBusService(service.serviceID)} on:keypress={loadBusService(service.serviceID)}>{service.origin?.location?.locationName || ''}</td>
>{service.origin?.location?.locationName || ""}</td <td class="origdest to" on:click={loadBusService(service.serviceID)} on:keypress={loadBusService(service.serviceID)}
> >{service.destination?.location?.locationName || ''}</td
<td class="origdest to" on:click={loadBusService(service.serviceID)} on:keypress={loadBusService(service.serviceID)} >
>{service.destination?.location?.locationName || ""}</td <td class="time">{parseTime(service.sta).data}</td>
> <td class="time {parseTime(service.eta).changed}">{parseTime(service.eta).data}</td>
<td class="time">{parseTime(service.sta).data}</td> <td class="time">{parseTime(service.std).data}</td>
<td class="time {parseTime(service.eta).changed}">{parseTime(service.eta).data}</td> <td class="time {parseTime(service.etd).changed}">{parseTime(service.etd).data}</td>
<td class="time">{parseTime(service.std).data}</td> </tr>
<td class="time {parseTime(service.etd).changed}">{parseTime(service.etd).data}</td>
</tr>
<tr <tr
><td colspan="7"> ><td colspan="7">
<p class="service-detail"> <p class="service-detail">
A {service.operator || "Unknown"} service A {service.operator || 'Unknown'} service
</p> </p>
{#if service.delayReason} {#if service.delayReason}
<p class="service-detail">{service.delayReason}</p> <p class="service-detail">{service.delayReason}</p>
{/if} {/if}
{#if service.cancelReason} {#if service.cancelReason}
<p class="service-detail">{service.cancelReason}</p> <p class="service-detail">{service.cancelReason}</p>
{/if} {/if}
</td></tr </td></tr
> >
{/each} {/each}
</table> </table>
{/if} {/if}
{#if ferryServices.length} {#if ferryServices.length}
<br /> <br />
<IconSailboat /><br /> <img class="transport-mode" src="/images/transport-modes/ferry.svg" alt="Bus services" /><br />
<span class="table-head-text">Ferry Services</span> <span class="table-head-text">Ferry Services</span>
<table class="ldbTable"> <table class="ldbTable">
<tr> <tr>
<th class="from">From</th> <th class="from">From</th>
<th class="to">To</th> <th class="to">To</th>
<th class="time">Sch Arr.</th> <th class="time">Sch Arr.</th>
<th class="time">Exp Arr.</th> <th class="time">Exp Arr.</th>
<th class="time">Sch Dep.</th> <th class="time">Sch Dep.</th>
<th class="time">Exp Dep.</th> <th class="time">Exp Dep.</th>
</tr> </tr>
{#each ferryServices as service} {#each ferryServices as service}
<tr> <tr>
<td class="origdest from">{service.origin?.location?.locationName || ""}</td> <td class="origdest from">{service.origin?.location?.locationName || ''}</td>
<td class="origdest to">{service.destination?.location?.locationName || ""}</td> <td class="origdest to">{service.destination?.location?.locationName || ''}</td>
<td class="time">{parseTime(service.sta).data}</td> <td class="time">{parseTime(service.sta).data}</td>
<td class="time {parseTime(service.eta).changed}">{parseTime(service.eta).data}</td> <td class="time {parseTime(service.eta).changed}">{parseTime(service.eta).data}</td>
<td class="time">{parseTime(service.std).data}</td> <td class="time">{parseTime(service.std).data}</td>
<td class="time {parseTime(service.etd).changed}">{parseTime(service.etd).data}</td> <td class="time {parseTime(service.etd).changed}">{parseTime(service.etd).data}</td>
</tr> </tr>
<tr <tr
><td colspan="7"> ><td colspan="7">
{#if service.delayReason} {#if service.delayReason}
<p class="service-detail">{service.delayReason}</p> <p class="service-detail">{service.delayReason}</p>
{/if} {/if}
{#if service.cancelReason} {#if service.cancelReason}
<p class="service-detail">{service.cancelReason}</p> <p class="service-detail">{service.cancelReason}</p>
{/if} {/if}
</td></tr </td></tr
> >
{/each} {/each}
</table> </table>
{/if} {/if}
{:else} {:else}
<Island> <Island>
<p style="font-weight:600">Unable to load data</p> <p style="font-weight:600">Unable to load data</p>
</Island> </Island>
{/if} {/if}
{#if serviceDetail} {#if serviceDetail}
<OverlayIsland> <OverlayIsland>
<div id="detailBox"> <div id="detailBox">
<h6>Service Detail</h6> <h6>Service Detail</h6>
<button type="button" id="closeService" on:click={closeService}>X</button> <button type="button" id="closeService" on:click={closeService}>X</button>
<table id="detailTable"> <table id="detailTable">
<tr> <tr>
<th>Location</th> <th>Location</th>
<th>Sch</th> <th>Sch</th>
<th>Exp</th> <th>Exp</th>
</tr> </tr>
{#if serviceDetail?.previousCallingPoints?.callingPointList?.callingPoint} {#if serviceDetail?.previousCallingPoints?.callingPointList?.callingPoint}
{#if Array.isArray(serviceDetail?.previousCallingPoints?.callingPointList?.callingPoint)} {#if Array.isArray(serviceDetail?.previousCallingPoints?.callingPointList?.callingPoint)}
{#each serviceDetail.previousCallingPoints.callingPointList.callingPoint as prevPoint} {#each serviceDetail.previousCallingPoints.callingPointList.callingPoint as prevPoint}
<tr> <tr>
<td>{prevPoint.locationName}</td> <td>{prevPoint.locationName}</td>
<td>{prevPoint.st}</td> <td>{prevPoint.st}</td>
<td class="time {parseTime(prevPoint.at || prevPoint.et).changed}">{parseTime(prevPoint.at || prevPoint.et).data}</td> <td class="time {parseTime(prevPoint.at || prevPoint.et).changed}">{parseTime(prevPoint.at || prevPoint.et).data}</td>
</tr> </tr>
{/each} {/each}
{:else} {:else}
<tr> <tr>
<td>{serviceDetail.previousCallingPoints.callingPointList.callingPoint.locationName}</td> <td>{serviceDetail.previousCallingPoints.callingPointList.callingPoint.locationName}</td>
<td>{serviceDetail.previousCallingPoints.callingPointList.callingPoint.st}</td> <td>{serviceDetail.previousCallingPoints.callingPointList.callingPoint.st}</td>
<td <td
class="time {parseTime( class="time {parseTime(serviceDetail.previousCallingPoints.callingPointList.callingPoint.at || serviceDetail.previousCallingPoints.callingPointList.callingPoint.et)
serviceDetail.previousCallingPoints.callingPointList.callingPoint.at || serviceDetail.previousCallingPoints.callingPointList.callingPoint.et .changed}"
).changed}" >{parseTime(serviceDetail.previousCallingPoints.callingPointList.callingPoint.at || serviceDetail.previousCallingPoints.callingPointList.callingPoint.et).data}</td
>{parseTime( >
serviceDetail.previousCallingPoints.callingPointList.callingPoint.at || serviceDetail.previousCallingPoints.callingPointList.callingPoint.et </tr>
).data}</td {/if}
> {/if}
</tr> <tr class="thisStop">
{/if} <td>{title}</td>
{/if} <td>{serviceDetail.std || serviceDetail.sta}</td>
<tr class="thisStop"> <td class="time {parseTime(serviceDetail.etd || serviceDetail.eta).changed}">{parseTime(serviceDetail.etd || serviceDetail.eta).data}</td>
<td>{title}</td> </tr>
<td>{serviceDetail.std || serviceDetail.sta}</td> {#if serviceDetail?.subsequentCallingPoints?.callingPointList?.callingPoint}
<td class="time {parseTime(serviceDetail.etd || serviceDetail.eta).changed}">{parseTime(serviceDetail.etd || serviceDetail.eta).data}</td> {#if Array.isArray(serviceDetail?.subsequentCallingPoints?.callingPointList?.callingPoint)}
</tr> {#each serviceDetail.subsequentCallingPoints.callingPointList.callingPoint as nextPoint}
{#if serviceDetail?.subsequentCallingPoints?.callingPointList?.callingPoint} <tr>
{#if Array.isArray(serviceDetail?.subsequentCallingPoints?.callingPointList?.callingPoint)} <td>{nextPoint.locationName}</td>
{#each serviceDetail.subsequentCallingPoints.callingPointList.callingPoint as nextPoint} <td>{nextPoint.st}</td>
<tr> <td class="time {parseTime(nextPoint.et).changed}">{parseTime(nextPoint.et).data}</td>
<td>{nextPoint.locationName}</td> </tr>
<td>{nextPoint.st}</td> {/each}
<td class="time {parseTime(nextPoint.et).changed}">{parseTime(nextPoint.et).data}</td> {:else}
</tr> <tr class="detailRow">
{/each} <td>{serviceDetail.subsequentCallingPoints.callingPointList.callingPoint.locationName}</td>
{:else} <td>{serviceDetail.subsequentCallingPoints.callingPointList.callingPoint.st}</td>
<tr class="detailRow"> <td class="time {parseTime(serviceDetail.subsequentCallingPoints.callingPointList.callingPoint.et).changed}"
<td>{serviceDetail.subsequentCallingPoints.callingPointList.callingPoint.locationName}</td> >{parseTime(serviceDetail.subsequentCallingPoints.callingPointList.callingPoint.et).data}</td
<td>{serviceDetail.subsequentCallingPoints.callingPointList.callingPoint.st}</td> >
<td class="time {parseTime(serviceDetail.subsequentCallingPoints.callingPointList.callingPoint.et).changed}" </tr>
>{parseTime(serviceDetail.subsequentCallingPoints.callingPointList.callingPoint.et).data}</td {/if}
> {/if}
</tr> </table>
{/if} </div>
{/if} </OverlayIsland>
</table>
</div>
</OverlayIsland>
{/if} {/if}
<style> <style>
.ldbTable { #timestamp {
width: 100%; margin: auto;
min-width: 300px; text-align: left;
margin: auto; font-size: 14px;
padding-right: 2px; }
padding-left: 0px; .ldbTable {
color: white; width: 100%;
font-size: 13px; min-width: 300px;
margin: auto;
padding-right: 2px;
padding-left: 0px;
color: white;
font-size: 13px;
}
.service-detail {
color: cyan;
text-align: left;
font-size: 12px;
padding: 0;
margin: 0;
}
.transport-mode {
width: 30px;
}
.table-head-text {
color: white;
font-size: 14px;
}
@media (min-width: 800px) {
table {
font-size: 15px;
max-width: 850px;
} }
.service-detail { .service-detail {
color: cyan; font-size: 14px;
text-align: left;
font-size: 12px;
padding: 0;
margin: 0;
} }
.transport-mode { .transport-mode {
width: 30px; width: 50px;
}
#timestamp {
font-size: 16px;
}
}
@media (min-width: 1000px) {
table {
font-size: 17px;
}
.service-detail {
font-size: 16px;
} }
.table-head-text { .table-head-text {
color: white; font-size: 16px;
font-size: 14px;
} }
@media (min-width: 800px) { }
table { @media (min-width: 1600px) {
font-size: 15px; table {
max-width: 850px; font-size: 19px;
}
.service-detail {
font-size: 14px;
}
.transport-mode {
width: 50px;
}
} }
@media (min-width: 1000px) { .service-detail {
table { font-size: 18px;
font-size: 17px;
}
.service-detail {
font-size: 16px;
}
.table-head-text {
font-size: 16px;
}
}
@media (min-width: 1600px) {
table {
font-size: 19px;
}
.service-detail {
font-size: 18px;
}
}
.origdest {
color: yellow;
}
.from {
width: 25%;
text-align: left;
}
.to {
width: 25%;
text-align: left;
}
.plat {
width: 10%;
}
.time {
width: 10%;
}
.changed {
animation: pulse-change 1.5s linear infinite;
} }
}
.origdest {
color: yellow;
}
.from {
width: 25%;
text-align: left;
}
.to {
width: 25%;
text-align: left;
}
.plat {
width: 10%;
}
.time {
width: 10%;
}
.changed {
animation: pulse-change 1.5s linear infinite;
}
.cancelled { .cancelled {
animation: pulse-cancel 1.5s linear infinite; animation: pulse-cancel 1.5s linear infinite;
} }
@keyframes pulse-change { @keyframes pulse-change {
50% { 50% {
color: var(--main-warning-color); color: var(--main-warning-color);
}
} }
}
@keyframes pulse-cancel { @keyframes pulse-cancel {
50% { 50% {
color: var(--main-alert-color); color: var(--main-alert-color);
}
}
#detailBox {
width: 100%;
}
h6 {
position: absolute;
top: -25px;
left: 20px;
font-size: 18px;
}
#closeService {
position: absolute;
top: 10px;
right: 10px;
border: none;
border-radius: 60px;
width: 35px;
height: 35px;
background-color: var(--main-bg-color);
color: white;
font-weight: 700;
font-size: 16px;
}
#detailTable {
margin-top: 40px;
color: white;
font-size: 15px;
}
.thisStop {
color: yellow;
} }
}
#detailBox {
width: 100%;
}
h6 {
position: absolute;
top: -25px;
left: 20px;
font-size: 18px;
}
#closeService {
position: absolute;
top: 10px;
right: 10px;
border: none;
border-radius: 60px;
width: 35px;
height: 35px;
background-color: var(--main-bg-color);
color: white;
font-weight: 700;
font-size: 16px;
}
#detailTable {
margin-top: 40px;
color: white;
font-size: 15px;
}
.thisStop {
color: yellow;
}
</style> </style>

View File

@ -1,39 +1,39 @@
// Fetches StaffLDB Data, correctly formats DATE fields and returns the data // Fetches StaffLDB Data, correctly formats DATE fields and returns the data
import { getApiUrl } from "$lib/scripts/upstream"; import { getApiUrl } from '$lib/scripts/upstream';
import { uuid } from "$lib/stores/uuid"; import { uuid } from '$lib/stores/uuid';
import type { ApiResponse, StaffLdb } from "@owlboard/ts-types"; import type { ApiResponse, StaffLdb } from '@owlboard/ts-types';
// Fetch StaffLDB Data, and returns the data after hydration (convert date types etc.) // Fetch StaffLDB Data, and returns the data after hydration (convert date types etc.)
export async function fetchStaffLdb(station: string): Promise<ApiResponse<StaffLdb>> { export async function fetchStaffLdb(station: string): Promise<ApiResponse<StaffLdb>> {
const url = `${getApiUrl()}/api/v2/live/station/${station}/staff`; const url = `${getApiUrl()}/api/v2/live/station/${station}/staff`;
let uuid_value: string = ""; let uuid_value: string = '';
const unsubscribe = uuid.subscribe((value) => { const unsubscribe = uuid.subscribe((value) => {
uuid_value = value; uuid_value = value;
}); });
const fetchOpts = { const fetchOpts = {
method: "GET", method: 'GET',
headers: { headers: {
uuid: uuid_value, uuid: uuid_value
}, }
}; };
const res = await fetch(url, fetchOpts); const res = await fetch(url, fetchOpts);
unsubscribe(); unsubscribe();
const resJs = await res.json(); const resJs = await res.json();
return parseFormat(JSON.stringify(resJs)); return parseFormat(JSON.stringify(resJs));
} }
// Parse dates within the JSON response // Parse dates within the JSON response
function parseFormat(jsonString: any): ApiResponse<StaffLdb> { function parseFormat(jsonString: any): ApiResponse<StaffLdb> {
return JSON.parse(jsonString, (key, value) => { return JSON.parse(jsonString, (key, value) => {
if (typeof value === "string") { if (typeof value === 'string') {
const dateRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z$/; const dateRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z$/;
if (dateRegex.test(value)) { if (dateRegex.test(value)) {
return new Date(value); return new Date(value);
} }
} }
return value; return value;
}); });
} }

View File

@ -1,102 +1,89 @@
<script lang="ts"> <script lang="ts">
import TableGenerator from "./table/table-generator.svelte"; import TableGenerator from './table/table-generator.svelte';
import Loading from "$lib/navigation/loading.svelte"; import Loading from '$lib/navigation/loading.svelte';
import type { StaffLdb } from "@owlboard/ts-types"; import type { ApiResponse, StaffLdb } from '@owlboard/ts-types';
import { detailInit, defineDetail } from "./train-detail"; import { detailInit, defineDetail } from './train-detail';
import TrainDetail from "./train-detail.svelte"; import TrainDetail from './train-detail.svelte';
import { fetchStaffLdb } from "./fetch"; import { fetchStaffLdb } from './fetch';
import AlertBar from "../common/nrcc/alert-bar.svelte"; import AlertBar from '../nrcc/alert-bar.svelte';
import TimeBar from "$lib/navigation/TimeBar.svelte";
import { onMount } from "svelte";
import { IconBus, IconSailboat } from "@tabler/icons-svelte";
export let station: string; export let station: string;
export let title: string | undefined = "Loading..."; export let title: string | undefined = 'Loading...';
let errorDetail = { let errorDetail = {
code: "", code: '',
message: "", message: ''
}; };
let nrcc: string[] = []; let nrcc: string[] = [];
let detail = detailInit(); let detail = detailInit();
function hideDetail() { function hideDetail() {
detail = detailInit(); detail = detailInit();
} }
function showDetail(rid: string, uid: string, tid: string) { function showDetail(rid: string, uid: string, tid: string) {
detail = defineDetail(rid, uid, tid); detail = defineDetail(rid, uid, tid);
} }
console.log(`Station: ${station}`); console.log(`Station: ${station}`);
let updatedTime: Date; async function callFetch(station: string): Promise<StaffLdb> {
const data = await fetchStaffLdb(station);
async function callFetch(station: string): Promise<StaffLdb> { if (data.data) {
console.log("callFetch function called"); title = data.data.locationName;
const data = await fetchStaffLdb(station); if (data.data?.nrccMessages) {
if (data.data) { for (const msg of data.data.nrccMessages) {
title = data.data.locationName; nrcc.push(msg.xhtmlMessage);
if (data.data?.nrccMessages) {
for (const msg of data.data.nrccMessages) {
nrcc.push(msg.xhtmlMessage);
}
nrcc = nrcc; // Reassign to ensure Svelte reloads
}
if (data.data.generatedAt) {
updatedTime = new Date(data.data.generatedAt);
}
return data.data;
} }
errorDetail.code = data.obStatus.toString() || "UNKNOWN"; }
errorDetail.message = data.obMsg || "An unknown error occoured"; return data.data;
throw new Error("Unable to Fetch Data");
} }
errorDetail.code = data.obStatus.toString() || 'UNKNOWN';
onMount(async () => { errorDetail.message = data.obMsg || 'An unknown error occoured';
console.log("staff-ldb component mounted"); throw new Error('Unable to Fetch Data');
}); }
</script> </script>
{#if nrcc.length}
<AlertBar alerts={nrcc} />
{/if}
<TimeBar bind:updatedTime />
{#key detail} {#key detail}
{#if detail.show} {#if detail.show}
<TrainDetail {detail} close={hideDetail} /> <TrainDetail {detail} close={hideDetail} />
{/if} {/if}
{/key} {/key}
{#await callFetch(station)} {#await callFetch(station)}
<Loading /> <Loading />
{:then data} {:then data}
{#if data} {#if data}
{#if data.trainServices?.length} <p class="generatedTime">Updated: {new Date(data.generatedAt).toLocaleTimeString()}</p>
<TableGenerator services={data.trainServices} click={showDetail} /> {#if data.trainServices?.length}
{/if} <TableGenerator services={data.trainServices} click={showDetail} />
{#if data.busServices?.length}
<IconBus />
<br />
<span class="table-head-text">Bus Services</span>
<TableGenerator services={data.busServices} click={showDetail} />
{/if}
{#if data.ferryServices?.length}
<IconSailboat />
<br>
<span class="table-head-text">Ferry Services</span>
<TableGenerator services={data.ferryServices} click={showDetail} />
{/if}
{/if} {/if}
{#if data.busServices?.length}
<img class="transport-mode" src="/images/transport-modes/bus.svg" alt="Bus services" /><br />
<span class="table-head-text">Bus Services</span>
<TableGenerator services={data.busServices} click={showDetail} />
{/if}
{#if data.ferryServices?.length}
<img class="transport-mode" src="/images/transport-modes/ferry.svg" alt="Ferry services" /><br />
<span class="table-head-text">Ferry Services</span>
<TableGenerator services={data.ferryServices} click={showDetail} />
{/if}
{#if nrcc.length}
<AlertBar alerts={nrcc} />
{/if}
<!-- NRCC Alerts are not available -->
{/if}
{:catch} {:catch}
<h2>Error</h2> <h2>Error</h2>
<p>ERR-CODE: {errorDetail.code}</p> <p>ERR-CODE: {errorDetail.code}</p>
<p>Message:<br />{errorDetail.message}</p> <p>Message:<br />{errorDetail.message}</p>
{/await} {/await}
<style> <style>
.table-head-text { .transport-mode {
color: white; padding-top: 20px;
} height: 17px;
}
.table-head-text {
color: white;
}
</style> </style>

View File

@ -1,320 +1,319 @@
<script lang="ts"> <script lang="ts">
import Reason from "$lib/raw-fetchers/reason.svelte"; import Reason from '$lib/raw-fetchers/reason.svelte';
import { tocs as tocMap } from "$lib/stores/tocMap"; import { tocs as tocMap } from '$lib/stores/tocMap';
import type { TrainServices, ServiceLocation } from "@owlboard/ts-types"; import type { TrainServices, ServiceLocation } from '@owlboard/ts-types';
import { fade } from "svelte/transition";
export let services: TrainServices[]; export let services: TrainServices[];
export let click: Function; export let click: Function;
function detail(event: any, rid: string, uid: string, tid: string) { function detail(event: any, rid: string, uid: string, tid: string) {
const target = event.target; const target = event.target;
click(rid, uid, tid); click(rid, uid, tid);
}
async function formatLocations(locations: ServiceLocation[]): Promise<string> {
let tiplocs: string[] = [];
for (const location of locations) {
tiplocs.push(location.tiploc);
}
return tiplocs.join(' & ');
}
async function classGenerator(service: TrainServices) {
// This function needs updating next
let otherArr: string[] = [];
let arrArr: string[] = [];
let depArr: string[] = [];
let platArr: string[] = [];
if (service.isCancelled) {
otherArr.push('canc');
}
if (service.serviceIsSupressed) {
otherArr.push('nonPass');
}
if (service.platformIsHidden) {
platArr.push('nonPass');
} }
async function formatLocations(locations: ServiceLocation[]): Promise<string> { function checkLateEarly(originalTime: Date | undefined, comparedTime: Date | undefined, arr: string[]) {
let tiplocs: string[] = []; if (originalTime !== undefined && comparedTime instanceof Date) {
for (const location of locations) { if (originalTime < comparedTime) {
tiplocs.push(location.tiploc); arr.push('late');
} else if (originalTime > comparedTime) {
arr.push('early');
} }
return tiplocs.join(" & "); }
} }
async function classGenerator(service: TrainServices) { checkLateEarly(service.sta, service.eta, arrArr);
// This function needs updating next checkLateEarly(service.sta, service.ata, arrArr);
let otherArr: string[] = []; checkLateEarly(service.std, service.etd, depArr);
let arrArr: string[] = []; checkLateEarly(service.std, service.atd, depArr);
let depArr: string[] = [];
let platArr: string[] = [];
if (service.isCancelled) { return {
otherArr.push("canc"); other: otherArr.join(' '),
} arr: arrArr.join(' '),
if (service.serviceIsSupressed) { dep: depArr.join(' '),
otherArr.push("nonPass"); plat: platArr.join(' ')
} };
if (service.platformIsHidden) { }
platArr.push("nonPass");
}
function checkLateEarly(originalTime: Date | undefined, comparedTime: Date | undefined, arr: string[]) { function fmtTime(date: Date | string | undefined): string | false {
if (originalTime !== undefined && comparedTime instanceof Date) { if (typeof date === 'string') return date;
if (originalTime < comparedTime) { if (date instanceof Date) {
arr.push("late"); const hours = date.getHours().toString().padStart(2, '0');
} else if (originalTime > comparedTime) { const minutes = date.getMinutes().toString().padStart(2, '0');
arr.push("early"); return `${hours}:${minutes}`;
} } else {
} return false;
}
checkLateEarly(service.sta, service.eta, arrArr);
checkLateEarly(service.sta, service.ata, arrArr);
checkLateEarly(service.std, service.etd, depArr);
checkLateEarly(service.std, service.atd, depArr);
return {
other: otherArr.join(" "),
arr: arrArr.join(" "),
dep: depArr.join(" "),
plat: platArr.join(" "),
};
}
function fmtTime(date: Date | string | undefined): string | false {
if (typeof date === "string") return date;
if (date instanceof Date) {
const hours = date.getHours().toString().padStart(2, "0");
const minutes = date.getMinutes().toString().padStart(2, "0");
return `${hours}:${minutes}`;
} else {
return false;
}
} }
}
</script> </script>
<p class="smallScreen">Your display is too small to view this data</p> <p class="smallScreen">Your display is too small to view this data</p>
<p class="smallScreen">Try rotating your device</p> <p class="smallScreen">Try rotating your device</p>
<table in:fade={{ duration: 500 }}> <table>
<tr> <tr>
<th class="id">ID</th> <th class="id">ID</th>
<th class="from">From</th> <th class="from">From</th>
<th class="to">To</th> <th class="to">To</th>
<th class="plat">Plat</th> <th class="plat">Plat</th>
<th class="time arrsch">Sch</th> <th class="time arrsch">Sch</th>
<th class="time arrexp">Exp</th> <th class="time arrexp">Exp</th>
<th class="time depsch">Sch</th> <th class="time depsch">Sch</th>
<th class="time depexp">Exp</th> <th class="time depexp">Exp</th>
</tr>
<tr>
<th class="other" colspan="4" />
<th class="timepair" colspan="2">Arrival</th>
<th class="timepair" colspan="2">Departure</th>
</tr>
{#each services as service}
<tr
class="dataRow"
on:click={(event) => detail(event, service.rid, service.uid, service.trainid)}
on:keypress={(event) => detail(event, service.rid, service.uid, service.trainid)}
>
{#await classGenerator(service) then classes}
<!-- HEADCODE -->
<td class="id">{service.trainid}</td>
<!-- ORIGIN -->
<td class="loc from {classes.other}">{#await formatLocations(service.origin) then origin}{origin}{/await}</td>
<!-- DESTINATION -->
<td class="loc to {classes.other}">{#await formatLocations(service.destination) then dest}<span class="locName">{dest}</span>{/await}</td>
<!-- PLATFORM -->
<td class="plat {classes.other} {classes.plat}">{service.platform || '-'}</td>
<!-- SCHEDULED ARR -->
<td class="time schTime {classes.other}">{fmtTime(service?.sta) || '-'}</td>
<!-- EXPECTED/ACTUAL ARR -->
<td class="time {classes.other} {classes.arr}">{fmtTime(service.eta) || fmtTime(service.ata) || '-'}</td>
<!-- SCHEDULED DEP -->
<td class="time schTime {classes.other}">{fmtTime(service.std) || '-'}</td>
<!-- EXPECTED/ACTUAL DEP -->
<td class="time {classes.other} {classes.dep}">{fmtTime(service.etd) || fmtTime(service.atd) || '-'}</td>
{/await}
</tr> </tr>
<tr> <tr>
<th class="other" colspan="4" /> <td colspan="1" />
<th class="timepair" colspan="2">Arrival</th> <td class="tableTxt" colspan="7">
<th class="timepair" colspan="2">Departure</th> {#if service.destination?.[0] && service.destination[0].via}<span class="via">{service.destination[0].via}</span><br />{/if}
{tocMap.get(service.operatorCode.toLowerCase()) || service.operatorCode}
{#if service.length} | {service.length} carriages{/if}
{#if service.delayReason}
<br />
<span class="delayTxt">
<Reason type={'delay'} code={service.delayReason} />
</span>
{/if}
{#if service.cancelReason}
<br />
<span class="cancTxt">
<Reason type={'cancel'} code={service.cancelReason} />
</span>
{/if}
</td>
</tr> </tr>
{#each services as service} {/each}
<tr
class="dataRow"
on:click={(event) => detail(event, service.rid, service.uid, service.trainid)}
on:keypress={(event) => detail(event, service.rid, service.uid, service.trainid)}
>
{#await classGenerator(service) then classes}
<!-- HEADCODE -->
<td class="id">{service.trainid}</td>
<!-- ORIGIN -->
<td class="loc from {classes.other}">{#await formatLocations(service.origin) then origin}{origin}{/await}</td>
<!-- DESTINATION -->
<td class="loc to {classes.other}">{#await formatLocations(service.destination) then dest}<span class="locName">{dest}</span>{/await}</td>
<!-- PLATFORM -->
<td class="plat {classes.other} {classes.plat}">{service.platform || "-"}</td>
<!-- SCHEDULED ARR -->
<td class="time schTime {classes.other}">{fmtTime(service?.sta) || "-"}</td>
<!-- EXPECTED/ACTUAL ARR -->
<td class="time {classes.other} {classes.arr}">{fmtTime(service.eta) || fmtTime(service.ata) || "-"}</td>
<!-- SCHEDULED DEP -->
<td class="time schTime {classes.other}">{fmtTime(service.std) || "-"}</td>
<!-- EXPECTED/ACTUAL DEP -->
<td class="time {classes.other} {classes.dep}">{fmtTime(service.etd) || fmtTime(service.atd) || "-"}</td>
{/await}
</tr>
<tr>
<td colspan="1" />
<td class="tableTxt" colspan="7">
{#if service.destination?.[0] && service.destination[0].via}<span class="via">{service.destination[0].via}</span><br />{/if}
{tocMap.get(service.operatorCode.toLowerCase()) || service.operatorCode}
{#if service.length} | {service.length} carriages{/if}
{#if service.delayReason}
<br />
<span class="delayTxt">
<Reason type={"delay"} code={service.delayReason} />
</span>
{/if}
{#if service.cancelReason}
<br />
<span class="cancTxt">
<Reason type={"cancel"} code={service.cancelReason} />
</span>
{/if}
</td>
</tr>
{/each}
</table> </table>
<style> <style>
table { table {
table-layout: fixed; table-layout: fixed;
width: 100%; width: 100%;
max-width: 875px; max-width: 875px;
margin: auto; margin: auto;
padding: 0px; padding: 0px;
color: white; color: white;
} }
th {
font-size: 12px;
margin: 0px;
}
.dataRow {
font-family: ubuntu, monospace;
vertical-align: top;
cursor: pointer;
font-size: 16px;
line-height: 1;
padding: 0;
margin: 0;
}
/* Table Columns */
.id {
width: 8%;
}
.from {
width: 14%;
}
.to {
width: 14%;
}
.plat {
width: 6%;
}
.time {
width: 9%;
}
td.id {
color: lightblue;
text-align: left;
padding-left: 2px;
}
td.from,
td.to {
color: yellow;
}
td.to {
text-align: right;
}
td.from,
th.from {
text-align: left;
}
td.time {
font-size: 15px;
vertical-align: top;
}
.tableTxt {
text-align: left;
padding-left: 2px;
color: var(--secondary-text-color);
vertical-align: top;
font-size: 12px;
padding-bottom: 10px;
}
.delayTxt {
color: var(--main-warning-color);
}
.cancTxt {
color: var(--main-alert-color);
}
.via {
color: yellow;
padding-left: 0px;
}
/* Handle small screens */
.smallScreen {
display: none;
margin: 20px;
}
@media screen and (max-width: 335px) {
th { th {
font-size: 12px; font-size: 10px;
margin: 0px;
} }
.dataRow { .dataRow {
font-family: ubuntu, monospace; font-size: 12px;
vertical-align: top;
cursor: pointer;
font-size: 16px;
line-height: 1;
padding: 0;
margin: 0;
}
/* Table Columns */
.id {
width: 8%;
}
.from {
width: 14%;
}
.to {
width: 14%;
}
.plat {
width: 6%;
}
.time {
width: 9%;
}
td.id {
color: lightblue;
text-align: left;
padding-left: 2px;
}
td.from,
td.to {
color: yellow;
}
td.to {
text-align: right;
}
td.from,
th.from {
text-align: left;
} }
td.time { td.time {
font-size: 15px; font-size: 12px;
vertical-align: top;
} }
.tableTxt { .tableTxt {
text-align: left; font-size: 10px;
padding-left: 2px;
color: var(--secondary-text-color);
vertical-align: top;
font-size: 12px;
padding-bottom: 10px;
} }
.delayTxt { }
color: var(--main-warning-color); @media screen and (max-width: 279px) {
table {
display: none;
} }
.cancTxt {
color: var(--main-alert-color);
}
.via {
color: yellow;
padding-left: 0px;
}
/* Handle small screens */
.smallScreen { .smallScreen {
display: none; display: block;
margin: 20px;
}
@media screen and (max-width: 335px) {
th {
font-size: 10px;
}
.dataRow {
font-size: 12px;
}
td.time {
font-size: 12px;
}
.tableTxt {
font-size: 10px;
}
}
@media screen and (max-width: 279px) {
table {
display: none;
}
.smallScreen {
display: block;
}
} }
}
/* Handle Large Screens */ /* Handle Large Screens */
@media screen and (min-width: 375px) { @media screen and (min-width: 375px) {
.dataRow { .dataRow {
font-size: 18px; font-size: 18px;
}
td.time {
font-size: 16px;
}
} }
@media screen and (min-width: 450px) { td.time {
.dataRow { font-size: 16px;
font-size: 20px;
}
td.time {
font-size: 19px;
}
.tableTxt {
font-size: 14px;
}
td.to,
td.from,
th.to,
th.from {
text-align: left;
}
} }
}
@media screen and (min-width: 450px) {
.dataRow {
font-size: 20px;
}
td.time {
font-size: 19px;
}
.tableTxt {
font-size: 14px;
}
td.to,
td.from,
th.to,
th.from {
text-align: left;
}
}
/* Conditional Classes */ /* Conditional Classes */
.loc.canc, .loc.canc,
.canc { .canc {
color: grey; color: grey;
text-decoration: line-through; text-decoration: line-through;
opacity: 0.8; opacity: 0.8;
} }
.nonPass { .nonPass {
opacity: 0.4; opacity: 0.4;
} }
.late { .late {
animation: pulse-late 1.5s linear infinite; animation: pulse-late 1.5s linear infinite;
} }
.canc.time { .canc.time {
animation: pulse-cancel 1.5s linear infinite; animation: pulse-cancel 1.5s linear infinite;
} }
.early { .early {
animation: pulse-early 1.5s linear infinite; animation: pulse-early 1.5s linear infinite;
} }
/* Animation Definitions */ /* Animation Definitions */
@keyframes pulse-late { @keyframes pulse-late {
50% { 50% {
color: var(--main-warning-color); color: var(--main-warning-color);
}
} }
}
@keyframes pulse-cancel { @keyframes pulse-cancel {
50% { 50% {
color: var(--main-alert-color); color: var(--main-alert-color);
}
} }
}
@keyframes pulse-early { @keyframes pulse-early {
50% { 50% {
color: rgb(136, 164, 255); color: rgb(136, 164, 255);
}
} }
}
</style> </style>

View File

@ -1,286 +1,286 @@
<script> <script>
import OverlayIsland from "$lib/islands/overlay-island.svelte"; import OverlayIsland from '$lib/islands/overlay-island.svelte';
import { fade } from "svelte/transition"; import { fade } from 'svelte/transition';
import Reason from "$lib/raw-fetchers/reason.svelte"; import Reason from '$lib/raw-fetchers/reason.svelte';
import { uuid } from "$lib/stores/uuid"; import { uuid } from '$lib/stores/uuid';
import StylesToc from "$lib/train/styles-toc.svelte"; import StylesToc from '$lib/train/styles-toc.svelte';
import { getApiUrl } from "$lib/scripts/upstream"; import { getApiUrl } from '$lib/scripts/upstream';
export let detail = { export let detail = {
uid: "", uid: '',
rid: "", rid: '',
headcode: "", headcode: '',
show: true, show: true
};
export let close;
function handleClick() {
close();
}
async function getTrain(rid) {
try {
console.log(`Requested Station: ${rid}`);
const url = `${getApiUrl()}/api/v2/live/train/rid/${rid}`;
const opt = {
method: 'GET',
headers: {
uuid: $uuid
}
};
const data = await fetch(url, opt);
return await data.json();
} catch (error) {
console.error('Error fetching data:', error);
}
}
async function parseDelay(location) {
let string, state;
if (location?.lateness) {
try {
const result = Math.floor(location.lateness / 60);
if (result === 0) {
(string = 'RT'), (state = '');
} else if (result < 0) {
(string = -result + 'E'), (state = 'early');
} else if (result > 0) {
(string = result + 'L'), (state = 'late');
}
} catch {
(string = ''), (state = '');
}
} else if (location.arrivalType === 'Delayed') {
(string = ''), (state = 'late');
} else {
(string = ''), (state = 'noreport');
}
return {
string: string,
state: state
}; };
export let close; }
function handleClick() { function parseTime(date) {
close(); const parsedTime = date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
} return parsedTime !== 'Invalid Date' ? parsedTime : null;
}
async function getTrain(rid) { function parseTimes(service) {
try { const sta = new Date(service.sta),
console.log(`Requested Station: ${rid}`); eta = new Date(service.eta),
const url = `${getApiUrl()}/api/v2/live/train/rid/${rid}`; ata = new Date(service.ata);
const opt = { const std = new Date(service.std),
method: "GET", etd = new Date(service.etd),
headers: { atd = new Date(service.atd);
uuid: $uuid, let parsedSta = parseTime(sta),
}, parsedEta = parseTime(eta),
}; parsedAta = parseTime(ata);
const data = await fetch(url, opt); let parsedStd = parseTime(std),
return await data.json(); parsedEtd = parseTime(etd),
} catch (error) { parsedAtd = parseTime(atd);
console.error("Error fetching data:", error); if (service.isCancelled) {
} (parsedEta = 'CANC'), (parsedEtd = 'CANC');
} }
let times = {
async function parseDelay(location) { sta: parsedSta || '-',
let string, state; eata: parsedEta || parsedAta || '-',
if (location?.lateness) { aEst: parsedEta ? 'estimate' : '',
try { std: parsedStd || '-',
const result = Math.floor(location.lateness / 60); eatd: parsedEtd || parsedAtd || '-',
if (result === 0) { dEst: parsedEtd ? 'estimate' : ''
(string = "RT"), (state = ""); };
} else if (result < 0) { if (service.isCancelled) {
(string = -result + "E"), (state = "early"); (parsedEta = 'CANC'), (parsedEtd = 'CANC');
} else if (result > 0) { (times.aEst = 'canc'), (times.dEst = 'canc');
(string = result + "L"), (state = "late");
}
} catch {
(string = ""), (state = "");
}
} else if (location.arrivalType === "Delayed") {
(string = ""), (state = "late");
} else {
(string = ""), (state = "noreport");
}
return {
string: string,
state: state,
};
}
function parseTime(date) {
const parsedTime = date.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
return parsedTime !== "Invalid Date" ? parsedTime : null;
}
function parseTimes(service) {
const sta = new Date(service.sta),
eta = new Date(service.eta),
ata = new Date(service.ata);
const std = new Date(service.std),
etd = new Date(service.etd),
atd = new Date(service.atd);
let parsedSta = parseTime(sta),
parsedEta = parseTime(eta),
parsedAta = parseTime(ata);
let parsedStd = parseTime(std),
parsedEtd = parseTime(etd),
parsedAtd = parseTime(atd);
if (service.isCancelled) {
(parsedEta = "CANC"), (parsedEtd = "CANC");
}
let times = {
sta: parsedSta || "-",
eata: parsedEta || parsedAta || "-",
aEst: parsedEta ? "estimate" : "",
std: parsedStd || "-",
eatd: parsedEtd || parsedAtd || "-",
dEst: parsedEtd ? "estimate" : "",
};
if (service.isCancelled) {
(parsedEta = "CANC"), (parsedEtd = "CANC");
(times.aEst = "canc"), (times.dEst = "canc");
}
return times;
} }
return times;
}
</script> </script>
<OverlayIsland> <OverlayIsland>
<div id="detailBox"> <div id="detailBox">
<button type="button" id="closeService" on:click={handleClick}>X</button> <button type="button" id="closeService" on:click={handleClick}>X</button>
{#await getTrain(detail.rid)} {#await getTrain(detail.rid)}
<h6>{detail.headcode}</h6> <h6>{detail.headcode}</h6>
<p in:fade id="loading">Loading Data...</p> <p in:fade id="loading">Loading Data...</p>
{:then train} {:then train}
<h6><StylesToc toc={train.GetServiceDetailsResult.operatorCode} full={true} /> {detail.headcode}</h6> <h6><StylesToc toc={train.GetServiceDetailsResult.operatorCode} full={true} /> {detail.headcode}</h6>
<p> <p>
Locations in grey are not scheduled stops Locations in grey are not scheduled stops
<br /> <br />
Times in <span class="estimate">yellow</span> are estimated times Times in <span class="estimate">yellow</span> are estimated times
</p> </p>
{#if train.GetServiceDetailsResult.delayReason} {#if train.GetServiceDetailsResult.delayReason}
<p class="reason late"> <p class="reason late">
<Reason type="delay" code={train.GetServiceDetailsResult.delayReason} /> <Reason type="delay" code={train.GetServiceDetailsResult.delayReason} />
</p> </p>
{/if} {/if}
{#if train.GetServiceDetailsResult.cancelReason} {#if train.GetServiceDetailsResult.cancelReason}
<p class="reason canc"> <p class="reason canc">
<Reason type="cancel" code={train.GetServiceDetailsResult.cancelReason} /> <Reason type="cancel" code={train.GetServiceDetailsResult.cancelReason} />
</p> </p>
{/if} {/if}
<table id="detailTable"> <table id="detailTable">
<tr> <tr>
<th class="tableLocation">Loc.</th> <th class="tableLocation">Loc.</th>
<th class="tablePlatform">Pl.</th> <th class="tablePlatform">Pl.</th>
<th class="tableTime">Sch</th> <th class="tableTime">Sch</th>
<th class="tableTime">Est/<br />Act</th> <th class="tableTime">Est/<br />Act</th>
<th class="tableTime">Sch</th> <th class="tableTime">Sch</th>
<th class="tableTime">Est/<br />Act</th> <th class="tableTime">Est/<br />Act</th>
<th class="tableDelay" /> <th class="tableDelay" />
</tr> </tr>
<tr> <tr>
<th colspan="2" /> <th colspan="2" />
<th colspan="2">Arrival</th> <th colspan="2">Arrival</th>
<th colspan="2">Departure</th> <th colspan="2">Departure</th>
<th /> <th />
</tr> </tr>
{#each train.GetServiceDetailsResult.locations.location as location} {#each train.GetServiceDetailsResult.locations.location as location}
<tr> <tr>
<td class="location {location?.isPass === 'true' ? 'pass' : ''}">{location.tiploc}</td> <td class="location {location?.isPass === 'true' ? 'pass' : ''}">{location.tiploc}</td>
<td class={location?.isPass === "true" ? "pass" : ""}>{location.platform || ""}</td> <td class={location?.isPass === 'true' ? 'pass' : ''}>{location.platform || ''}</td>
{#await parseTimes(location)} {#await parseTimes(location)}
<td /> <td />
<td /> <td />
<td /> <td />
<td /> <td />
{:then times} {:then times}
<td class={location?.isPass === "true" ? "pass" : ""}>{times.sta}</td> <td class={location?.isPass === 'true' ? 'pass' : ''}>{times.sta}</td>
<td class="{location?.isPass === 'true' ? 'pass' : ''} {times.aEst}">{times.eata}</td> <td class="{location?.isPass === 'true' ? 'pass' : ''} {times.aEst}">{times.eata}</td>
<td class={location?.isPass === "true" ? "pass" : ""}>{times.std}</td> <td class={location?.isPass === 'true' ? 'pass' : ''}>{times.std}</td>
<td class="{location?.isPass === 'true' ? 'pass' : ''} {times.dEst}">{times.eatd}</td> <td class="{location?.isPass === 'true' ? 'pass' : ''} {times.dEst}">{times.eatd}</td>
{/await} {/await}
{#await parseDelay(location)} {#await parseDelay(location)}
<td>-</td> <td>-</td>
{:then delay} {:then delay}
<td class={delay.state}>{delay.string}</td> <td class={delay.state}>{delay.string}</td>
{/await} {/await}
</tr> </tr>
{/each} {/each}
</table> </table>
{:catch} {:catch}
<h6>Error loading data</h6> <h6>Error loading data</h6>
{/await} {/await}
</div> </div>
</OverlayIsland> </OverlayIsland>
<style> <style>
#detailBox { #detailBox {
width: 100%; width: 100%;
min-height: 100px; min-height: 100px;
overflow-x: hidden; overflow-x: hidden;
overflow-y: auto; overflow-y: auto;
} }
h6 { h6 {
position: absolute; position: absolute;
top: -16px; top: -16px;
left: 20px; left: 20px;
font-size: 14px; font-size: 14px;
color: whitesmoke; color: whitesmoke;
} }
#loading { #loading {
color: white; color: white;
animation: pulse-early 2.5s linear infinite; animation: pulse-early 2.5s linear infinite;
} }
p { p {
margin-top: 45px; margin-top: 45px;
margin-bottom: 0px; margin-bottom: 0px;
} }
p.reason { p.reason {
margin-top: 5px; margin-top: 5px;
} }
#closeService { #closeService {
position: absolute; position: absolute;
top: 10px; top: 10px;
right: 10px; right: 10px;
border: none; border: none;
border-radius: 60px; border-radius: 60px;
width: 35px; width: 35px;
height: 35px; height: 35px;
background-color: var(--main-bg-color); background-color: var(--main-bg-color);
color: white; color: white;
font-weight: 700; font-weight: 700;
font-size: 14px; font-size: 14px;
} }
#detailTable {
margin-top: 10px;
table-layout: fixed;
width: 100%;
margin-top: 12px;
margin-left: 0px;
margin-right: 0px;
padding: 0px;
color: white;
font-family: ubuntu, monospace;
font-size: 16px;
}
@media screen and (max-width: 338px) {
#detailTable { #detailTable {
margin-top: 10px; font-size: 14px;
table-layout: fixed;
width: 100%;
margin-top: 12px;
margin-left: 0px;
margin-right: 0px;
padding: 0px;
color: white;
font-family: ubuntu, monospace;
font-size: 16px;
} }
@media screen and (max-width: 338px) { }
#detailTable { @media screen and (max-width: 301px) {
font-size: 14px; #detailTable {
} font-size: 12px;
} }
@media screen and (max-width: 301px) { }
#detailTable { @media screen and (min-width: 469px) {
font-size: 12px; #detailTable {
} font-size: 20px;
}
@media screen and (min-width: 469px) {
#detailTable {
font-size: 20px;
}
}
.tableLocation {
width: 18%;
}
td.location {
color: yellow;
}
.tablePlatform {
width: 9%;
}
.tableTime {
width: 14%;
}
.tableDelay {
width: 7%;
}
.estimate {
color: rgb(255, 255, 119);
}
.pass {
color: white !important;
opacity: 0.45;
}
.canc {
color: white;
animation: pulse-cancel 1.5s linear infinite;
} }
}
.tableLocation {
width: 18%;
}
td.location {
color: yellow;
}
.tablePlatform {
width: 9%;
}
.tableTime {
width: 14%;
}
.tableDelay {
width: 7%;
}
.estimate {
color: rgb(255, 255, 119);
}
.pass {
color: white !important;
opacity: 0.45;
}
.canc {
color: white;
animation: pulse-cancel 1.5s linear infinite;
}
.early { .early {
animation: pulse-early 1.5s linear infinite; animation: pulse-early 1.5s linear infinite;
} }
.late { .late {
color: white; color: white;
animation: pulse-late 1.5s linear infinite; animation: pulse-late 1.5s linear infinite;
} }
@keyframes pulse-late { @keyframes pulse-late {
50% { 50% {
color: var(--main-warning-color); color: var(--main-warning-color);
}
} }
}
@keyframes pulse-cancel { @keyframes pulse-cancel {
50% { 50% {
color: var(--main-alert-color); color: var(--main-alert-color);
}
} }
}
@keyframes pulse-early { @keyframes pulse-early {
50% { 50% {
color: rgb(136, 164, 255); color: rgb(136, 164, 255);
}
} }
}
</style> </style>

View File

@ -1,29 +1,29 @@
// Contains the details required to lookup train details // Contains the details required to lookup train details
export interface Detail { export interface Detail {
show: boolean; show: boolean;
headcode: string; headcode: string;
rid: string; rid: string;
uid: string; uid: string;
} }
// Initiates/Resets a `Detail` interface // Initiates/Resets a `Detail` interface
export function detailInit(): Detail { export function detailInit(): Detail {
const detail: Detail = { const detail: Detail = {
show: false, show: false,
headcode: "", headcode: '',
rid: "", rid: '',
uid: "", uid: ''
}; };
return detail; return detail;
} }
// Initiates/Updates a `Detail` interface using the given values // Initiates/Updates a `Detail` interface using the given values
export function defineDetail(rid: string, uid: string, tid: string) { export function defineDetail(rid: string, uid: string, tid: string) {
const detail: Detail = { const detail: Detail = {
rid: rid, rid: rid,
uid: uid, uid: uid,
headcode: tid, headcode: tid,
show: true, show: true
}; };
return detail; return detail;
} }

View File

@ -1,77 +1,77 @@
import { getApiUrl } from "./scripts/upstream"; import { getApiUrl } from './scripts/upstream';
import { uuid } from "./stores/uuid"; import { uuid } from './stores/uuid';
export interface libauthResponse { export interface libauthResponse {
uuidPresent?: boolean; uuidPresent?: boolean;
serverAuthCheck?: boolean; serverAuthCheck?: boolean;
uuidValue?: string; uuidValue?: string;
serverAuthCheckResponseCode?: number; serverAuthCheckResponseCode?: number;
} }
interface uuidCheckRes { interface uuidCheckRes {
uuidValue?: string; uuidValue?: string;
uuidPresent?: boolean; uuidPresent?: boolean;
} }
export async function checkAuth(): Promise<libauthResponse> { export async function checkAuth(): Promise<libauthResponse> {
let result: libauthResponse = {}; let result: libauthResponse = {};
const uuidCheck = await checkUuid(); const uuidCheck = await checkUuid();
result.uuidPresent = uuidCheck?.uuidPresent; result.uuidPresent = uuidCheck?.uuidPresent;
result.uuidValue = uuidCheck?.uuidValue; result.uuidValue = uuidCheck?.uuidValue;
const serverCheck = await checkServerAuth(result.uuidValue || ""); const serverCheck = await checkServerAuth(result.uuidValue || '');
result.serverAuthCheck = serverCheck.authOk; result.serverAuthCheck = serverCheck.authOk;
result.serverAuthCheckResponseCode = serverCheck.status; result.serverAuthCheckResponseCode = serverCheck.status;
return result; return result;
} }
async function checkUuid(): Promise<uuidCheckRes> { async function checkUuid(): Promise<uuidCheckRes> {
let uuid_value: string = ""; let uuid_value: string = '';
const unsubscribe = uuid.subscribe((value) => { const unsubscribe = uuid.subscribe((value) => {
uuid_value = value; uuid_value = value;
}); });
let res: uuidCheckRes = { let res: uuidCheckRes = {
uuidValue: uuid_value, uuidValue: uuid_value
};
console.log('uuid-value is: ', uuid_value);
if (uuid_value && uuid_value != 'null') {
res = {
uuidPresent: true,
uuidValue: uuid_value
}; };
console.log("uuid-value is: ", uuid_value); } else {
if (uuid_value && uuid_value != "null") { res = {
res = { uuidPresent: false,
uuidPresent: true, uuidValue: uuid_value
uuidValue: uuid_value, };
}; }
} else { unsubscribe();
res = { return res;
uuidPresent: false,
uuidValue: uuid_value,
};
}
unsubscribe();
return res;
} }
async function checkServerAuth(uuidString: string) { async function checkServerAuth(uuidString: string) {
const url = `${getApiUrl()}/api/v2/user/checkAuth`; const url = `${getApiUrl()}/api/v2/user/checkAuth`;
const options = { const options = {
method: "GET", method: 'GET',
headers: { headers: {
uuid: uuidString, uuid: uuidString
},
};
const res = await fetch(url, options);
let ok: boolean;
if (res.status !== 401) {
ok = true;
} else {
ok = false;
} }
return { };
authOk: ok, const res = await fetch(url, options);
status: res.status, let ok: boolean;
}; if (res.status !== 401) {
ok = true;
} else {
ok = false;
}
return {
authOk: ok,
status: res.status
};
} }
export async function logout(): Promise<boolean> { export async function logout(): Promise<boolean> {
uuid.set(null); uuid.set(null);
return true; return true;
} }

View File

@ -1,64 +1,67 @@
/* FONTS */ /* FONTS */
@font-face { @font-face {
font-family: "firamono"; font-family: 'firamono';
src: url("/font/firamono/firamono-regular.woff2") format("woff2"), url("/font/firamono/firamono-regular.woff") format("woff"); src: url('/font/firamono/firamono-regular.woff2') format('woff2'), url('/font/firamono/firamono-regular.woff') format('woff'),
font-weight: normal; url('/font/firamono/firamono-regular.ttf') format('truetype');
font-style: normal; font-weight: normal;
font-style: normal;
} }
@font-face { @font-face {
font-family: "firamono"; font-family: 'firamono';
src: url("/font/firamono/firamono-500.woff2") format("woff2"), url("/font/firamono/firamono-500.woff") format("woff"); 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-weight: 500;
font-style: normal; font-style: normal;
} }
@font-face { @font-face {
font-family: "urwgothic"; font-family: 'urwgothic';
src: url("/font/urwgothic/urwgothic.woff2") format("woff2"), url("/font/urwgothic/urwgothic.woff") format("woff"); 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-weight: normal;
font-style: normal; font-style: normal;
} }
@font-face { @font-face {
font-family: "urwgothic"; font-family: 'urwgothic';
src: url("/font/urwgothic/urwgothicDemi.woff2") format("woff2"), url("/font/urwgothic/urwgothicDemi.woff") format("woff"); src: url('/font/urwgothic/urwgothicDemi.woff2') format('woff2'), url('/font/urwgothic/urwgothicDemi.woff') format('woff'),
font-weight: 900; url('/font/urwgothic/urwgothicDemi.ttf') format('truetype');
font-style: normal; font-weight: 900;
font-style: normal;
} }
@font-face { @font-face {
font-family: "ubuntu"; font-family: 'ubuntu';
src: url("/font/ubuntumono/ubuntumono-regular.woff2") format("woff2"), url("/font/ubuntumono/ubuntumono-regular.woff") format("woff"); src: url('/font/ubuntumono/ubuntumono-regular.woff2') format('woff2'), url('/font/ubuntumono/ubuntumono-regular.woff') format('woff'),
font-weight: 400; url('/font/ubuntumono/ubuntumono-regular.ttf') format('truetype');
font-style: normal; font-weight: 400;
font-style: normal;
} }
html { html {
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
body { body {
background-color: var(--main-bg-color); background-color: var(--main-bg-color);
background-image: radial-gradient(var(--second-bg-color), var(--main-bg-color)); background-image: radial-gradient(var(--second-bg-color), var(--main-bg-color));
color: var(--main-text-color); color: var(--main-text-color);
font-family: urwgothic, sans-serif; font-family: urwgothic, sans-serif;
text-align: center; text-align: center;
margin: auto; margin: auto;
width: 100%; width: 100%;
padding-bottom: 65px; padding-bottom: 65px;
} }
a { a {
color: var(--main-link-color); color: var(--main-link-color);
} }
button:hover { button:hover {
cursor: pointer; cursor: pointer;
} }
button { button {
-webkit-touch-callout: none; -webkit-touch-callout: none;
-webkit-user-select: none; -webkit-user-select: none;
-khtml-user-select: none; -khtml-user-select: none;
-moz-user-select: none; -moz-user-select: none;
-ms-user-select: none; -ms-user-select: none;
user-select: none; user-select: none;
-webkit-tap-highlight-color: transparent; -webkit-tap-highlight-color: transparent;
} }

View File

@ -1,28 +0,0 @@
<script lang="ts">
export let size: string = "1em";
export let color: string = "aliceblue";
</script>
<div class="spinner" style="--spinner-size: {size}; --spinner-color: {color};" />
<style>
.spinner {
display: inline-block;
width: var(--spinner-size);
height: var(--spinner-size);
border: 2px solid transparent;
border-top-color: var(--spinner-color);
border-radius: 50%;
animation: spin 1s linear infinite;
margin: 10px;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
</style>

View File

@ -1,25 +1,25 @@
<script lang="ts"> <script lang="ts">
import { logout } from "$lib/libauth"; import { logout } from '$lib/libauth';
async function logoutAction() { async function logoutAction() {
await logout(); await logout();
location.reload(); location.reload();
} }
</script> </script>
<button class="logout" type="button" on:click={logoutAction}>Logout</button> <button class="logout" type="button" on:click={logoutAction}>Logout</button>
<style> <style>
.logout { .logout {
border: none; border: none;
background-color: var(--island-button-color); background-color: var(--island-button-color);
color: var(--island-link-color); color: var(--island-link-color);
width: 35%; width: 35%;
border-radius: 50px; border-radius: 50px;
font-size: 20px; font-size: 20px;
min-width: 90px; min-width: 90px;
margin: 30px; margin: 30px;
height: 48px; height: 48px;
box-shadow: var(--box-shadow); box-shadow: var(--box-shadow);
} }
</style> </style>

View File

@ -1,57 +0,0 @@
<script lang="ts">
import { onMount } from "svelte";
import { fade } from "svelte/transition";
export let updatedTime: Date | undefined;
let currentTime: string = "00:00:00";
let updateDisplay: string;
function updateTime() {
const now = new Date();
const hours = now.getHours().toString().padStart(2, "0");
const mins = now.getMinutes().toString().padStart(2, "0");
const secs = now.getSeconds().toString().padStart(2, "0");
currentTime = `${hours}:${mins}:${secs}`;
}
onMount(() => {
console.log("TimeBar component mounted");
updateTime();
const interval = setInterval(updateTime, 250);
return () => clearInterval(interval);
});
</script>
<div id="TimeBar">
{#if updatedTime}
<span in:fade class="updated-time">Updated: {updatedTime.toLocaleTimeString()}</span>
{:else}
<span />
{/if}
<span class="current-time">{currentTime}</span>
</div>
<style>
#TimeBar {
width: 100%;
background-color: transparent;
height: 30px;
display: flex;
justify-content: space-between;
align-items: center;
padding: 0;
}
.updated-time {
font-family: firamono, "Courier New", Courier, monospace;
margin-left: 10px;
font-size: 14px;
}
.current-time {
font-family: firamono, "Courier New", Courier, monospace;
font-weight: 900;
vertical-align: middle;
color: aliceblue;
margin-right: 10px;
font-size: 17px;
}
</style>

View File

@ -1,32 +1,32 @@
<div id="container"> <div id="container">
<p id="tick">&#10004;</p> <p id="tick">&#10004;</p>
<p>Done</p> <p>Done</p>
</div> </div>
<style> <style>
#tick { #tick {
font-size: 45px; font-size: 45px;
margin: 0; margin: 0;
padding: 0; padding: 0;
} }
#container { #container {
position: fixed; position: fixed;
top: 50%; top: 50%;
left: 50%; left: 50%;
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
margin: auto; margin: auto;
background-color: var(--overlay-island-bg-color); background-color: var(--overlay-island-bg-color);
border-radius: 15px; border-radius: 15px;
padding: 20px; padding: 20px;
padding-bottom: 1px; padding-bottom: 1px;
min-width: 90px; min-width: 90px;
max-width: 90px; max-width: 90px;
box-shadow: var(--box-shadow); box-shadow: var(--box-shadow);
} }
p { p {
padding-top: 0px; padding-top: 0px;
font-weight: bolder; font-weight: bolder;
overflow-wrap: normal; overflow-wrap: normal;
color: var(--island-text-color); color: var(--island-text-color);
} }
</style> </style>

View File

@ -1,53 +1,56 @@
<script> <script>
export let title = "title"; export let title = 'title';
</script> </script>
<div class="headerBar"> <div class="headerBar">
<a href="/"> <a href="/">
<img src="/images/logo/wide_logo.svg" alt="OwlBoard Logo" /> <picture>
</a> <source srcset="/images/logo/wide_logo.svg" type="image/svg+xml" />
<header>{title}</header> <img src="/images/logo/wide_logo_200.png" alt="OwlBoard Logo" />
</picture>
</a>
<header>{title}</header>
</div> </div>
<div class="headerBlock"> <div class="headerBlock">
<!-- This exists to prevent the headerBar overlapping anything below it --> <!-- This exists to prevent the headerBar overlapping anything below it -->
</div> </div>
<style> <style>
.headerBar { .headerBar {
background: var(--island-bg-solid); background: var(--island-bg-solid);
color: var(--main-header-color); color: var(--main-header-color);
position: fixed; position: fixed;
top: 0; top: 0;
left: 0; left: 0;
width: 100%; width: 100%;
margin: 0; margin: 0;
padding: 0; padding: 0;
height: 50px; height: 50px;
z-index: 20; z-index: 20;
box-shadow: 0 3px 30px var(--box-shadow-color); box-shadow: 0 3px 30px var(--box-shadow-color);
} }
img { img {
position: absolute; position: absolute;
height: 40px; height: 40px;
right: 8px; right: 8px;
top: 5px; top: 5px;
} }
header { header {
position: absolute; position: absolute;
left: 0px; left: 0px;
top: 3px; top: 3px;
font-family: urwgothic, sans-serif; font-family: urwgothic, sans-serif;
font-weight: 600; font-weight: 600;
margin-top: 7px; margin-top: 7px;
margin-left: 20px; margin-left: 20px;
font-size: 15pt; font-size: 15pt;
} }
.headerBlock { .headerBlock {
height: 50px; height: 50px;
margin: 0; margin: 0;
padding: 0; padding: 0;
} }
</style> </style>

View File

@ -1,16 +1,16 @@
<p id="load">Loading...</p> <p id="load">Loading...</p>
<style> <style>
#load { #load {
margin-top: 5px; margin-top: 5px;
font-size: 18px; font-size: 18px;
font-weight: 600; font-weight: 600;
color: white; color: white;
animation: pulse-loading 2.5s linear infinite; animation: pulse-loading 2.5s linear infinite;
} }
@keyframes pulse-loading { @keyframes pulse-loading {
50% { 50% {
color: rgb(136, 164, 255); color: rgb(136, 164, 255);
}
} }
}
</style> </style>

View File

@ -1,54 +1,54 @@
<script> <script>
import { fade } from "svelte/transition"; import { fade } from 'svelte/transition';
</script> </script>
<div id="container" in:fade={{ delay: 150, duration: 250 }} out:fade={{ duration: 250 }}> <div id="container" in:fade={{ delay: 150, duration: 250 }} out:fade={{ duration: 250 }}>
<div class="spinner" /> <div class="spinner" />
<p>Loading...</p> <p>Loading...</p>
</div> </div>
<style> <style>
@keyframes spinner { @keyframes spinner {
0% { 0% {
transform: translate3d(-50%, -50%, 0) rotate(0); transform: translate3d(-50%, -50%, 0) rotate(0);
}
100% {
transform: translate3d(-50%, -50%, 0) rotate(360deg);
}
} }
.spinner::before { 100% {
animation: 1.5s linear infinite spinner; transform: translate3d(-50%, -50%, 0) rotate(360deg);
animation-play-state: inherit;
border: solid 5px var(--overlay-island-bg-color);
border-bottom-color: white;
border-radius: 50%;
content: "";
height: 40px;
width: 40px;
position: absolute;
top: 30%;
margin: auto;
transform: translate3d(-50%, -50%, 0);
will-change: transform;
}
#container {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
margin: auto;
background-color: var(--overlay-island-bg-color);
border-radius: 15px;
padding: 20px;
padding-bottom: 1px;
min-width: 90px;
max-width: 90px;
box-shadow: var(--box-shadow);
}
p {
padding-top: 50px;
font-weight: bolder;
overflow-wrap: normal;
color: var(--island-text-color);
} }
}
.spinner::before {
animation: 1.5s linear infinite spinner;
animation-play-state: inherit;
border: solid 5px var(--overlay-island-bg-color);
border-bottom-color: white;
border-radius: 50%;
content: '';
height: 40px;
width: 40px;
position: absolute;
top: 30%;
margin: auto;
transform: translate3d(-50%, -50%, 0);
will-change: transform;
}
#container {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
margin: auto;
background-color: var(--overlay-island-bg-color);
border-radius: 15px;
padding: 20px;
padding-bottom: 1px;
min-width: 90px;
max-width: 90px;
box-shadow: var(--box-shadow);
}
p {
padding-top: 50px;
font-weight: bolder;
overflow-wrap: normal;
color: var(--island-text-color);
}
</style> </style>

View File

@ -1,93 +1,92 @@
<script lang="ts"> <script>
const links = [ const links = [
{ {
title: "Home", title: 'Home',
path: "/", path: '/',
icon: IconHome, svgPath: '/images/navigation/home.svg'
}, }
]; ];
import { page } from "$app/stores"; import { page } from '$app/stores';
import { IconHome } from "@tabler/icons-svelte";
</script> </script>
<footer> <footer>
{#each links as item} {#each links as item}
<a class="footerLink" href={item.path} class:active={$page.url.pathname == item.path}> <a class="footerLink" href={item.path} class:active={$page.url.pathname == item.path}>
<svelte:component this={item.icon} /> <img src={item.svgPath} alt={item.title} />
<br /> <br />
<span class="title">{item.title}</span> <span>{item.title}</span>
</a> </a>
{/each} {/each}
<div class="data-source"> <div class="data-source">
<a href="https://nationalrail.co.uk" target="_blank"> <a href="https://nationalrail.co.uk" target="_blank">
<picture> <picture>
<source srcset="/images/nre/nre-powered_200w.jxl" type="image/jxl" /> <source srcset="/images/nre/nre-powered_200w.jxl" type="image/jxl" />
<source srcset="/images/nre/nre-powered_200w.webp" type="image/webp" /> <source srcset="/images/nre/nre-powered_200w.webp" type="image/webp" />
<img id="nre-logo" src="/images/nre/nre-powered_200w.png" alt="Data sourced from National Rail and others" /> <img id="nre-logo" src="/images/nre/nre-powered_200w.png" alt="Data sourced from National Rail and others" />
</picture> </picture>
</a> </a>
</div> </div>
</footer> </footer>
<style> <style>
footer { footer {
position: fixed; position: fixed;
display: flex; display: flex;
bottom: 0; bottom: 0;
left: 0; left: 0;
width: 100%; width: 100%;
height: 50px; height: 50px;
background-color: var(--island-bg-solid); background-color: var(--island-bg-solid);
} }
.footerLink { .footerLink {
width: 30%; width: 30%;
height: 100%; height: 100%;
background-color: var(--island-bg-solid); background-color: var(--island-bg-solid);
border-style: solid; border-style: solid;
border-width: 1px; border-width: 1px;
border-top: none; border-top: none;
border-bottom: none; border-bottom: none;
border-color: var(--box-shadow-color); border-color: var(--box-shadow-color);
color: var(--main-text-color); color: var(--main-text-color);
text-decoration: double; text-decoration: double;
font-weight: 600; font-weight: 600;
} }
footer a.active { footer a.active {
background-color: transparent; background-color: transparent;
} }
.data-source {
flex-grow: 2;
background: rgb(255, 255, 255);
}
#nre-logo {
width: 150px;
height: auto;
margin: auto;
margin-top: 13px;
}
@media only screen and (min-width: 475px) {
.data-source { .data-source {
flex-grow: 2; background: rgb(255, 255, 255);
background: rgb(255, 255, 255); background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 40%);
} }
#nre-logo { #nre-logo {
width: 150px; position: absolute;
height: auto; right: 0;
margin: auto; right: 20px;
margin-top: 13px;
}
@media only screen and (min-width: 475px) {
.data-source {
background: rgb(255, 255, 255);
background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 40%);
}
#nre-logo {
position: absolute;
right: 0;
right: 20px;
}
}
img {
height: 20px;
width: 20px;
margin: 0;
margin-top: 3px;
padding: 0;
}
.title {
margin: 0;
margin-bottom: 3px;
padding: 0;
} }
}
img {
height: 20px;
width: 20px;
margin: 0;
margin-top: 3px;
padding: 0;
}
span {
margin: 0;
margin-bottom: 3px;
padding: 0;
}
</style> </style>

View File

@ -1,69 +1,76 @@
<script> <script>
const links = [ const links = [
{ {
title: "Home", title: 'Home',
path: "/", path: '/',
icon: IconHome, svgPath: '/images/navigation/home.svg'
}, },
{ {
title: "PIS Finder", title: 'PIS Finder',
path: "/pis/", path: '/pis',
icon: IconDialpad, svgPath: '/images/navigation/info.svg'
}, },
{ {
title: "Menu", title: 'Menu',
path: "/more/", path: '/more',
icon: IconMenu2, svgPath: '/images/navigation/more.svg'
}, }
]; ];
import { page } from "$app/stores"; import { page } from '$app/stores';
import { IconHome, IconMenu2, IconDialpad } from "@tabler/icons-svelte";
</script> </script>
<footer> <footer>
{#each links as item} {#each links as item}
<a href={item.path} class:active={$page.url.pathname == item.path || $page.url.pathname == item.path + "/"}> <a href={item.path} class:active={$page.url.pathname == item.path}>
<svelte:component this={item.icon} /> <img src={item.svgPath} alt={item.title} />
<br /> <br />
<span>{item.title}</span> <span>{item.title}</span>
</a> </a>
{/each} {/each}
</footer> </footer>
<style> <style>
footer { footer {
position: fixed; position: fixed;
display: flex; display: flex;
bottom: 0; bottom: 0;
left: 0; left: 0;
width: 100%; width: 100%;
height: 50px; height: 50px;
background-color: rgb(54, 54, 54); background-color: rgb(54, 54, 54);
box-shadow: 0 -2px 30px rgba(0, 0, 0, 0.19); box-shadow: 0 -2px 30px rgba(0, 0, 0, 0.19);
} }
footer a { footer a {
flex: 12; flex: 12;
width: 30%; width: 30%;
height: 100%; height: 100%;
background-color: var(--island-bg-solid); background-color: var(--island-bg-solid);
border-style: solid; border-style: solid;
border-width: 1px; border-width: 1px;
border-top: none; border-top: none;
border-bottom: none; border-bottom: none;
border-color: var(--box-shadow-color); border-color: var(--box-shadow-color);
text-decoration: double; text-decoration: double;
color: var(--main-text-color); color: var(--main-text-color);
font-weight: 600; font-weight: 600;
} }
footer a.active { footer a.active {
background-color: transparent; background-color: transparent;
} }
span { img {
margin: 0; height: 20px;
margin-bottom: 3px; width: 20px;
padding: 0; margin: 0;
} margin-top: 3px;
padding: 0;
}
span {
margin: 0;
margin-bottom: 3px;
padding: 0;
}
</style> </style>

View File

@ -0,0 +1,103 @@
<script lang="ts">
import { welcome } from '$lib/stores/welcome';
import { fade } from 'svelte/transition';
import { version } from '$lib/stores/version';
let pageNum: number = 0;
function pageUp() {
pageNum++;
console.log(`Welcome page: ${pageNum}`);
}
function pageDn() {
pageNum--;
console.log(`Welcome page: ${pageNum}`);
}
function close() {
welcome.set(version);
}
const pageText: string[] = [
'<h3>A new way to find PIS Codes</h3>' +
"<p>You can now use a headcode to find a PIS code where there is only a partial match</p>" +
'<p>For now, you can see a PIS code where you need to skip some stops at the start,</p>' +
'<p>soon, you will be able to find PIS codes where you need to skip stops at the end.</p>' +
'<p>Check out our <a href="https://www.facebook.com/owlboard.support">Facebook page</a> where a video guide will be available soon.</p>',
];
</script>
<div id="popup" in:fade={{ delay: 500, duration: 300 }} out:fade={{ duration: 300 }}>
<h2>What's new in OwlBoard {version}</h2>
{#key pageNum}
<div in:fade={{ delay: 300 }} out:fade={{ duration: 200 }}>
{@html pageText[pageNum] || "You won't see this welcome message again"}
</div>
{/key}
{#if pageNum >= pageText.length - 1}
<button in:fade={{ delay: 350, duration: 250 }} out:fade={{ duration: 250 }} class="navButton" id="buttonCentre" type="button" on:click={close}>X</button>
{/if}
{#if pageNum > 0 && pageNum < pageText.length}
<button in:fade={{ delay: 350, duration: 250 }} out:fade={{ duration: 250 }} class="navButton" id="buttonLeft" type="button" on:click={pageDn}>&lt;</button>
{/if}
{#if pageNum < pageText.length - 1}
<button in:fade={{ delay: 350, duration: 250 }} out:fade={{ duration: 250 }} class="navButton" id="buttonRight" type="button" on:click={pageUp}>&gt;</button>
{/if}
</div>
<style>
#popup {
position: fixed;
top: 50px;
left: 50%;
transform: translateX(-50%);
width: 85%;
height: 75vh;
max-height: 600px;
overflow-y: auto;
max-width: 400px;
margin: auto;
margin-top: 25px;
padding: 10px;
background-color: var(--island-bg-solid);
border-radius: 10px;
z-index: 2500;
box-shadow: 5px 5px 10px var(--box-shadow-color);
}
.navButton {
border-radius: 50px;
border: none;
color: var(--island-link-color);
background-color: var(--island-button-color);
width: 50px;
height: 50px;
font-size: 20px;
font-weight: 600;
bottom: 50px;
}
#buttonLeft {
position: absolute;
margin: auto;
left: 50px;
}
#buttonCentre {
position: absolute;
margin: auto;
left: 50%;
transform: translateX(-50%);
}
#buttonRight {
position: absolute;
margin: auto;
right: 50px;
}
div {
color: var(--island-text-color);
}
</style>

View File

@ -1,49 +1,49 @@
<script lang="ts"> <script>
import { apiGet } from "$lib/scripts/apiFetch"; import { getApiUrl } from '$lib/scripts/upstream';
import type { ReasonCode } from "@owlboard/ts-types"; import { uuid } from '$lib/stores/uuid';
export let code: string; export let code = '';
export let type: string; export let type = '';
async function getDelay(code: string): Promise<string | undefined> { async function getDelay(code = '') {
const data = await getReason(code); console.log(`Fetching delay reason ${code}`);
if (data) { const data = await getReason(code);
return data[0].lateReason || "This train has been delayed"; return data[0].lateReason || 'This train has been delayed';
} }
}
async function getCancel(code: string): Promise<string | undefined> { async function getCancel(code = '') {
const data = await getReason(code); console.log(`Fetching cancel reason ${code}`);
if (data) { const data = await getReason(code);
return data[0].cancReason || "This train has been cancelled"; return data[0].cancReason || 'This train has been cancelled';
} }
}
async function getReason(code: string): Promise<ReasonCode[] | undefined> { async function getReason(code = '') {
const apiString = `/api/v2/ref/reasonCode/${code}`; const url = `${getApiUrl()}/api/v2/ref/reasonCode/${code}`;
try { const options = {
const apiRes = (await apiGet(apiString)) as ReasonCode[]; method: 'GET',
return apiRes; headers: {
} catch (err) { uuid: $uuid
console.error("Unable to define reason code"); }
} };
} const res = await fetch(url, options);
return await res.json();
}
</script> </script>
{#if type === "cancel"} {#if type === 'cancel'}
{#await getCancel(code)} {#await getCancel(code)}
This train has been cancelled This train has been cancelled
{:then reason} {:then reason}
{reason} {reason}
{:catch} {:catch}
This train has been cancelled This train has been cancelled
{/await} {/await}
{:else if type === "delay"} {:else if type === 'delay'}
{#await getDelay(code)} {#await getDelay(code)}
This train has been delayed This train has been delayed
{:then reason} {:then reason}
{reason} {reason}
{:catch} {:catch}
This train has been delayed This train has been delayed
{/await} {/await}
{/if} {/if}

View File

@ -1,55 +0,0 @@
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;
}
}
export async function apiGet(path: string): Promise<any> {
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,
},
};
try {
const res = await fetch(getUrlString() + path, options);
if (res.status === 401) {
throw new Error("Registration not accepted. Register at `Menu > Registration`");
}
if (!res.ok) {
throw new Error(`Failed: ${res.status}: ${res.statusText}`);
}
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();
}
}

View File

@ -1,49 +0,0 @@
export interface FeatureDetectionResult {
critical: boolean;
nice: boolean;
missing: string[];
}
export function featureDetect(): FeatureDetectionResult {
console.info("Running feature detection");
// Define critical features
const criticalFeatures = {
fetch: "fetch" in window,
localStorage: "localStorage" in window && window["localStorage"] !== null,
sessionStorage: "sessionStorage" in window && window["sessionStorage"] !== null,
promise: "Promise" in window,
};
// Define nice-to-have features
const niceToHaveFeatures = {
geolocation: "geolocation" in navigator,
serviceWorker: "serviceWorker" in navigator,
dialog: "HTMLDialogElement" in window,
popover: "showPopover" in HTMLElement.prototype, // Note: 'Popover' might need more specific checks based on implementation
};
// Initialize result object
const result = {
critical: true,
nice: true,
missing: [],
};
// Check critical features
for (const [feature, available] of Object.entries(criticalFeatures)) {
if (!available) {
result.critical = false;
result.missing.push(feature);
}
}
// Check nice-to-have features
for (const [feature, available] of Object.entries(niceToHaveFeatures)) {
if (!available) {
result.nice = false;
result.missing.push(feature);
}
}
return result;
}

View File

@ -1,39 +0,0 @@
export async function getCurrentLocation(): Promise<locationObj> {
console.debug("Fetching location");
if (typeof window === "undefined") {
console.error("Location fetch has run serverside - invalid method");
}
if (!navigator.geolocation) {
console.error("Geolocation is not supported");
throw new Error("Geolocation is not supported");
}
return new Promise((resolve, reject) => {
const options = {
timeout: 10000,
maximumAge: 300,
};
navigator.geolocation.getCurrentPosition(
(position) => {
console.debug(`Position obtained: ${position.coords}`);
resolve({
latitude: position.coords.latitude,
longitude: position.coords.longitude,
});
},
(error) => {
console.error("Error fetching location: ", error);
reject(error);
}
);
options;
});
}
export interface locationObj {
latitude: number;
longitude: number;
}

View File

@ -1,12 +1,12 @@
import { dev } from "$app/environment"; import { dev } from '$app/environment';
const testUrl: string = "http://localhost:8460"; const testUrl: string = 'http://localhost:8460'
const prodUrl: string = "https://owlboard.info"; const prodUrl: string = 'https://owlboard.info'
export function getApiUrl() { export function getApiUrl() {
if (dev) { if (dev) {
console.info("DEVMODE active, using testing URL: ", testUrl); console.info('DEVMODE active, using testing URL: ', testUrl);
return testUrl; return testUrl;
} }
return prodUrl; return prodUrl;
} }

View File

@ -1,25 +0,0 @@
// src/stores.js
import { writable, type Writable } from "svelte/store";
import { browser } from "$app/environment";
// Initialize the store with a boolean value from local storage
export const location: Writable<boolean> = writable(fromLocalStorage("location", false));
toLocalStorage(location, "location");
function fromLocalStorage(storageKey: string, fallback: boolean): boolean {
if (browser) {
const storedValue = localStorage.getItem(storageKey);
if (storedValue !== null && storedValue !== "undefined") {
return storedValue === "true";
}
}
return fallback;
}
function toLocalStorage(store: Writable<boolean>, storageKey: string) {
if (browser) {
store.subscribe((value: boolean) => {
localStorage.setItem(storageKey, String(value));
});
}
}

View File

@ -1,26 +0,0 @@
import { writable, type Writable } from "svelte/store";
import { browser } from "$app/environment";
import type { NearestStationResponse } from "@owlboard/ts-types";
export const nearToMeCache = writable(fromSessionStorage("nearToMeCache", []));
toSessionStorage(nearToMeCache, "nearToMeCache");
function fromSessionStorage(storageKey: string, fallback: NearestStationResponse[]): NearestStationResponse[] {
if (browser) {
const storedValue = sessionStorage.getItem(storageKey);
if (storedValue !== "undefined" && storedValue !== null) {
return typeof fallback === "object" ? JSON.parse(storedValue) : storedValue;
}
}
return fallback;
}
function toSessionStorage(store: Writable<NearestStationResponse[]>, storageKey: string) {
if (browser) {
store.subscribe((value) => {
let storageValue = typeof value === "object" ? JSON.stringify(value.sort()) : value;
sessionStorage.setItem(storageKey, storageValue);
});
}
}

View File

@ -1,25 +1,25 @@
import { writable, type Writable } from "svelte/store"; import { writable, type Writable } from 'svelte/store';
import { browser } from "$app/environment"; import { browser } from '$app/environment';
export const ql = writable(fromLocalStorage("ql", [])); export const ql = writable(fromLocalStorage('ql', []));
toLocalStorage(ql, "ql"); toLocalStorage(ql, 'ql');
function fromLocalStorage(storageKey: string, fallback: string[]): string[] { function fromLocalStorage(storageKey: string, fallback: string[]): string[] {
if (browser) { if (browser) {
const storedValue = localStorage.getItem(storageKey); const storedValue = localStorage.getItem(storageKey);
if (storedValue !== "undefined" && storedValue !== null) { if (storedValue !== 'undefined' && storedValue !== null) {
return typeof fallback === "object" ? JSON.parse(storedValue) : storedValue; return typeof fallback === 'object' ? JSON.parse(storedValue) : storedValue;
}
} }
return fallback; }
return fallback;
} }
function toLocalStorage(store: Writable<string[]>, storageKey: string) { function toLocalStorage(store: Writable<string[]>, storageKey: string) {
if (browser) { if (browser) {
store.subscribe((value) => { store.subscribe((value) => {
let storageValue = typeof value === "object" ? JSON.stringify(value.sort()) : value; let storageValue = typeof value === 'object' ? JSON.stringify(value.sort()) : value;
localStorage.setItem(storageKey, storageValue); localStorage.setItem(storageKey, storageValue);
}); });
} }
} }

View File

@ -1,44 +1,43 @@
export const tocs = new Map<string, string>([ export const tocs = new Map<string, string>([
["gw", "Great Western Railway"], ['gw', 'Great Western Railway'],
["sw", "South Western Railway"], ['sw', 'South Western Railway'],
["il", "Island Line"], ['il', 'Island Line'],
["nt", "Northern"], ['nt', 'Northern'],
["aw", "Trafnidiaeth Cymru"], ['aw', 'Transport for Wales'],
["cc", "c2c"], ['cc', 'c2c'],
["cs", "Caledonian Sleeper"], ['cs', 'Caledonian Sleeper'],
["ch", "Chiltern Railways"], ['ch', 'Chiltern Railways'],
["xc", "CrossCountry"], ['xc', 'CrossCountry'],
["em", "East Midlands Railway"], ['em', 'East Midlands Railway'],
["es", "Eurostar"], ['es', 'Eurostar'],
["ht", "Hull Trains"], ['ht', 'Hull Trains'],
["tl", "Thameslink"], ['tl', 'Thameslink'],
["gc", "Grand Central"], ['gc', 'Grand Central'],
["gx", "Gatwick Express"], ['gx', 'Gatwick Express'],
["hx", "Heathrow Express"], ['hx', 'Heathrow Express'],
["ls", "Locomotive Services Limited"], ['ls', 'Locomotive Services Limited'],
["me", "Merseyrail"], ['me', 'Merseyrail'],
["lr", "Network Rail OTM"], ['lr', 'Network Rail OTM'],
["xr", "TfL Elizabeth Line"], ['xr', 'TfL Elizabeth Line'],
["se", "Southeastern"], ['se', 'Southeastern'],
["sn", "Southern"], ['sn', 'Southern'],
["le", "Greater Anglia"], ['le', 'Greater Anglia'],
["ga", "Greater Anglia"], ['ga', 'Greater Anglia'],
["lm", "West Midlands Railway (LM)"], ['lm', 'West Midlands Railway'],
["sr", "ScotRail"], ['sr', 'ScotRail'],
["gn", "Great Northern"], ['gn', 'Great Northern'],
["lt", "TfL London Underground"], ['lt', 'TfL London Underground'],
["lo", "TfL London Overground"], ['lo', 'TfL London Overground'],
["sj", "SuperTram (Sheffield)"], ['sj', 'Sheffield SuperTram'],
["tp", "TransPennine Express"], ['tp', 'TransPennine Express'],
["vt", "Avanti West Coast"], ['vt', 'Avanti West Coast'],
["gr", "LNER"], ['gr', 'LNER'],
["wr", "West Coast Railway"], ['wr', 'West Coast Railway'],
["ty", "Vintage Trains"], ['ty', 'Vintage Trains'],
["tw", "Nexus (Tyne & Wear Metro)"], ['ld', 'Lumo'],
["ld", "Lumo"], ['so', 'Rail Adventure'],
["so", "Rail Adventure"], ['ln', 'Grand Union Trains'],
["ln", "Grand Union Trains"], ['zz', 'Freight/Charter Company'],
["zz", "Freight/Charter Company"], ['wm', 'West Midlands Railway (WMT)'],
["wm", "West Midlands Railway (WM)"], ['uk', 'Unknown Operator']
["uk", "Unknown Operator"],
]); ]);

View File

@ -1,23 +1,23 @@
import { writable } from "svelte/store"; import { writable } from 'svelte/store';
import { browser } from "$app/environment"; import { browser } from '$app/environment';
export const uuid = writable(fromLocalStorage("uuid", null)); export const uuid = writable(fromLocalStorage('uuid', null));
toLocalStorage(uuid, "uuid"); toLocalStorage(uuid, 'uuid');
function fromLocalStorage(storageKey, fallback) { function fromLocalStorage(storageKey, fallback) {
if (browser) { if (browser) {
const storedValue = localStorage.getItem(storageKey); const storedValue = localStorage.getItem(storageKey);
if (storedValue !== "undefined") { if (storedValue !== 'undefined') {
return storedValue; return storedValue;
}
} }
return fallback; }
return fallback;
} }
function toLocalStorage(store, storageKey) { function toLocalStorage(store, storageKey) {
if (browser) { if (browser) {
store.subscribe((value) => { store.subscribe((value) => {
localStorage.setItem(storageKey, value); localStorage.setItem(storageKey, value);
}); });
} }
} }

View File

@ -1,2 +1,3 @@
export const version: string = "2024.10.1"; export const version: string = '2024.2.1';
export const versionTag: string = ""; export const versionTag: string = '';
export const showWelcome: boolean = true;

23
src/lib/stores/welcome.ts Normal file
View File

@ -0,0 +1,23 @@
import { writable, type Writable } from 'svelte/store';
import { browser } from '$app/environment';
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;
}
}
return fallback;
}
function toLocalStorage(store: Writable<any>, storageKey: string) {
if (browser) {
store.subscribe((value: string) => {
localStorage.setItem(storageKey, value);
});
}
}

View File

@ -19,25 +19,24 @@
/* Main Theme */ /* Main Theme */
:root { :root {
--main-bg-color: #404c55; --main-bg-color: #404c55;
--second-bg-color: #2b343c; --second-bg-color: #2b343c;
--main-header-color: #dff3f3; --main-header-color: #dff3f3;
--main-text-color: #cce9e9; --main-text-color: #cce9e9;
--secondary-text-color: #02fcfc; --secondary-text-color: #02fcfc;
--main-link-color: #00b7b7; --main-link-color: #00b7b7;
--island-bg-color: #3c6f79de; --island-bg-color: #3c6f79de;
--island-bg-solid: #3c6f79; --island-bg-solid: #3c6f79;
--island-button-color: #404c55; --island-button-color: #404c55;
--island-link-color: #e1ebeb; --island-link-color: #e1ebeb;
--island-header-color: #4fd1d1; --island-header-color: #4fd1d1;
--island-text-color: #e1ebeb; --island-text-color: #e1ebeb;
--overlay-island-bg-color: #3c6f79; --overlay-island-bg-color: #3c6f79;
--box-shadow-color: rgba(0, 0, 0, 0.19); --box-shadow-color: rgba(0, 0, 0, 0.19);
--box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.19); --box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.19);
--box-shadow-dark: 2px 2px 4px rgba(0, 0, 0, 0.392); --main-alert-color: #ed6d00;
--main-alert-color: #ed6d00; --second-alert-color: #e77f00;
--second-alert-color: #e77f00; --main-warning-color: orange;
--main-warning-color: orange;
} }
/* Christmas Theme /* Christmas Theme

View File

@ -1,33 +1,31 @@
<script lang="ts"> <script lang="ts">
import type { OB_Pis_SimpleObject } from "@owlboard/ts-types"; import type { OB_Pis_SimpleObject } from '@owlboard/ts-types';
export let pisObject: OB_Pis_SimpleObject; export let pisObject: OB_Pis_SimpleObject;
</script> </script>
{#if pisObject} {#if pisObject}
{#if typeof pisObject === "string" || typeof pisObject === "number"} {#if typeof pisObject === 'string' || typeof pisObject === 'number'}
<span class="pis">PIS: {pisObject}</span> <span class="pis">PIS: {pisObject}</span>
{:else if pisObject["skipCount"] === 0} {:else if pisObject['skipCount'] === 0}
<span class="pis">PIS: {pisObject.code}</span> <span class="pis">PIS: {pisObject.code}</span>
{:else if pisObject["skipCount"] > 0} {:else if pisObject['skipCount'] > 0}
<span class="pis">PIS: {pisObject.code}</span> <span class="pis">PIS: {pisObject.code}</span>
<br /> <br>
<span class="pis-text" <span class="pis-text">(skip first {pisObject.skipType}{#if pisObject.skipCount > 1} {" " + pisObject.skipCount} stops{:else} stop{/if})</span>
>(skip {pisObject.skipType}{#if pisObject.skipCount > 1} {" " + pisObject.skipCount} stops{:else} stop{/if})</span {/if}
>
{/if}
{/if} {/if}
<style> <style>
.pis-text { .pis-text {
font-size: 14px; font-size: 14px;
font-weight: 600; font-weight: 600;
color: var(--main-text-color); color: var(--main-text-color);
} }
.pis { .pis {
font-size: 18px; font-size: 18px;
font-weight: 600; font-weight: 600;
color: var(--main-text-color); color: var(--main-text-color);
} }
</style> </style>

View File

@ -1,223 +1,223 @@
<script lang="ts"> <script lang="ts">
export let toc: string; export let toc: string;
export let full: boolean = false; export let full: boolean = false;
import { tocs as map } from "$lib/stores/tocMap"; import { tocs as map } from '$lib/stores/tocMap';
let text: string; let text: string;
$: { $: {
if (full) { if (full) {
text = map.get(toc.toLowerCase()) || toc; text = map.get(toc.toLowerCase()) || toc;
} else { } else {
text = toc; text = toc;
}
} }
}
</script> </script>
<span class={toc.toLocaleLowerCase()}>{text}</span> <span class={toc.toLocaleLowerCase()}>{text}</span>
<style> <style>
span { span {
padding: 4px; padding: 4px;
border-radius: 5px; border-radius: 5px;
border-style: solid; border-style: solid;
border-width: 1px; border-width: 1px;
background-color: white; background-color: white;
color: black; color: black;
} }
.gw { .gw {
/* GWR */ /* GWR */
background-color: #07352d; background-color: #07352d;
color: white; color: white;
border-color: #041d18; border-color: #041d18;
} }
.sw, .sw,
.il { .il {
/* SWR & Island Line */ /* SWR & Island Line */
background-color: rgb(17, 23, 23); background-color: rgb(17, 23, 23);
color: white; color: white;
} }
.nt { .nt {
/* Northern */ /* Northern */
background-color: rgb(38, 34, 98); background-color: rgb(38, 34, 98);
color: white; color: white;
} }
.aw { .aw {
/* TfW */ /* TfW */
background-color: red; background-color: red;
color: white; color: white;
} }
.cc { .cc {
/* c2c */ /* c2c */
background-color: rgb(168, 25, 127); background-color: rgb(168, 25, 127);
color: white; color: white;
} }
.cs { .cs {
/* Caledonian Sleeper */ /* Caledonian Sleeper */
background-color: #033c3c; background-color: #033c3c;
color: white; color: white;
} }
.ch { .ch {
/* Chiltern Railways */ /* Chiltern Railways */
background-color: white; background-color: white;
color: blue; color: blue;
} }
.xc { .xc {
/* CrossCountry */ /* CrossCountry */
background-color: rgb(76, 18, 58); background-color: rgb(76, 18, 58);
color: white; color: white;
} }
.em { .em {
/* EMR */ /* EMR */
background-color: rgb(69, 29, 69); background-color: rgb(69, 29, 69);
color: white; color: white;
} }
.es { .es {
/* Eurostar */ /* Eurostar */
background-color: rgb(13, 13, 98); background-color: rgb(13, 13, 98);
color: yellow; color: yellow;
} }
.zz { .zz {
/* Freight, Charters, etc */ /* Freight, Charters, etc */
background-color: rgba(255, 255, 255, 0); background-color: rgba(255, 255, 255, 0);
color: white; color: white;
} }
.ht { .ht {
/* Hull Trains */ /* Hull Trains */
background-color: rgb(160, 0, 136); background-color: rgb(160, 0, 136);
color: rgb(19, 19, 173); color: rgb(19, 19, 173);
} }
.gn { .gn {
/* GTR Great Northern */ /* GTR Great Northern */
background-color: rgb(79, 0, 128); background-color: rgb(79, 0, 128);
color: white; color: white;
} }
.tl { .tl {
/* GTR Thameslink */ /* GTR Thameslink */
background-color: rgb(191, 25, 183); background-color: rgb(191, 25, 183);
color: white; color: white;
} }
.gc { .gc {
/* Grand Central */ /* Grand Central */
background-color: rgb(40, 40, 40); background-color: rgb(40, 40, 40);
color: rgb(219, 123, 5); color: rgb(219, 123, 5);
} }
.le, .le,
.ga { .ga {
/*Greater Anglia */ /*Greater Anglia */
background-color: rgb(122, 124, 154); background-color: rgb(122, 124, 154);
color: rgb(151, 0, 0); color: rgb(151, 0, 0);
border-color: red; border-color: red;
} }
.hx { .hx {
/* Heathrow Express */ /* Heathrow Express */
background-color: rgb(181, 142, 211); background-color: rgb(181, 142, 211);
color: black; color: black;
} }
.ls { .ls {
/* Locomotive Services Limited */ /* Locomotive Services Limited */
background-color: white; background-color: white;
color: black; color: black;
} }
.lm { .lm {
/* West Midlands Railway */ /* West Midlands Railway */
background-color: rgb(120, 120, 120); background-color: rgb(120, 120, 120);
border-color: rgb(230, 150, 0); border-color: rgb(230, 150, 0);
color: white; color: white;
} }
.lo { .lo {
/*London Overground */ /*London Overground */
background-color: rgb(231, 150, 0); background-color: rgb(231, 150, 0);
color: rgb(0, 0, 210); color: rgb(0, 0, 210);
} }
.lt { .lt {
/* London Underground (when on Network Rail Metals) */ /* London Underground (when on Network Rail Metals) */
background-color: rgb(203, 17, 17); background-color: rgb(203, 17, 17);
color: rgb(0, 0, 210); color: rgb(0, 0, 210);
} }
.me { .me {
/* Merseyrail */ /* Merseyrail */
background-color: rgb(229, 229, 16); background-color: rgb(229, 229, 16);
color: rgb(96, 96, 96); color: rgb(96, 96, 96);
} }
.lr { .lr {
/* NR On-Track Machines */ /* NR On-Track Machines */
background-color: yellow; background-color: yellow;
color: black; color: black;
} }
.tw { .tw {
/* Tyne & Wear Metro (when on Network Rail Metals) */ /* Tyne & Wear Metro (when on Network Rail Metals) */
background-color: rgb(212, 169, 0); background-color: rgb(212, 169, 0);
color: black; color: black;
} }
.sr { .sr {
/* ScotRail */ /* ScotRail */
background-color: rgb(16, 16, 200); background-color: rgb(16, 16, 200);
color: white; color: white;
} }
.sj { .sj {
/* South Yorkshire (Sheffield) SuperTram (When on network rail metals) */ /* South Yorkshire (Sheffield) SuperTram (When on network rail metals) */
background-color: rgb(255, 185, 56); background-color: rgb(255, 185, 56);
color: rgb(58, 58, 255); color: rgb(58, 58, 255);
} }
.se { .se {
/* Southeastern */ /* Southeastern */
background-color: darkblue; background-color: darkblue;
color: rgb(107, 152, 207); color: rgb(107, 152, 207);
} }
.sn { .sn {
/* GTR (Southern) */ /* GTR (Southern) */
background-color: rgb(11, 74, 11); background-color: rgb(11, 74, 11);
color: rgb(231, 231, 188); color: rgb(231, 231, 188);
} }
.xr { .xr {
/* Elizabeth Line (EastWest CrossRail) */ /* Elizabeth Line (EastWest CrossRail) */
background-color: rgb(91, 0, 171); background-color: rgb(91, 0, 171);
color: rgb(207, 207, 255); color: rgb(207, 207, 255);
} }
.tp { .tp {
/* TransPennine Express */ /* TransPennine Express */
background-color: rgb(197, 130, 238); background-color: rgb(197, 130, 238);
color: rgb(0, 98, 226); color: rgb(0, 98, 226);
} }
.vt { .vt {
/* Avanti West Coast */ /* Avanti West Coast */
background-color: rgb(37, 37, 86); background-color: rgb(37, 37, 86);
color: rgb(230, 96, 0); color: rgb(230, 96, 0);
} }
.gr { .gr {
/* LNER */ /* LNER */
background-color: rgb(202, 0, 0); background-color: rgb(202, 0, 0);
color: white; color: white;
} }
.wc { .wc {
/* West Coast Railway (Spot Hire/Charter) */ /* West Coast Railway (Spot Hire/Charter) */
background-color: maroon; background-color: maroon;
color: rgb(225, 190, 92); color: rgb(225, 190, 92);
} }
.ty { .ty {
/* Vintage Trains (Tour Operator) */ /* Vintage Trains (Tour Operator) */
background-color: green; background-color: green;
color: white; color: white;
} }
.ld { .ld {
/* Lumo */ /* Lumo */
background-color: whitesmoke; background-color: whitesmoke;
color: blue; color: blue;
} }
.so { .so {
/* Rail Adventure */ /* Rail Adventure */
background-color: rgb(93, 93, 93); background-color: rgb(93, 93, 93);
color: rgb(93, 195, 93); color: rgb(93, 195, 93);
} }
.ln { .ln {
/* Grand Union Trains */ /* Grand Union Trains */
background-color: rgb(89, 89, 89); background-color: rgb(89, 89, 89);
color: white; color: white;
} }
.uk { .uk {
background-color: whitesmoke; background-color: whitesmoke;
color: black; color: black;
} }
</style> </style>

View File

@ -1,187 +1,179 @@
<script lang="ts"> <script>
import { fly } from "svelte/transition"; import { fly } from 'svelte/transition';
import { uuid } from "$lib/stores/uuid"; import { uuid } from '$lib/stores/uuid';
import LoadingText from "$lib/navigation/loading-text.svelte"; import LoadingText from '$lib/navigation/loading-text.svelte';
import StylesToc from "./styles-toc.svelte"; import StylesToc from './styles-toc.svelte';
import { getApiUrl } from "$lib/scripts/upstream"; import { getApiUrl } from '$lib/scripts/upstream';
import PisHandler from "$lib/train/pis-handler.svelte"; import PisHandler from '$lib/train/pis-handler.svelte';
import type { OB_TrainTT_service } from "@owlboard/ts-types"; export let service = '';
import TrainIcons from "./trainIcons.svelte";
export let service: OB_TrainTT_service; let isExpanded = false;
let isExpanded = false; async function getTrainByUID(tuid = '') {
const url = `${getApiUrl()}/api/v2/timetable/train/now/byTrainUid/${tuid}`;
async function getTrainByUID(tuid = "") { const options = {
const url = `${getApiUrl()}/api/v2/timetable/train/now/byTrainUid/${tuid}`; method: 'GET',
const options = { headers: {
method: "GET", uuid: $uuid
headers: { }
uuid: $uuid, };
}, const res = await fetch(url, options);
}; if (res.status === 200) {
const res = await fetch(url, options); return await res.json();
if (res.status === 200) { } else {
return await res.json(); throw new Error('Unable to Fetch');
} else {
throw new Error("Unable to Fetch");
}
} }
}
async function expand() { async function expand() {
isExpanded = !isExpanded; isExpanded = !isExpanded;
} }
</script> </script>
<div class="container"> <div class="container">
<div class="container-header" on:click={expand} on:keypress={expand}> <div class="container-header" on:click={expand} on:keypress={expand}>
<span class="header" <span class="header"
><StylesToc toc={service?.operator || ""} /> ><StylesToc toc={service?.operator || ''} />
{service?.stops[0]["publicDeparture"] || service?.stops[0]["wttDeparture"]} {service?.stops[0]['publicDeparture'] || service?.stops[0]['wttDeparture']}
{service?.stops[0]["tiploc"]} to {service?.stops[service["stops"].length - 1]["tiploc"]}</span {service?.stops[0]['tiploc']} to {service?.stops[service['stops'].length - 1]['tiploc']}</span
> >
<span id="container-arrow" class:isExpanded>V</span> <span id="container-arrow" class:isExpanded>V</span>
</div> </div>
{#if isExpanded} {#if isExpanded}
<div class="container-detail" in:fly={{ y: -20, duration: 200 }}> <div class="container-detail" in:fly={{ y: -20, duration: 200 }}>
{#await getTrainByUID(service.trainUid)} {#await getTrainByUID(service.trainUid)}
<LoadingText /> <LoadingText />
{:then serviceDetail} {:then serviceDetail}
{#if serviceDetail.stpIndicator === "C"} {#if serviceDetail.stpIndicator === 'C'}
<p class="text-message">This has been removed from the timetable for today.</p> <p class="text-message">This has been removed from the timetable for today.<br /><br>
<p class="text-message">The service may have been retimed, re-routed or removed from todays timetable completely.</p> The service will not run, another service may be running in its place.</p>
<p class="text-message">If it has been retimed or re-routed, there is likely to be another service with the same headcode booked to run.</p> {:else}
{:else} {#if serviceDetail.vstp}
<div class="detailOperator"><StylesToc toc={service?.operator || ""} full={true} /></div> <div class="vstp">VSTP</div>
{/if}
<TrainIcons serviceDetails={serviceDetail.serviceDetail} /> <div class="detailOperator"><StylesToc toc={service?.operator || ''} full={true} /></div>
{#if serviceDetail.pis} {#if serviceDetail.pis}
<PisHandler pisObject={serviceDetail.pis} /> <PisHandler pisObject={serviceDetail.pis} />
{/if} {/if}
<p class="svc-detail"> <p class="svc-detail">
Planned Type: {parseInt(serviceDetail.planSpeed) || "--"}mph {serviceDetail.powerType || "Non-Rail vehicle"} Planned Type: {parseInt(serviceDetail.planSpeed) || '--'}mph {serviceDetail.powerType || 'Non-Rail vehicle'}
</p> </p>
<p class="svc-detail"> <p class="svc-detail">
Days Run: {serviceDetail?.daysRun.join(", ").toUpperCase() || "Unknown"} Days Run: {serviceDetail?.daysRun.join(', ').toUpperCase() || 'Unknown'}
</p> </p>
<p class="svc-detail validity"> <p class="svc-detail validity">
Valid From: {new Date(serviceDetail.scheduleStart).toLocaleDateString("en-GB", { Valid From: {new Date(serviceDetail.scheduleStart).toLocaleDateString('en-GB', {
timeZone: "UTC", timeZone: 'UTC'
})} - {new Date(serviceDetail.scheduleEnd).toLocaleDateString("en-GB", { })} - {new Date(serviceDetail.scheduleEnd).toLocaleDateString('en-GB', {
timeZone: "UTC", timeZone: 'UTC'
})} })}
</p> </p>
<table> <table>
<caption>Italics are 'pass' times, grey times are non-passenger stops</caption> <tr>
<tr> <th>Location</th>
<th>Location</th> <th>Sch Arr.</th>
<th>Plt.</th> <th>Sch Dep.</th>
<th>Sch Arr.</th> </tr>
<th>Sch Dep.</th> {#if serviceDetail.stops[0]['publicDeparture']}
</tr> {#each serviceDetail.stops as stop}
{#each serviceDetail.stops as stop} {#if stop.publicArrival || stop.publicDeparture}
<tr> <tr>
{#if stop.publicArrival || stop.publicDeparture} <td>{stop.tiploc}</td>
<td>{stop.tiploc}</td> <td>{stop.publicArrival || '-'}</td>
<td>{stop.platform || "-"}</td> <td>{stop.publicDeparture || '-'}</td>
<td>{stop.publicArrival || "-"}</td> </tr>
<td>{stop.publicDeparture || "-"}</td>
{:else if stop.wttArrival || stop.wttDeparture}
<td class="wtt">{stop.tiploc}</td>
<td class="wtt">{stop.platform || stop.depLine || stop.arrLine || "-"}</td>
<td class="wtt">{stop.wttArrival || "-"}</td>
<td class="wtt">{stop.wttDeparture || "-"}</td>
{:else}
<td class="pass">{stop.tiploc}</td>
<td class="pass">{stop.platform || stop.depLine || stop.arrLine || "-"}</td>
<td class="pass">-</td>
<td class="pass">{stop.pass || "-"}</td>
{/if}
</tr>
{/each}
</table>
{/if} {/if}
{:catch} {/each}
<p>Unable to fetch train data</p> {:else}
{/await} {#each serviceDetail.stops as stop}
</div> <tr>
{/if} <td>{stop.tiploc}</td>
<td>{stop.wttArrival || '-'}</td>
<td>{stop.wttDeparture || '-'}</td>
</tr>
{/each}
{/if}
</table>
{/if}
{:catch}
<p>Unable to fetch train data</p>
{/await}
</div>
{/if}
</div> </div>
<style> <style>
.container { .container {
position: relative; position: relative;
margin: auto; margin: auto;
margin-bottom: 20px; margin-bottom: 20px;
width: 95%; width: 95%;
max-width: 600px; max-width: 600px;
height: auto; height: auto;
background-color: var(--island-bg-solid); background-color: var(--island-bg-solid);
border-radius: 10px; border-radius: 10px;
overflow: hidden; overflow: hidden;
transition: height 500ms ease-in-out; transition: height 500ms ease-in-out;
box-shadow: 5px 5px 30px var(--box-shadow-color); box-shadow: 5px 5px 30px var(--box-shadow-color);
} }
.container-header { .container-header {
text-align: left; text-align: left;
padding-left: 10px; padding-left: 10px;
font-size: 18px; font-size: 18px;
font-weight: 600; font-weight: 600;
padding-top: 12px; padding-top: 12px;
padding-bottom: 10px; padding-bottom: 10px;
font-family: ubuntu, monospace; font-family: ubuntu, monospace;
color: var(--island-text-color); color: var(--island-text-color);
} }
#container-arrow { #container-arrow {
font-family: Arial, Helvetica, sans-serif; font-family: Arial, Helvetica, sans-serif;
font-weight: 600; font-weight: 600;
color: var(--island-text-color); color: var(--island-text-color);
margin: 0; margin: 0;
padding: 0; padding: 0;
position: absolute; position: absolute;
right: 16px; right: 16px;
top: 10px; top: 10px;
transition-duration: 300ms; transition-duration: 300ms;
z-index: 2; z-index: 2;
} }
.isExpanded { .isExpanded {
transform: rotate(180deg); transform: rotate(180deg);
} }
.detailOperator { .detailOperator {
padding-top: 15px; padding-top: 15px;
margin-bottom: 15px; margin-bottom: 15px;
font-weight: 600; font-weight: 600;
} }
.svc-detail { .svc-detail {
margin-top: 6px; margin-top: 6px;
margin-bottom: 2px; margin-bottom: 2px;
color: var(--island-text-color); color: var(--island-text-color);
} }
.validity { .validity {
font-size: 14px; font-size: 14px;
} }
table { table {
margin: auto; margin: auto;
padding-top: 5px; padding-top: 10px;
padding-bottom: 10px; padding-bottom: 10px;
color: var(--island-text-color); color: var(--island-text-color);
} }
caption { .text-message {
padding-top: 15px; margin: 5px;
font-size: small; margin-left: 20px;
} margin-right: 20px;
.wtt { padding-bottom: 10px;
opacity: 0.5; }
} .vstp {
.pass { background-color: red;
font-style: italic; margin: auto;
opacity: 0.5; padding: 5px;
} width: 50px;
.text-message { border-radius: 5px;
margin: 5px; border-color: darkred;
margin-left: 20px; font-weight: bolder;
margin-right: 20px; }
padding-bottom: 10px;
}
</style> </style>

View File

@ -1,39 +0,0 @@
<script lang="ts">
import Tooltip from "$lib/Tooltip.svelte";
import type { ServiceDetail } from "@owlboard/ts-types";
import { IconBed, IconSquare1, IconSquareLetterV, IconToolsKitchen2 } from "@tabler/icons-svelte";
export let serviceDetails: ServiceDetail;
</script>
{#if serviceDetails.firstClass}
<Tooltip text="First Class is available">
<IconSquare1 />
</Tooltip>
{/if}
{#if serviceDetails.catering}
<Tooltip text="Catering is available">
<IconToolsKitchen2 />
</Tooltip>
{/if}
{#if serviceDetails.sleeper}
<Tooltip text="Sleeping Berths are available">
<IconBed />
</Tooltip>
{/if}
{#if serviceDetails.vstp}
<Tooltip text="This is a VSTP planned service">
<IconSquareLetterV />
</Tooltip>
{/if}
<!-- Render a newline if any of the icons is to appear -->
{#if serviceDetails.firstClass || serviceDetails.catering || serviceDetails.sleeper || serviceDetails.vstp}
<br />
{/if}
<style>
</style>

View File

@ -1,8 +1,8 @@
<script> <script>
import { page } from "$app/stores"; import { page } from '$app/stores';
import Header from "$lib/navigation/header.svelte"; import Header from '$lib/navigation/header.svelte';
import Nav from "$lib/navigation/nav.svelte"; import Nav from '$lib/navigation/nav.svelte';
const title = "OwlBoard - Error"; const title = 'OwlBoard - Error';
</script> </script>
<Header {title} /> <Header {title} />
@ -10,16 +10,16 @@
<h1>{$page.status}: {$page?.error?.message}</h1> <h1>{$page.status}: {$page?.error?.message}</h1>
{#if $page.status === 404} {#if $page.status === 404}
<p>This is not the page you're looking for.</p> <p>This is not the page you're looking for.</p>
<p>The page you are looking for doesn't exist, use the tabs below to find another page.</p> <p>The page you are looking for doesn't exist, use the tabs below to find another page.</p>
{:else if $page.status === 500} {:else if $page.status === 500}
<p> <p>
Something went wrong loading the app.<br /> Something went wrong loading the app.<br />
Try going <a href="/">home</a> and try again. Try going <a href="/">home</a> and try again.
</p> </p>
<p>If the problem persists, you can report an issue from the 'More' menu.</p> <p>If the problem persists, you can report an issue from the 'More' menu.</p>
{:else} {:else}
<p>Not sure what went wrong, please try again later or report an issue from the 'More' menu.</p> <p>Not sure what went wrong, please try again later or report an issue from the 'More' menu.</p>
{/if} {/if}
<Nav /> <Nav />

View File

@ -1,43 +1,27 @@
<script> <script>
import "$lib/themes.css"; import '$lib/themes.css';
import "$lib/main.css"; import '$lib/main.css';
import { dev } from "$app/environment"; import { dev } from '$app/environment';
import DevBanner from "$lib/DevBanner.svelte"; import DevBanner from '$lib/DevBanner.svelte';
import { page } from "$app/stores"; import { page } from '$app/stores';
import { Toaster } from "svelte-french-toast";
</script> </script>
<svelte:head> <svelte:head>
<!-- <meta name="application-name" content="OwlBoard" />
___ _ ___ _ <meta name="author" content="Frederick Boniface" />
/ _ \__ __ _| | _ ) ___ __ _ _ _ __| | <meta
| (_) \ V V / | _ \/ _ \/ _` | '_/ _` | name="description"
\___/ \_/\_/|_|___/\___/\__,_|_| \__,_| content="Get instant access to live train data, PIS codes, and location reference codes. Built by railway staff, for railway staff your fastest route to accurate information."
Check out the source code on Gitea (https://git.fjla.net/OwlBoard) />
It's easier to read there <meta name="viewport" content="width=device-width" />
--> <meta name="theme-color" content="#00b7b7" />
<link rel="canonical" href="https://owlboard.info{$page.url.pathname}" />
<meta name="application-name" content="OwlBoard" /> <link rel="icon" href="/images/icon.svg" type="image/svg+xml" />
<meta name="author" content="Frederick Boniface" /> <link rel="apple-touch-icon" href="/images/app-icons/any/apple-192.png" />
<meta <link rel="manifest" href="/manifest.json" />
name="description" <title>OwlBoard</title>
content="Get instant access to live train data, PIS codes, and location reference codes. Built by railway staff, for railway staff - your fastest route to accurate information."
/>
<meta name="viewport" content="width=device-width" />
<meta name="theme-color" content="#00b7b7" />
<link rel="canonical" href="https://owlboard.info{$page.url.pathname}" />
<link rel="icon" href="/images/icon.svg" type="image/svg+xml" />
<link rel="apple-touch-icon" href="/images/app-icons/any/apple-192.png" />
<link rel="manifest" href="/manifest.json" />
<title>OwlBoard</title>
</svelte:head> </svelte:head>
<Toaster />
{#if dev} {#if dev}
<DevBanner /> <DevBanner />
{/if} {/if}
<slot /> <slot />
<style>
</style>

View File

@ -1,48 +1,38 @@
<script lang="ts"> <script>
import Header from "$lib/navigation/header.svelte"; import Header from '$lib/navigation/header.svelte';
import Nav from "$lib/navigation/nav.svelte"; import Nav from '$lib/navigation/nav.svelte';
import { featureDetect } from "$lib/scripts/featureDetect"; import InputIsland from '$lib/islands/input-island-form.svelte';
import { onMount } from "svelte"; import QuickLinkIsland from '$lib/islands/quick-link-island.svelte';
import toast from "svelte-french-toast"; import Welcome from '$lib/overlays/welcome.svelte';
import type { LookupCardConfig } from "$lib/cards/Card.types"; import { welcome } from '$lib/stores/welcome';
import LookupCard from "$lib/cards/LookupCard.svelte"; import { version, showWelcome } from '$lib/stores/version';
import NearToMeCard from "$lib/cards/NearToMeCard.svelte";
import QuickLinkCard from "$lib/cards/QuickLinkCard.svelte";
const title = "OwlBoard";
const lookupCards: LookupCardConfig[] = [
{
title: "Live Arr/Dep Boards",
helpText: "",
formAction: "/ldb",
placeholder: "enter crs/tiploc",
maxLen: 7,
fieldName: "station",
},
{
title: "Timetable & PIS",
helpText: "",
formAction: "/train",
placeholder: "enter headcode",
maxLen: 4,
fieldName: "headcode",
},
];
onMount(async () => { const title = 'OwlBoard';
const featureSupport = featureDetect(); const inputIslands = [
if (!featureSupport.critical) { {
toast.error("Your browser is missing critical features, OwlBoard might not work properly. See `Menu > Statistics` for more information."); title: 'Live Departure Boards',
} else if (!featureSupport.nice) { action: '/ldb',
toast.error("Your browser is missing some features, see `Menu > Statistics` for more information."); placeholder: 'Enter CRS/TIPLOC',
} queryName: 'station'
}); },
{
title: 'Train Details & PIS',
action: '/train',
placeholder: 'Enter Headcode',
queryName: 'headcode'
}
];
</script> </script>
{#if showWelcome && ($welcome === 'null' || !$welcome || parseInt($welcome.replace(/\./g, '')) < parseInt(version.replace(/\./g, '')))}
<Welcome />
{/if}
<Header {title} /> <Header {title} />
{#each lookupCards as config}
<LookupCard {config} /> {#each inputIslands as variables}
<InputIsland {variables} />
{/each} {/each}
<NearToMeCard />
<QuickLinkCard /> <QuickLinkIsland />
<Nav /> <Nav />

View File

@ -1,8 +1,8 @@
<script lang="ts"> <script lang="ts">
import Header from "$lib/navigation/header.svelte"; import Header from '$lib/navigation/header.svelte';
import Nav from "$lib/navigation/nav.svelte"; import Nav from '$lib/navigation/nav.svelte';
const title = "404 - Not Found"; const title = '404 - Not Found';
</script> </script>
<Header {title} /> <Header {title} />
@ -14,10 +14,10 @@
<Nav /> <Nav />
<style> <style>
.heading { .heading {
color: var(--second-text-color); color: var(--second-text-color);
} }
.err_code { .err_code {
color: white; color: white;
} }
</style> </style>

View File

@ -1,8 +1,8 @@
<script lang="ts"> <script lang="ts">
import Header from "$lib/navigation/header.svelte"; import Header from '$lib/navigation/header.svelte';
import Nav from "$lib/navigation/nav.svelte"; import Nav from '$lib/navigation/nav.svelte';
const title = "50x - Server Error"; const title = '50x - Server Error';
</script> </script>
<Header {title} /> <Header {title} />
@ -14,10 +14,10 @@
<Nav /> <Nav />
<style> <style>
.heading { .heading {
color: var(--second-text-color); color: var(--second-text-color);
} }
.err_code { .err_code {
color: white; color: white;
} }
</style> </style>

View File

@ -1,45 +1,42 @@
<script lang="ts"> <script>
import Header from "$lib/navigation/header.svelte"; import Header from '$lib/navigation/header.svelte';
import Nav from "$lib/navigation/nav-ldb.svelte"; import Nav from '$lib/navigation/nav-ldb.svelte';
import PublicLdb from "$lib/ldb/public-ldb.svelte"; import PublicLdb from '$lib/ldb/public-ldb.svelte';
import StaffLdb from "$lib/ldb/staff/staff-ldb.svelte"; import StaffLdb from '$lib/ldb/staff/staff-ldb.svelte';
import { uuid } from "$lib/stores/uuid.js"; import { uuid } from '$lib/stores/uuid.js';
import { onMount } from "svelte"; import { onMount } from 'svelte';
let title = "Loading"; let title = 'Loading';
async function getHeadcode() { async function getHeadcode() {
return new URLSearchParams(window.location.search).get("station"); return new URLSearchParams(window.location.search).get('station');
}
let station = '';
let staff = false;
let uuidValue = '';
$: uuidValue = $uuid;
onMount(async () => {
station = (await getHeadcode()) || '';
if (uuidValue !== null && uuidValue !== '' && uuidValue !== 'null') {
staff = true;
title = 'Staff Board';
} else {
title = 'Public Board';
} }
});
let station: string;
let staff: boolean;
let uuidValue: string;
let blockLoading: boolean = true;
$: uuidValue = $uuid;
onMount(async () => {
station = (await getHeadcode()) || "";
if (uuidValue !== null && uuidValue !== "" && uuidValue !== "null") {
staff = true;
title = "Staff Board";
} else {
title = "Public Board";
}
blockLoading = false;
});
</script> </script>
<Header {title} /> <Header {title} />
{#if !blockLoading} <!-- If 'uuid' exists in store then load StaffLdb else load PublicLdb -->
{#if !staff} {#if !staff}
<PublicLdb {station} bind:title /> <PublicLdb {station} bind:title />
{:else} {:else}
<StaffLdb {station} bind:title /> <StaffLdb {station} bind:title />
{/if} <!--<StaffLdb {station} bind:title={title} /> -- Temporary, Disable StaffLdb - it isn't implemented -->
{/if} {/if}
<Nav /> <Nav />

View File

@ -1,89 +1,68 @@
<script> <script>
import Header from "$lib/navigation/header.svelte"; import Header from '$lib/navigation/header.svelte';
import Nav from "$lib/navigation/nav.svelte"; import Nav from '$lib/navigation/nav.svelte';
import { const title = 'More';
IconCode,
IconHelp,
IconInfoCircle,
IconLocation,
IconMessageCode,
IconNumber,
IconSettings,
IconSpy,
IconUser,
IconUserPlus,
IconVersions,
} from "@tabler/icons-svelte";
const title = "More";
const links = [ const links = [
{ title: "Your Data", path: "/more/data", icon: IconUser }, { title: 'Your Data', path: '/more/data' },
{ title: "Registration", path: "/more/reg", icon: IconUserPlus }, { title: 'Registration', path: '/more/reg' },
{ title: "Settings", path: "/more/settings", icon: IconSettings }, { title: 'Settings', path: '/more/settings' },
{ title: "Help", path: "/more/help", icon: IconHelp }, { title: 'Help', path: '/more/help' },
{ title: "About", path: "/more/about", icon: IconInfoCircle }, { title: 'About', path: '/more/about' },
{ title: "Location Reference Code Lookup", path: "/more/corpus", icon: IconLocation }, { title: 'Location Reference Code Lookup', path: '/more/corpus' },
{ title: "Reason Code Lookup", path: "/more/reasons", icon: IconMessageCode }, { title: 'Reason Code Lookup', path: '/more/reasons' },
{ title: "Privacy Policy", path: "/more/privacy", icon: IconSpy }, { title: 'Privacy Policy', path: '/more/privacy' },
{ title: "Component Versions", path: "/more/versions", icon: IconVersions }, { title: 'Component Versions', path: '/more/versions' },
{ title: "Statistics", path: "/more/statistics", icon: IconNumber }, { title: 'Statistics', path: '/more/statistics' }
]; ];
</script> </script>
<Header {title} /> <Header {title} />
{#each links as item} {#each links as item}
<a href={item.path}> <a href={item.path}>
<div> <div>
<svelte:component this={item.icon} /> <p>{item.title}</p>
<p>{item.title}</p> </div>
</div> </a>
</a>
{/each} {/each}
<Nav /> <Nav />
<style> <style>
div { div {
width: 100%; width: 100%;
background: rgba(0, 0, 0, 0.226); background: rgba(0, 0, 0, 0.226);
border-color: aliceblue; border-color: aliceblue;
border-width: 1px; border-width: 1px;
border-style: solid; border-style: solid;
border-left: none; border-left: none;
padding-left: 0.5rem; border-right: none;
overflow-x: hidden; height: 50px;
border-right: none; }
height: 50px; a {
display: flex; text-decoration: none;
align-items: center; height: 100%;
margin-bottom: 0.5rem; vertical-align: middle;
} }
a { p {
text-decoration: none; color: white;
height: 100%; margin: 0;
vertical-align: middle; padding-left: 10px;
overflow-x: hidden; text-align: left;
} line-height: 50px;
vertical-align: middle;
font-weight: 600;
font-size: 20px;
}
@media (min-width: 600px) {
p { p {
color: white; text-align: center;
margin: 0;
padding-left: 10px;
text-align: left;
line-height: 50px;
vertical-align: middle;
font-weight: 600;
font-size: 20px;
overflow-x: hidden;
} }
@media (min-width: 600px) { }
p { @media (max-width: 380px) {
text-align: center; p {
} font-size: 16px;
}
@media (max-width: 380px) {
p {
font-size: 16px;
}
} }
}
</style> </style>

View File

@ -1,9 +1,9 @@
<script> <script>
import LargeLogo from "$lib/images/large-logo.svelte"; import LargeLogo from '$lib/images/large-logo.svelte';
import Header from "$lib/navigation/header.svelte"; import Header from '$lib/navigation/header.svelte';
import Nav from "$lib/navigation/nav.svelte"; import Nav from '$lib/navigation/nav.svelte';
const title = "About"; const title = 'About';
</script> </script>
<Header {title} /> <Header {title} />
@ -13,19 +13,19 @@
<p>I developed OwlBoard in 2022 with the aim of providing fast and easy access to the information we need on a daily basis.</p> <p>I developed OwlBoard in 2022 with the aim of providing fast and easy access to the information we need on a daily basis.</p>
<p>Data is sourced from National Rail Enquiries, the OwlBoard Project, and Network Rail.</p> <p>Data is sourced from National Rail Enquiries, the OwlBoard Project, and Network Rail.</p>
<p> <p>
OwlBoard components are available under various Open Source licenses. Please refer to the OwlBoard components are available under various Open Source licenses. Please refer to the
<a href="https://git.fjla.uk/OwlBoard" target="_blank">code repository</a> <a href="https://git.fjla.uk/OwlBoard" target="_blank">code repository</a>
for more detailed information. for more detailed information.
</p> </p>
<Nav /> <Nav />
<style> <style>
p { p {
margin-left: 10px; margin-left: 10px;
margin-right: 10px; margin-right: 10px;
} }
.neg { .neg {
margin-top: -40px; margin-top: -40px;
margin-bottom: 40px; margin-bottom: 40px;
} }
</style> </style>

View File

@ -1,78 +1,78 @@
<script> <script>
import Header from "$lib/navigation/header.svelte"; import Header from '$lib/navigation/header.svelte';
import Loading from "$lib/navigation/loading.svelte"; import Loading from '$lib/navigation/loading.svelte';
import Nav from "$lib/navigation/nav.svelte"; import Nav from '$lib/navigation/nav.svelte';
import { getApiUrl } from "$lib/scripts/upstream"; import { getApiUrl } from '$lib/scripts/upstream';
const title = "Location Codes"; const title = 'Location Codes';
let val = { let val = {
crs: "", crs: '',
tiploc: "", tiploc: '',
stanox: "", stanox: '',
nlc: "", nlc: '',
name: "", name: '',
uic: "", uic: ''
};
let isLoading = false;
async function getData(type = '', value = '') {
const url = `${getApiUrl()}/api/v2/ref/locationCode/${type}/${value}`;
const res = await fetch(url);
const data = await res.json();
isLoading = false;
return data;
}
async function processData(data) {
//console.log("data",JSON.stringify(data))
if (data.ERROR == 'Offline') {
return;
}
val = {
crs: data[0]['3ALPHA'] || 'None',
tiploc: data[0]['TIPLOC'] || 'None',
stanox: data[0]['STANOX'] || 'None',
nlc: data[0]['NLC'] || 'None',
name: data[0]['NLCDESC'] || 'None',
uic: data[0]['UIC'] || 'None'
}; };
//console.log("val",JSON.stringify(val));
}
let isLoading = false; async function submit() {
isLoading = true;
async function getData(type = "", value = "") { let data = [];
const url = `${getApiUrl()}/api/v2/ref/locationCode/${type}/${value}`; if (val?.crs) {
const res = await fetch(url); data = await getData('crs', val.crs);
const data = await res.json(); } else if (val?.tiploc) {
isLoading = false; data = await getData('tiploc', val.tiploc);
return data; } else if (val?.stanox) {
data = await getData('stanox', val.stanox);
} else if (val?.nlc) {
data = await getData('nlc', val.nlc);
} else {
return;
} }
processData(data);
}
async function processData(data) { async function reset() {
//console.log("data",JSON.stringify(data)) val = {
if (data.ERROR == "Offline") { crs: '',
return; tiploc: '',
} stanox: '',
val = { nlc: '',
crs: data[0]["3ALPHA"] || "None", name: '',
tiploc: data[0]["TIPLOC"] || "None", uic: ''
stanox: data[0]["STANOX"] || "None", };
nlc: data[0]["NLC"] || "None", }
name: data[0]["NLCDESC"] || "None",
uic: data[0]["UIC"] || "None",
};
//console.log("val",JSON.stringify(val));
}
async function submit() {
isLoading = true;
let data = [];
if (val?.crs) {
data = await getData("crs", val.crs);
} else if (val?.tiploc) {
data = await getData("tiploc", val.tiploc);
} else if (val?.stanox) {
data = await getData("stanox", val.stanox);
} else if (val?.nlc) {
data = await getData("nlc", val.nlc);
} else {
return;
}
processData(data);
}
async function reset() {
val = {
crs: "",
tiploc: "",
stanox: "",
nlc: "",
name: "",
uic: "",
};
}
</script> </script>
<Header {title} /> <Header {title} />
{#if isLoading} {#if isLoading}
<Loading /> <Loading />
{/if} {/if}
<p>Enter one of the codes below and press submit.</p> <p>Enter one of the codes below and press submit.</p>
@ -80,59 +80,59 @@
<p class="desc">Some locations only have some applicable location codes.</p> <p class="desc">Some locations only have some applicable location codes.</p>
<div class="inputs"> <div class="inputs">
<form on:submit={submit}> <form on:submit={submit}>
<input type="text" readonly placeholder="Name" bind:value={val.name} /> <input type="text" readonly placeholder="Name" bind:value={val.name} />
<br /> <br />
<input type="text" maxlength="3" autocomplete="off" placeholder="CRS/3ALPHA" bind:value={val.crs} /> <input type="text" maxlength="3" autocomplete="off" placeholder="CRS/3ALPHA" bind:value={val.crs} />
<br /> <br />
<input type="text" maxlength="7" autocomplete="off" placeholder="TIPLOC" bind:value={val.tiploc} /> <input type="text" maxlength="7" autocomplete="off" placeholder="TIPLOC" bind:value={val.tiploc} />
<br /> <br />
<input type="text" maxlength="10" autocomplete="off" placeholder="STANOX" bind:value={val.stanox} /> <input type="text" maxlength="10" autocomplete="off" placeholder="STANOX" bind:value={val.stanox} />
<br /> <br />
<input type="number" maxlength="6" min="0" autocomplete="off" placeholder="NLC" bind:value={val.nlc} /> <input type="number" maxlength="6" min="0" autocomplete="off" placeholder="NLC" bind:value={val.nlc} />
<br /> <br />
<input type="text" readonly autocomplete="off" placeholder="UIC" bind:value={val.uic} /> <input type="text" readonly autocomplete="off" placeholder="UIC" bind:value={val.uic} />
<br /> <br />
<button type="submit">Submit</button> <button type="submit">Submit</button>
<button type="reset" on:click={reset}>Reset</button> <button type="reset" on:click={reset}>Reset</button>
</form> </form>
</div> </div>
<Nav /> <Nav />
<style> <style>
p { p {
margin: 10px; margin: 10px;
} }
input { input {
font-family: urwgothic, sans-serif; font-family: urwgothic, sans-serif;
border-radius: 50px; border-radius: 50px;
border: none; border: none;
width: 60%; width: 60%;
max-width: 200px; max-width: 200px;
min-width: 130px; min-width: 130px;
height: 30px; height: 30px;
margin-bottom: 10px; margin-bottom: 10px;
text-transform: uppercase; text-transform: uppercase;
box-shadow: var(--box-shadow); box-shadow: var(--box-shadow);
} }
button { button {
border-radius: 50px; border-radius: 50px;
font-family: urwgothic, sans-serif; font-family: urwgothic, sans-serif;
background-color: var(--island-bg-color); background-color: var(--island-bg-color);
border: none; border: none;
color: white; color: white;
height: 30px; height: 30px;
width: 20%; width: 20%;
max-width: 100px; max-width: 100px;
min-width: 75px; min-width: 75px;
font-size: 18px; font-size: 18px;
box-shadow: var(--box-shadow); box-shadow: var(--box-shadow);
} }
.desc { .desc {
color: white; color: white;
} }
input { input {
text-align: center; text-align: center;
} }
</style> </style>

View File

@ -1,38 +1,38 @@
<script> <script>
import LogoutButton from "$lib/navigation/LogoutButton.svelte"; import LogoutButton from '$lib/navigation/LogoutButton.svelte';
import Header from "$lib/navigation/header.svelte"; import Header from '$lib/navigation/header.svelte';
import Loading from "$lib/navigation/loading.svelte"; import Loading from '$lib/navigation/loading.svelte';
import Nav from "$lib/navigation/nav.svelte"; import Nav from '$lib/navigation/nav.svelte';
import { getApiUrl } from "$lib/scripts/upstream"; import { getApiUrl } from '$lib/scripts/upstream';
import { uuid } from "$lib/stores/uuid.js"; import { uuid } from '$lib/stores/uuid.js';
import { onMount } from "svelte"; import { onMount } from 'svelte';
const title = "Your Data"; const title = 'Your Data';
let data = [ let data = [
{ {
domain: "User not Found", domain: 'User not Found',
atime: "User not Found", atime: 'User not Found'
},
];
let isLoading = false;
async function fetchData() {
if ($uuid != "null") {
const url = `${getApiUrl()}/api/v2/user/${$uuid}`;
const res = await fetch(url);
const json = await res.json();
if (json.length) {
data = json;
}
}
} }
];
onMount(async () => { let isLoading = false;
isLoading = true;
await fetchData(); async function fetchData() {
isLoading = false; if ($uuid != 'null') {
}); const url = `${getApiUrl()}/api/v2/user/${$uuid}`;
const res = await fetch(url);
const json = await res.json();
if (json.length) {
data = json;
}
}
}
onMount(async () => {
isLoading = true;
await fetchData();
isLoading = false;
});
</script> </script>
<Header {title} /> <Header {title} />
@ -43,26 +43,26 @@
<br /><br /> <br /><br />
{#if isLoading} {#if isLoading}
<Loading /> <Loading />
{:else if data[0].domain != "User not Found"} {:else if data[0].domain != 'User not Found'}
<p class="api_response">Registration Domain: {data[0]["domain"]}</p> <p class="api_response">Registration Domain: {data[0]['domain']}</p>
<p class="api_response">Access Time: {data[0]["atime"]}</p> <p class="api_response">Access Time: {data[0]['atime']}</p>
<LogoutButton /> <LogoutButton />
<p> <p>
Clicking the logout button will delete your data from your browser. You will then be able to make a new account, your old account will remain inactive and be deleted after Clicking the logout button will delete your data from your browser. You will then be able to make a new account, your old account will remain inactive and be deleted after 90
90 days. days.
</p> </p>
{:else} {:else}
<p class="api_response">You are not registered, we don't have any data stored.</p> <p class="api_response">You are not registered, we don't have any data stored.</p>
{/if} {/if}
<Nav /> <Nav />
<style> <style>
p { p {
margin: 10px; margin: 10px;
} }
.api_response { .api_response {
color: white; color: white;
} }
</style> </style>

View File

@ -1,17 +1,15 @@
<script> <script>
import Header from "$lib/navigation/header.svelte"; import Header from '$lib/navigation/header.svelte';
import Nav from "$lib/navigation/nav.svelte"; import Nav from '$lib/navigation/nav.svelte';
</script> </script>
<Header title={"Help"} /> <Header title={'Help'} />
<Nav /> <Nav />
<br /><br /> <br /><br />
<p> <p>
You can find extensive help and documentation at <a href="https://docs.owlboard.info">the documentation site</a>. If you need help you can use the <a href="https://www.facebook.com/owlboard.support">OwlBoard Support</a> page on Facebook.
</p>
<p>
You can also use the <a href="https://www.facebook.com/owlboard.support">OwlBoard Support</a> page on Facebook.
</p> </p>
<br /><br /> <br /><br />
<p>There, you can watch help videos, ask a question or suggest a feature.</p>
<p>Alternatively, you can report an issue on the <a href="/more/report">Report an Issue</a> page.</p> <p>Alternatively, you can report an issue on the <a href="/more/report">Report an Issue</a> page.</p>

View File

@ -1,61 +1,57 @@
<script> <script>
import Header from "$lib/navigation/header.svelte"; import Header from '$lib/navigation/header.svelte';
import Nav from "$lib/navigation/nav.svelte"; import Nav from '$lib/navigation/nav.svelte';
const title = "Privacy Policy"; const title = 'Privacy Policy';
</script> </script>
<Header {title} /> <Header {title} />
<div> <div>
<p> <p>
OwlBoard stores the minimum amount of data necessary to provide its functions for your use. No personal data is stored unless you report an issue. To review the specific OwlBoard stores the minimum amount of data necessary to provide its functions for your use. No personal data is stored unless you report an issue. To review the specific data
data that we store, please visit <a href="/more/data">My Data</a>. that we store, please visit <a href="/more/data">My Data</a>.
</p> </p>
<p>OwlBoard does not utilize any cookies. IP addresses and browser fingerprints are not logged.</p> <p>OwlBoard does not utilize any cookies. IP addresses and browser fingerprints are not logged.</p>
<h2>If You Do Not Sign Up</h2> <h2>If You Do Not Sign Up</h2>
<p> <p>
If you choose not to sign up, no personal data will be processed or stored unless you report an issue. Any personal settings are stored locally in your browser and do not If you choose not to sign up, no personal data will be processed or stored unless you report an issue. Any personal settings are stored locally in your browser and do not leave
leave your device. your device.
</p> </p>
<h2>If You Sign Up</h2> <h2>If You Sign Up</h2>
<p> <p>
If you sign up for the rail staff version of OwlBoard, we do require the storage of some data. However, none of this data can be used to personally identify you. Any If you sign up for the rail staff version of OwlBoard, we do require the storage of some data. However, none of this data can be used to personally identify you. Any personal
personal settings are stored locally in your browser and do not leave your device. settings are stored locally in your browser and do not leave your device.
</p> </p>
<p> <p>
During the sign-up process, you will be asked to provide a work email address, which will be checked to confirm its origin from a railway company. Once confirmed, an email During the sign-up process, you will be asked to provide a work email address, which will be checked to confirm its origin from a railway company. Once confirmed, an email
containing a registration link will be sent to you. At this point, the username portion of your email address is discarded. For example, if your email address is containing a registration link will be sent to you. At this point, the username portion of your email address is discarded. For example, if your email address is
'a-user@owlboard.info', only 'owlboard.info' will be stored. This host portion of your email address is stored to filter and display relevant results prominently. 'a-user@owlboard.info', only 'owlboard.info' will be stored. This host portion of your email address is stored to filter and display relevant results prominently.
</p> </p>
<p>The email server may store the address and message content as part of its regular operation, and your consent to this is implied when you sign up.</p> <p>The email server may store the address and message content as part of its regular operation, and your consent to this is implied when you sign up.</p>
<p>In addition to the host portion of your email address, a randomly generated UUID is stored for the purpose of authorizing access to the rail staff data.</p> <p>In addition to the host portion of your email address, a randomly generated UUID is stored for the purpose of authorizing access to the rail staff data.</p>
<p> <h2>Reporting an Issue</h2>
If you enable location data, your location will be sent to the server when you navigate to the homepage to determine your closest stations. This data is never stored on the <p>When you report an issue, certain data is collected, including your browser's User Agent string and the size of the window in which you are viewing the website.</p>
server after the nearest stations have been send to your device. <p>
</p> Any data submitted when reporting an issue will be publicly viewable alongside the <a href="https://git.fjla.uk/owlboard/backend/issues" target="_blank"
<h2>Reporting an Issue</h2> >OwlBoard/backend git repository</a
<p>When you report an issue, certain data is collected, including your browser's User Agent string and the size of the window in which you are viewing the website.</p> >.
<p> </p>
Any data submitted when reporting an issue will be publicly viewable alongside the <a href="https://git.fjla.uk/owlboard/backend/issues" target="_blank"
>OwlBoard/backend git repository</a
>.
</p>
</div> </div>
<Nav /> <Nav />
<style> <style>
div { div {
text-align: left; text-align: left;
} }
h2 { h2 {
color: var(--second-text-color); color: var(--second-text-color);
margin: 10px; margin: 10px;
padding-top: 20px; padding-top: 20px;
} }
p { p {
color: white; color: white;
margin: 10px; margin: 10px;
} }
</style> </style>

View File

@ -1,140 +1,121 @@
<script lang="ts"> <script>
import { onMount } from "svelte"; import { onMount } from 'svelte';
import Header from "$lib/navigation/header.svelte"; import Header from '$lib/navigation/header.svelte';
import Nav from "$lib/navigation/nav.svelte"; import Nav from '$lib/navigation/nav.svelte';
import Loading from "$lib/navigation/loading.svelte"; import Loading from '$lib/navigation/loading.svelte';
import Card from "$lib/cards/Card.svelte"; import ResultIsland from '$lib/islands/result-island.svelte';
import { CardConfig } from "$lib/cards/Card.types"; import { getApiUrl } from '$lib/scripts/upstream';
import { apiGet } from "$lib/scripts/apiFetch";
interface ApiResponse { const title = 'Reason Codes';
results: boolean; let isLoading = false;
title: string; let inputValue = '';
resultLines: string[]; let resultObject = {
} results: false,
const title = "Reason Codes"; title: '',
let isLoading = false; resultLines: []
let inputValue = ""; };
let resultObject: ApiResponse = {
results: false,
title: "",
resultLines: [],
};
let config: CardConfig = {
title: "",
showHelp: false,
showRefresh: false,
helpText: "",
onRefresh: () => {},
refreshing: false,
};
function load() { function load() {
isLoading = true; isLoading = true;
resultObject.results = false; resultObject.results = false;
getData().then((result) => { getData().then((result) => {
handleData(result); handleData(result);
isLoading = false; isLoading = false;
});
}
async function getData() {
if (inputValue) {
const apiPath = `/api/v2/ref/reasonCode/${inputValue}`;
const res = await apiGet(apiPath);
return res;
} else {
return [];
}
}
async function handleData(data) {
let resultLines = [];
if (data.length) {
resultObject.title = data[0]["code"];
resultLines = [data[0]["lateReason"], data[0]["cancReason"]];
} else {
resultObject = {
results: false,
title: "Not Found",
resultLines: [],
};
}
resultObject.resultLines = resultLines;
config.title = resultObject.title;
resultObject.results = true;
}
onMount(() => {
isLoading = false;
}); });
}
function handleInput(event) { async function getData() {
inputValue = event.target.value; if (inputValue) {
const url = `${getApiUrl()}/api/v2/ref/reasonCode/${inputValue}`;
const res = await fetch(url);
return await res.json();
} else {
return [];
} }
}
function handleSubmit(event) { async function handleData(data) {
event.preventDefault(); let resultLines = [];
load(); if (data.length) {
resultObject.title = data[0]['code'];
resultLines = [data[0]['lateReason'], data[0]['cancReason']];
} else {
resultObject = {
results: false,
title: 'Not Found',
resultLines: []
};
} }
resultObject.resultLines = resultLines;
resultObject.results = true;
}
onMount(() => {
isLoading = false;
});
function handleInput(event) {
inputValue = event.target.value;
}
function handleSubmit(event) {
event.preventDefault();
load();
}
</script> </script>
<Header {title} /> <Header {title} />
<p>A reason code is a three digit number that maps to a reason for a delay or cancellation</p> <p>A reason code is a three digit number that maps to a reason for a delay or cancellation</p>
<form on:submit={handleSubmit}> <form on:submit={handleSubmit}>
<input type="text" placeholder="Enter Code" autocomplete="off" bind:value={inputValue} on:input={handleInput} /> <input type="text" placeholder="Enter Code" autocomplete="off" bind:value={inputValue} on:input={handleInput} />
<br /> <br />
<button type="submit">Submit</button> <button type="submit">Submit</button>
</form> </form>
{#if isLoading} {#if isLoading}
<Loading /> <Loading />
{/if} {/if}
{#if resultObject.results} {#if resultObject.results}
<Card {config}> <ResultIsland {resultObject} />
{#each resultObject.resultLines as line}
<p>{line}</p>
{/each}
</Card>
{/if} {/if}
<Nav /> <Nav />
<style> <style>
p { p {
margin: 10px; margin: 10px;
margin-top: 20px; margin-top: 20px;
} }
input { input {
width: 25%; width: 25%;
min-width: 150px; min-width: 150px;
height: 32px; height: 32px;
margin-top: 10px; margin-top: 10px;
margin-bottom: 5px; margin-bottom: 5px;
border-radius: 50px; border-radius: 50px;
border: none; border: none;
text-align: center; text-align: center;
font-family: urwgothic, "Lucida Sans", "Lucida Sans Regular", "Lucida Grande", "Lucida Sans Unicode", Geneva, Verdana, sans-serif; font-family: urwgothic, 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
text-transform: uppercase; text-transform: uppercase;
font-size: 15px; font-size: 15px;
box-shadow: var(--box-shadow); box-shadow: var(--box-shadow);
} }
button { button {
width: 15%; width: 15%;
min-width: 100px; min-width: 100px;
margin-bottom: 5px; margin-bottom: 5px;
margin-top: 5px; margin-top: 5px;
border: none; border: none;
border-radius: 20px; border-radius: 20px;
padding: 5px; padding: 5px;
font-family: urwgothic, "Lucida Sans", "Lucida Sans Regular", "Lucida Grande", "Lucida Sans Unicode", Geneva, Verdana, sans-serif; font-family: urwgothic, 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
font-size: 16px; font-size: 16px;
font-weight: 400; font-weight: 400;
background-color: var(--island-bg-color); background-color: var(--island-bg-color);
color: var(--main-text-color); color: var(--main-text-color);
box-shadow: var(--box-shadow); box-shadow: var(--box-shadow);
} }
</style> </style>

View File

@ -1,153 +1,136 @@
<script lang="ts"> <script>
import Header from "$lib/navigation/header.svelte"; import Header from '$lib/navigation/header.svelte';
import Nav from "$lib/navigation/nav.svelte"; import Nav from '$lib/navigation/nav.svelte';
import Loading from "$lib/navigation/loading.svelte"; import Loading from '$lib/navigation/loading.svelte';
import { onMount } from "svelte"; import { onMount } from 'svelte';
import { checkAuth } from "$lib/libauth"; import { checkAuth, logout } from '$lib/libauth';
import LogoutButton from "$lib/navigation/LogoutButton.svelte"; import LogoutButton from '$lib/navigation/LogoutButton.svelte';
import { getApiUrl } from "$lib/scripts/upstream"; import { getApiUrl } from '$lib/scripts/upstream';
import toast from "svelte-french-toast";
const title = "Register"; const title = 'Register';
let state = "unreg"; let state = 'unreg';
let isLoading = true; let isLoading = true;
let inputValue = ""; let inputValue = '';
function handleInput(event: KeyboardEvent) { function handleInput(event) {
inputValue = event?.target?.value; inputValue = event.target.value;
}
async function request() {
isLoading = true;
const url = `${getApiUrl()}/api/v2/user/request`;
const request = {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
email: inputValue
})
};
const res = await fetch(url, request);
if (res.status == 400 || res.status == 403) {
state = 'unauth';
} else if (res.status == 201) {
state = 'sent';
} else {
state = 'error';
} }
isLoading = false;
}
async function request() { onMount(async () => {
isLoading = true; const auth = await checkAuth();
const url = `${getApiUrl()}/api/v2/user/request`; if (auth.uuidPresent === false) {
const request = { state = 'unreg';
method: "POST", } else if (auth.uuidPresent === true) {
headers: { state = 'reg';
"Content-Type": "application/json",
},
body: JSON.stringify({
email: inputValue,
}),
};
const res = await fetch(url, request);
if (res.status == 400 || res.status == 403) {
state = "unauth";
} else if (res.status == 201) {
state = "sent";
} else {
state = "error";
}
isLoading = false;
} }
isLoading = false;
function send() { });
toast.promise(request(), {
loading: "Contacting Server...",
success: "Request Answered.",
error: "Unable to contact server.",
});
}
onMount(async () => {
const auth = await checkAuth();
if (auth.uuidPresent === false) {
state = "unreg";
} else if (auth.uuidPresent === true) {
state = "reg";
}
isLoading = false;
});
</script> </script>
<Header {title} /> <Header {title} />
<section class="content"> <section class="content">
{#if isLoading} {#if isLoading}
<Loading /> <Loading />
{:else if state == "unreg"} {:else if state == 'unreg'}
<p>To register, you will need to enter a work email address to receive a confirmation email</p> <p>The staff version of OwlBoard offers several extra features:</p>
<p class="bold">Already have a registration code? <a href="/more/reg/submit">enter it here</a></p> <ul>
<form on:submit={send}> <li>Access the Train Finder</li>
<input type="text" autocomplete="email" placeholder="Enter work email" bind:value={inputValue} on:input={handleInput} /><br /> <li>Access the PIS Finder</li>
<label for="checkbox"> <li>More detailed departure boards:</li>
I have read and accept the terms of the <a href="/more/privacy">Privacy Policy</a><br /> <ul>
<input id="checkbox" type="checkbox" required /> <li>Non-Passenger movements</li>
</label><br /> <li>Hidden platform numbers</li>
<button type="submit">Submit</button> <li>Display up to 25 services</li>
</form> </ul>
<br /> </ul>
<p class="bold">What do you get?</p> <p>To register, you will need to enter a work email address to receive a confirmation email</p>
<li>Access to Train details</li> <form on:submit={request}>
<li>Access to PIS Codes</li> <input type="text" autocomplete="email" placeholder="Enter work email" bind:value={inputValue} on:input={handleInput} /><br />
<li>ECS Movements on departure boards</li> <label for="checkbox">
<li>Non-Public trains on departure boards</li> I have read and accept the terms of the <a href="/more/privacy">Privacy Policy</a><br />
<li>Hidden platform numbers on departure boards</li> <input id="checkbox" type="checkbox" required />
<li>See up to the next 40 trains departing a station over the next two hours</li> </label><br />
{:else if state == "sent"} <button type="submit">Submit</button>
<p>An email has been sent, enter the code in the email to activate your profile.</p> </form>
<p class="bold"><a href="/more/reg/submit">Ready to enter your code?</a></p> {:else if state == 'sent'}
<p>If you use multiple browsers, you will only be logged in using the browser you open the link with.</p> <p>An email has been sent, click the link in the email to activate your profile.</p>
<p>You will be able to register again using the same email address</p> <p>When you click the link, your authorisation key will be automatically be stored in your browser.</p>
{:else if state == "unauth"} <p>If you use multiple browsers, you will only be logged in using the browser you open the link with.</p>
<p>The email address you entered does not belong to an authorised business.</p> <p>You will be able to register again using the same email address</p>
<p>If you think this is an error, you can get help on <a href="/more/help">the help page</a>.</p> {:else if state == 'unauth'}
{:else if state == "error"} <p>The email address you entered does not belong to an authorised business.</p>
<p>There was an error processing your request.</p> <p>If you think this is an error, you can get help on <a href="/more/help">the help page</a>.</p>
<p>Check that the email you entered was correct or try again later.</p> {:else if state == 'error'}
{:else if state == "reg"} <p>There was an error processing your request.</p>
<p> <p>Check that the email you entered was correct or try again later.</p>
You are already registered for OwlBoard. If you've recently logged out or updated, you may need to refresh this page to register as old data could still be stored in {:else if state == 'reg'}
your browser. <p>
</p> You are already registered for OwlBoard. If you've recently logged out or updated, you may need to refresh this page to register as old data could still be stored in your
<LogoutButton /> browser.
{/if} </p>
<LogoutButton />
{/if}
</section> </section>
<Nav /> <Nav />
<style> <style>
.bold { .content {
font-weight: 800; margin-top: 30px;
} }
.content { p {
margin-top: 30px; margin: 10px;
} }
p { ul {
margin: 10px; text-align: left;
margin-left: 20px; color: white;
margin-right: 20px; }
} input {
li { height: 40px;
text-align: center; width: 80%;
font-size: 14px; max-width: 375px;
color: white; font-family: urwgothic, 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
margin-top: 5px; text-align: center;
margin-left: 15px; font-size: 20px;
margin-right: 15px; border-radius: 50px;
list-style-type: none; border: none;
} margin-bottom: 20px;
input { }
height: 40px; #checkbox {
width: 80%; height: 30px;
max-width: 375px; width: 30px;
font-family: urwgothic, "Franklin Gothic Medium", "Arial Narrow", Arial, sans-serif; }
text-align: center; button {
font-size: 20px; border: none;
border-radius: 50px; background-color: var(--island-bg-color);
border: none; color: var(--main-text-color);
margin-bottom: 20px; width: 35%;
} height: 30px;
#checkbox { border-radius: 50px;
height: 30px; font-size: 18px;
width: 30px; }
}
button {
border: none;
background-color: var(--island-bg-color);
color: var(--main-text-color);
width: 35%;
height: 30px;
border-radius: 50px;
font-size: 18px;
}
</style> </style>

View File

@ -1,128 +1,80 @@
<script lang="ts"> <script>
import Header from "$lib/navigation/header.svelte"; import Header from '$lib/navigation/header.svelte';
import Nav from "$lib/navigation/nav.svelte"; import Loading from '$lib/navigation/loading.svelte';
import { getApiUrl } from "$lib/scripts/upstream"; import Nav from '$lib/navigation/nav.svelte';
import { uuid } from "$lib/stores/uuid"; import { getApiUrl } from '$lib/scripts/upstream';
import { uuid } from '$lib/stores/uuid.js';
import { onMount } from 'svelte';
const title = "Submit Registration"; const title = 'Registration';
let state = false; let state = '';
let status: string; let isLoading = true;
let inputs: { id: string; value: string }[] = [ async function getUUID() {
{ id: "1", value: "" }, return new URLSearchParams(window.location.search).get('key');
{ id: "2", value: "" }, }
{ id: "3", value: "" },
{ id: "4", value: "" },
{ id: "5", value: "" },
{ id: "6", value: "" },
];
function handleInput(index: number, event: KeyboardEvent): void { async function submit(id) {
if (event.key === "Backspace" && index > 0 && inputs[index].value === "") { const url = `${getApiUrl()}/api/v2/user/register`;
const prevInput = document.getElementById(`input-${index}`); const request = {
if (prevInput) { method: 'POST',
prevInput.focus(); headers: {
} 'Content-Type': 'application/json'
} else if (inputs[index].value.length === 1) { },
const nextInput = document.getElementById(`input-${index + 2}`); body: JSON.stringify({
if (nextInput) { uuid: id
nextInput.focus(); })
} };
} const res = await fetch(url, request);
const body = await res.json();
if (body.api_key) {
uuid.set(body.api_key);
return 201;
} }
return res.status;
}
async function handleSubmit() { onMount(async () => {
let submitString: string = ""; const id = (await getUUID()) || '';
for (const input of inputs) { if (id == '' || !id) {
submitString += input.value.toUpperCase(); state = 'none';
} isLoading = false;
console.log(`Code: ${submitString}`); return;
const res = await submit(submitString);
console.log(`Registration Status: ${res}`);
if (res == 201) {
status = "okay";
} else if (res == 401) {
status = "fail";
} else {
console.error("Unable to register: ", status);
}
state = true;
} }
const status = await submit(id);
async function submit(id: string): Promise<number> { if (status == 201) {
const url = `${getApiUrl()}/api/v2/user/register`; console.log('Registered Successfully');
const request = { state = 'done';
method: "POST", } else if (status == 401) {
headers: { console.log('Invalid Key');
"Content-Type": "application/json", state = 'unauth';
}, } else {
body: JSON.stringify({ console.log('Error');
uuid: id, state = 'error';
}),
};
const res = await fetch(url, request);
const body = await res.json();
if (body.api_key) {
uuid.set(body.api_key);
return 201;
} else {
return res.status;
}
} }
isLoading = false;
});
</script> </script>
<Header {title} /> <Header {title} />
{#if isLoading}
{#if state} <Loading />
{#if status == "okay"} {/if}
<p class="title-ish">You are now registered</p> {#if state == 'none'}
<p>Your secret key will be stored in your browser.</p> <p>Unable to read your access key.</p>
<p>If you change browsers, change device or clear your browsing data, you may have to register again.</p> <p>Please click the link in your email again.</p>
{:else if status == "fail"} {:else if state == 'unauth'}
<p class="title-ish">Your code was not accepted</p> <p>Your link is not valid, links expire after 30 minutes.</p>
<p>The code expires after 1 hour, you can check the code and enter it again or request a <a href="/more/reg">new code</a>.</p> <p>You can try to register again.</p>
{/if} {:else if state == 'error'}
{:else} <p>There was an error on our end, please try again later</p>
<p class="title-ish">Enter your registration code below</p> {:else if state == 'done'}
<form on:submit={handleSubmit} id="codeInputForm"> <p>You are now logged in</p>
{#each inputs as input, index}
<input class="code-in" bind:value={input.value} id={`input-${input.id}`} maxlength="1" autocomplete="off" on:keydown={(event) => handleInput(index, event)} />
{/each}
<br />
<button type="submit">Submit</button>
</form>
{/if} {/if}
<Nav /> <Nav />
<style> <style>
.title-ish { p {
font-size: 20px; margin: 14px;
} }
.code-in {
margin: 3px;
margin-bottom: 20px;
width: 29px;
height: 39px;
font-size: 30px;
text-align: center;
text-transform: uppercase;
border-radius: 10px;
border: none;
}
button {
border: none;
background-color: var(--island-bg-color);
color: var(--main-text-color);
width: 35%;
min-width: 95px;
max-width: 231px;
height: 30px;
border-radius: 50px;
font-size: 18px;
}
p {
margin-left: 40px;
margin-right: 40px;
}
</style> </style>

View File

@ -1,188 +1,188 @@
<script> <script>
import Header from "$lib/navigation/header.svelte"; import Header from '$lib/navigation/header.svelte';
import Island from "$lib/islands/island.svelte"; import Island from '$lib/islands/island.svelte';
import Nav from "$lib/navigation/nav.svelte"; import Nav from '$lib/navigation/nav.svelte';
import { onMount } from "svelte"; import { onMount } from 'svelte';
import Loading from "$lib/navigation/loading.svelte"; import Loading from '$lib/navigation/loading.svelte';
import Done from "$lib/navigation/done.svelte"; import Done from '$lib/navigation/done.svelte';
import { getApiUrl } from "$lib/scripts/upstream"; import { getApiUrl } from '$lib/scripts/upstream';
const title = "Report Issue"; const title = 'Report Issue';
let isLoading = false; let isLoading = false;
let isDone = false; let isDone = false;
let isError = false; let isError = false;
let reportType = "", let reportType = '',
reportSubject = "", reportSubject = '',
reportMsg = "", reportMsg = '',
reportCollected; reportCollected;
onMount(async () => { onMount(async () => {
reportCollected = { reportCollected = {
userAgent: navigator.userAgent, userAgent: navigator.userAgent,
browser: navigator.appName, browser: navigator.appName,
version: navigator.appVersion, version: navigator.appVersion,
platform: navigator.platform, platform: navigator.platform,
viewport: `${window.innerWidth} x ${window.innerHeight}`, viewport: `${window.innerWidth} x ${window.innerHeight}`
}; };
});
let preFlight = false;
async function submit() {
console.log(reportType, reportSubject, reportMsg);
preFlight = true;
}
async function send() {
console.log('SEND DATA REQUESTED');
isLoading = true;
const formData = JSON.stringify({
label: reportType,
subject: reportSubject,
msg:
`User Agent: ${reportCollected.userAgent}\n` +
`Browser: ${reportCollected.browser}\n` +
`BrowserVersion: ${reportCollected.version}\n` +
`Platform: ${reportCollected.platform}\n` +
`Viewport: ${reportCollected.viewport}\n\n\n` +
`User Message:\n` +
`${reportMsg}`
}); });
const url = `${getApiUrl()}/misc/issue`;
let preFlight = false; const options = {
method: 'POST',
async function submit() { headers: {
console.log(reportType, reportSubject, reportMsg); 'Content-Type': 'application/json'
preFlight = true; },
body: formData
};
const res = await fetch(url, options);
if (res.status == 200) {
isLoading = false;
isDone = true;
await new Promise((r) => setTimeout(r, 2000));
window.location.href = '/';
} else {
isLoading = false;
isError = true;
} }
}
async function send() { async function cancel() {
console.log("SEND DATA REQUESTED"); preFlight = false;
isLoading = true; isLoading = false;
const formData = JSON.stringify({ isDone = false;
label: reportType, isError = false;
subject: reportSubject, }
msg:
`User Agent: ${reportCollected.userAgent}\n` +
`Browser: ${reportCollected.browser}\n` +
`BrowserVersion: ${reportCollected.version}\n` +
`Platform: ${reportCollected.platform}\n` +
`Viewport: ${reportCollected.viewport}\n\n\n` +
`User Message:\n` +
`${reportMsg}`,
});
const url = `${getApiUrl()}/misc/issue`;
const options = {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: formData,
};
const res = await fetch(url, options);
if (res.status == 200) {
isLoading = false;
isDone = true;
await new Promise((r) => setTimeout(r, 2000));
window.location.href = "/";
} else {
isLoading = false;
isError = true;
}
}
async function cancel() {
preFlight = false;
isLoading = false;
isDone = false;
isError = false;
}
</script> </script>
<Header {title} /> <Header {title} />
{#if isLoading} {#if isLoading}
<Loading /> <Loading />
{/if} {/if}
{#if isDone} {#if isDone}
<Done /> <Done />
{/if} {/if}
{#if !preFlight && !isDone} {#if !preFlight && !isDone}
<p>Get help on the <a href="https://www.facebook.com/owlboard.support">OwlBoard Support Facebook Page</a></p> <p>Get help on the <a href="https://www.facebook.com/owlboard.support">OwlBoard Support Facebook Page</a></p>
<p> <p>
Or submit an issue, you can check for existing reports Or submit an issue, you can check for existing reports
<a href="https://git.fjla.uk/OwlBoard/backend/issues" target="_blank">here</a> <a href="https://git.fjla.uk/OwlBoard/backend/issues" target="_blank">here</a>
before submitting a new issue. before submitting a new issue.
</p> </p>
<p>You will be shown all of the collected data before the form is submitted.</p> <p>You will be shown all of the collected data before the form is submitted.</p>
<form on:submit={submit}> <form on:submit={submit}>
<select class="formInputs" name="type" bind:value={reportType} placeholder="Choose Category"> <select class="formInputs" name="type" bind:value={reportType} placeholder="Choose Category">
<option value="" disabled selected>Choose an Issue Type</option> <option value="" disabled selected>Choose an Issue Type</option>
<option value="bug">Problem</option> <option value="bug">Problem</option>
<option value="enhancement">Feature Request</option> <option value="enhancement">Feature Request</option>
<option value="question">Question</option> <option value="question">Question</option>
<option value="user-support">Unable to sign up</option> <option value="user-support">Unable to sign up</option>
</select> </select>
<br /> <br />
<input class="formInputs" type="text" bind:value={reportSubject} placeholder="Subject" /> <input class="formInputs" type="text" bind:value={reportSubject} placeholder="Subject" />
<br /> <br />
<textarea class="formInputs" bind:value={reportMsg} placeholder="Enter your message..." /> <textarea class="formInputs" bind:value={reportMsg} placeholder="Enter your message..." />
<br /> <br />
<button type="submit">Submit</button> <button type="submit">Submit</button>
<button type="reset">Reset</button> <button type="reset">Reset</button>
</form> </form>
{:else} {:else}
<Island> <Island>
<h2>Device Data:</h2> <h2>Device Data:</h2>
<p><span class="dataType">User Agent: </span>{reportCollected.userAgent}</p> <p><span class="dataType">User Agent: </span>{reportCollected.userAgent}</p>
<p> <p>
<span class="dataType">Browser: </span>{reportCollected.browser} - {reportCollected.version} <span class="dataType">Browser: </span>{reportCollected.browser} - {reportCollected.version}
</p> </p>
<p><span class="dataType">Platform: </span>{reportCollected.platform}</p> <p><span class="dataType">Platform: </span>{reportCollected.platform}</p>
<p><span class="dataType">Viewport: </span> {reportCollected.viewport}</p> <p><span class="dataType">Viewport: </span> {reportCollected.viewport}</p>
<h2>Reported Data:</h2> <h2>Reported Data:</h2>
<p><span class="dataType">Report Type: </span>{reportType}</p> <p><span class="dataType">Report Type: </span>{reportType}</p>
<p>{reportSubject}</p> <p>{reportSubject}</p>
<p>{reportMsg}</p> <p>{reportMsg}</p>
<button class="overlayButtons" on:click={send}>Send</button> <button class="overlayButtons" on:click={send}>Send</button>
<button class="overlayButtons" on:click={cancel}>Cancel</button> <button class="overlayButtons" on:click={cancel}>Cancel</button>
</Island> </Island>
{/if} {/if}
<Nav /> <Nav />
<style> <style>
p { p {
margin-left: 10px; margin-left: 10px;
margin-right: 10px; margin-right: 10px;
} }
select { select {
text-align: center; text-align: center;
border: none; border: none;
border-radius: 50px; border-radius: 50px;
height: 30px; height: 30px;
background-color: white; background-color: white;
} }
.formInputs { .formInputs {
margin: 10px; margin: 10px;
font-family: urwgothic, sans-serif; font-family: urwgothic, sans-serif;
font-size: 16px; font-size: 16px;
border: none; border: none;
width: 50%; width: 50%;
max-width: 450px; max-width: 450px;
min-width: 250px; min-width: 250px;
} }
input { input {
text-align: center; text-align: center;
border-radius: 50px; border-radius: 50px;
height: 30px; height: 30px;
} }
textarea { textarea {
text-align: left; text-align: left;
border-radius: 10px; border-radius: 10px;
padding-left: 5px; padding-left: 5px;
padding-right: 5px; padding-right: 5px;
height: 30vh; height: 30vh;
min-height: 150px; min-height: 150px;
max-height: 400px; max-height: 400px;
} }
button { button {
background-color: var(--island-bg-color); background-color: var(--island-bg-color);
color: var(--main-text-color); color: var(--main-text-color);
font-family: urwgothic, sans-serif; font-family: urwgothic, sans-serif;
font-size: 16px; font-size: 16px;
border: none; border: none;
border-radius: 50px; border-radius: 50px;
width: 25%; width: 25%;
height: 30px; height: 30px;
max-width: 100px; max-width: 100px;
box-shadow: var(--box-shadow); box-shadow: var(--box-shadow);
} }
h2 { h2 {
color: white; color: white;
} }
.dataType { .dataType {
color: white; color: white;
} }
.overlayButtons { .overlayButtons {
background-color: var(--main-bg-color); background-color: var(--main-bg-color);
} }
</style> </style>

View File

@ -1,50 +1,12 @@
<script> <script>
import Header from "$lib/navigation/header.svelte"; import Header from '$lib/navigation/header.svelte';
import Nav from "$lib/navigation/nav.svelte"; import Nav from '$lib/navigation/nav.svelte';
import QlSet from "$lib/islands/quick-link-set-island.svelte"; import QlSet from '$lib/islands/quick-link-set-island.svelte';
import Island from "$lib/islands/island.svelte"; const title = 'Settings';
import { location } from "$lib/stores/location";
import { getCurrentLocation } from "$lib/scripts/getLocation";
import toast from "svelte-french-toast";
const title = "Settings";
$: if ($location) {
getCurrentLocation();
}
function locationToast() {
toast("Settings updated");
}
</script> </script>
<Header {title} /> <Header {title} />
<QlSet /> <QlSet />
<Island variables={{ title: "Location" }}>
<p>Use your location to quickly check departure boards near you</p>
<div class="checkbox-container">
<label for="location_enable">Enabled</label>
<input id="location_enable" type="checkbox" bind:checked={$location} on:click={locationToast} />
</div>
</Island>
<Nav /> <Nav />
<style>
.checkbox-container {
display: inline-flex;
align-items: center;
margin: auto;
}
.checkbox-container input[type="checkbox"] {
margin: 0;
height: 25px;
width: 25px;
}
.checkbox-container label {
margin-left: 0;
margin-right: 25px;
font-weight: 800;
}
</style>

View File

@ -1,197 +1,79 @@
<script lang="ts"> <script>
import Island from "$lib/islands/island.svelte"; import Island from '$lib/islands/island.svelte';
import Header from "$lib/navigation/header.svelte"; import Header from '$lib/navigation/header.svelte';
import Loading from "$lib/navigation/loading.svelte"; import Loading from '$lib/navigation/loading.svelte';
import Nav from "$lib/navigation/nav.svelte"; import Nav from '$lib/navigation/nav.svelte';
import { getApiUrl } from "$lib/scripts/upstream"; import { getApiUrl } from '$lib/scripts/upstream';
import { featureDetect, type FeatureDetectionResult } from "$lib/scripts/featureDetect"; const title = 'Statistics';
import { getCurrentLocation } from "$lib/scripts/getLocation";
import { onMount } from "svelte";
const title = "Statistics";
let features: FeatureDetectionResult | null = null;
let error: Error | null = null;
async function getData() { async function getData() {
const url = `${getApiUrl()}/misc/server/stats`; const url = `${getApiUrl()}/misc/server/stats`;
const res = await fetch(url); const res = await fetch(url);
return await res.json(); return await res.json();
} }
async function loadFeatures() { function U2L(input) {
try { try {
features = await featureDetect(); const datetime = new Date(input * 1000);
} catch (e) { return datetime.toLocaleString();
error = e; } catch (err) {
} console.log(err);
} return false;
onMount(() => {
loadFeatures();
});
function U2L(input: Date | number): string {
if (input instanceof Date) {
return input.toLocaleString();
}
try {
const datetime = new Date(input * 1000);
return datetime.toLocaleString();
} catch (err) {
console.log(err);
return "Unknown";
}
} }
}
</script> </script>
<Header {title} /> <Header {title} />
{#await getData()} {#await getData()}
<Loading /> <Loading />
{:then data} {:then data}
<br /> <br />
<p>API Server:<br /><span>{data?.hostname}</span></p> <p>API Server:<br /><span>{data?.hostname}</span></p>
<p>Runtime Mode: <span>{data?.runtimeMode}</span></p> <p>Runtime Mode: <span>{data?.runtimeMode}</span></p>
<p>Stats Reset: <span>{U2L(data?.reset) || "Unknown"}</span></p> <p>Stats Reset: <span>{U2L(data?.reset) || 'Unknown'}</span></p>
<h2>Last Update</h2> <h2>Last Update</h2>
<p>Timetable: <span>{U2L(data?.updateTimes?.timetable)}</span></p> <p>Timetable: <span>{U2L(data?.updateTimes?.timetable)}</span></p>
<p>Location Ref: <span>{U2L(data?.updateTimes?.corpus)}</span></p> <p>Location Ref: <span>{U2L(data?.updateTimes?.corpus)}</span></p>
<p>PIS Codes: <span>{U2L(data?.updateTimes?.pis)}</span></p> <p>PIS Codes: <span>{U2L(data?.updateTimes?.pis)}</span></p>
<p>Reason Codes: <span>{U2L(data?.updateTimes?.reasonCodes)}</span></p> <p>Reason Codes: <span>{U2L(data?.updateTimes?.reasonCodes)}</span></p>
<h2>Request Counts</h2> <h2>Request Counts</h2>
<p>LDBWS API: <span>{data?.requestCounts?.ldbws_api}</span></p> <p>LDBWS API: <span>{data?.requestCounts?.ldbws_api}</span></p>
<p>LDBSVWS API: <span>{data?.requestCounts?.lsbsvws_api}</span></p> <p>LDBSVWS API: <span>{data?.requestCounts?.lsbsvws_api}</span></p>
<p>Location Reference API: <span>{data?.requestCounts?.corpus_api}</span></p> <p>Location Reference API: <span>{data?.requestCounts?.corpus_api}</span></p>
<p>Timetable: <span>{data?.requestCounts?.timetable_db}</span></p> <p>Timetable: <span>{data?.requestCounts?.timetable_db}</span></p>
<p>PIS: <span>{data?.requestCounts?.pis_db}</span></p> <p>PIS: <span>{data?.requestCounts?.pis_db}</span></p>
<p>Location Reference: <span>{data?.requestCounts?.corpus_db}</span></p> <p>Location Reference: <span>{data?.requestCounts?.corpus_db}</span></p>
<p>Stations: <span>{data?.requestCounts?.stations_db}</span></p> <p>Stations: <span>{data?.requestCounts?.stations_db}</span></p>
<h2>Database Lengths</h2> <h2>Database Lengths</h2>
<p>Users: <span>{data?.dbLengths?.users}</span></p> <p>Users: <span>{data?.dbLengths?.users}</span></p>
<p>Pending Registrations: <span>{data?.dbLengths?.registrations}</span></p> <p>Pending Registrations: <span>{data?.dbLengths?.registrations}</span></p>
<p>CORPUS: <span>{data?.dbLengths?.corpus}</span></p> <p>CORPUS: <span>{data?.dbLengths?.corpus}</span></p>
<p>Stations: <span>{data?.dbLengths?.stations}</span></p> <p>Stations: <span>{data?.dbLengths?.stations}</span></p>
<p>PIS: <span>{data?.dbLengths?.pis}</span></p> <p>PIS: <span>{data?.dbLengths?.pis}</span></p>
<p>Timetable: <span>{data?.dbLengths?.timetable}</span></p> <p>Timetable: <span>{data?.dbLengths?.timetable}</span></p>
<p>Reason Codes: <span>{data?.dbLengths?.reasonCodes}</span></p> <p>Reason Codes: <span>{data?.dbLengths?.reasonCodes}</span></p>
{:catch} {:catch}
<Island> <Island>
<p style="font-weight:600">Unable to connect to server</p> <p style="font-weight:600">Unable to connect to server</p>
</Island> </Island>
{/await} {/await}
<h2>Browser Features</h2>
{#if features === null && error === null}
Checking browser features...
{:else if features !== null}
<h3>Critical Features</h3>
{#if !features.critical}
<p>
OwlBoard will not function properly without these browser features. If you see any crosses here you may need to update your browser or choose another browser. Chrome,
Edge, Firefox, Brave & Samsung Browser have been tested.
</p>
{/if}
<ul class="feature-list">
<li>
Fetch <span class="feature-status {features.missing.includes('fetch') ? 'cross' : 'tick'}">
{features.missing.includes("fetch") ? "✗" : "✓"}
</span>
</li>
<li>
Local Storage <span class="feature-status {features.missing.includes('localStorage') ? 'cross' : 'tick'}">
{features.missing.includes("localStorage") ? "✗" : "✓"}
</span>
</li>
<li>
Session Storage <span class="feature-status {features.missing.includes('sessionStorage') ? 'cross' : 'tick'}">
{features.missing.includes("sessionStorage") ? "✗" : "✓"}
</span>
</li>
<li>
Promises <span class="feature-status {features.missing.includes('promise') ? 'cross' : 'tick'}">
{features.missing.includes("promise") ? "✗" : "✓"}
</span>
</li>
</ul>
<h3>Nice-to-have Features</h3>
{#if !features.nice}
<p>
OwlBoard may run slowly or be missing some functions without these browser features. If you see any crosses here you may want to update your browser or choose another
browser for improved performance. Chrome, Edge, Firefox, Brave & Samsung Browser have been tested.
</p>
{/if}
<ul class="feature-list">
<li>
Geolocation <span class="feature-status {features.missing.includes('geolocation') ? 'cross' : 'tick'}">
{features.missing.includes("geolocation") ? "✗" : "✓"}
</span>
</li>
<li>
Service Worker <span class="feature-status {features.missing.includes('serviceWorker') ? 'cross' : 'tick'}">
{features.missing.includes("serviceWorker") ? "✗" : "✓"}
</span>
</li>
<li>
Dialog <span class="feature-status {features.missing.includes('dialog') ? 'cross' : 'tick'}">
{features.missing.includes("dialog") ? "✗" : "✓"}
</span>
</li>
<li>
Popover API <span class="feature-status {features.missing.includes('popover') ? 'cross' : 'tick'}">
{features.missing.includes("popover") ? "✗" : "✓"}
</span>
</li>
</ul>
{:else if error !== null}
Failed to detect browser features: {error.message}
{/if}
<Nav /> <Nav />
<style> <style>
span { span {
color: white; color: white;
} }
p { p {
margin: 0; margin: 0;
color: lightgray; color: lightgray;
} }
h2 { h2 {
font-family: urwgothic, sans-serif; font-family: urwgothic, sans-serif;
margin-bottom: 2px; margin-bottom: 2px;
margin-top: 8px; margin-top: 8px;
} }
.feature-list {
list-style-type: none; /* Remove bullet points */
padding: 0;
text-align: center; /* Center the list */
}
.feature-list li {
display: flex;
justify-content: center;
align-items: center;
margin: 8px 0;
}
.feature-status {
display: inline-block;
width: 20px;
height: 20px;
line-height: 20px;
text-align: center;
border-radius: 50%;
color: white;
margin-left: 8px;
}
.tick {
background-color: green;
}
.cross {
background-color: red;
}
</style> </style>

View File

@ -1,20 +1,18 @@
<script> <script>
import Header from "$lib/navigation/header.svelte"; import Header from '$lib/navigation/header.svelte';
import Island from "$lib/islands/island.svelte"; import Island from '$lib/islands/island.svelte';
import Loading from "$lib/navigation/loading.svelte"; import Loading from '$lib/navigation/loading.svelte';
import Nav from "$lib/navigation/nav.svelte"; import Nav from '$lib/navigation/nav.svelte';
import LargeLogo from "$lib/images/large-logo.svelte"; import LargeLogo from '$lib/images/large-logo.svelte';
import { version, versionTag } from "$lib/stores/version"; import { version, versionTag } from '$lib/stores/version';
import { getApiUrl } from "$lib/scripts/upstream"; import { getApiUrl } from '$lib/scripts/upstream';
import { IconBrandGolang, IconBrandJavascript, IconBrandNodejs, IconBrandPython, IconBrandSvelte, IconBrandTypescript } from "@tabler/icons-svelte"; const title = 'Versions';
import Tooltip from "$lib/Tooltip.svelte";
const title = "Versions";
async function getData() { async function getData() {
const url = `${getApiUrl()}/misc/server/versions`; const url = `${getApiUrl()}/misc/server/versions`;
const res = await fetch(url); const res = await fetch(url);
return await res.json(); return await res.json();
} }
</script> </script>
<Header {title} /> <Header {title} />
@ -22,58 +20,42 @@
<LargeLogo /> <LargeLogo />
{#await getData()} {#await getData()}
<Loading /> <Loading />
{:then data} {:then data}
<Island> <Island>
<p> <p>
<Tooltip text="Svelte"><IconBrandSvelte /></Tooltip> <a class="data" href="https://git.fjla.uk/owlboard/owlboard-svelte" target="_blank"
<Tooltip text="Javascript"><IconBrandJavascript /></Tooltip> >Web-app version<br /><span class="data"
<Tooltip text="Typescript"><IconBrandTypescript /></Tooltip> >{version}{#if versionTag}-{versionTag}{/if}</span
<br /> ></a
<a class="data" href="https://git.fjla.uk/owlboard/owlboard-svelte" target="_blank" >
>Web-app version<br /><span class="data" </p>
>{version}{#if versionTag}-{versionTag}{/if}</span <p>
></a <a class="data" href="https://git.fjla.uk/owlboard/backend" target="_blank">API Server version<br /><span class="data">{data?.backend || 'Unknown'}</span></a>
> </p>
</p> <p>
<p> <a class="data" href="https://git.fjla.uk/owlboard/db-manager" target="_blank">DB Manager version<br /><span class="data">{data?.['db-manager'] || 'Unknown'}</span></a>
<Tooltip text="NodeJS"><IconBrandNodejs /></Tooltip> </p>
<Tooltip text="Javascript"><IconBrandJavascript /></Tooltip> <p>
<Tooltip text="Typescript"><IconBrandTypescript /></Tooltip> <a class="data" href="https://git.fjla.uk/owlboard/mq-client" target="_blank">MQ Client version<br /><span class="data">{data?.['mq-client'] || 'Not installed'}</span></a>
<br /> </p>
<a class="data" href="https://git.fjla.uk/owlboard/backend" target="_blank">API Server version<br /><span class="data">{data?.backend || "Unknown"}</span></a> </Island>
</p>
<p>
<Tooltip text="Python"><IconBrandPython /></Tooltip>
<br />
<a class="data" href="https://git.fjla.uk/owlboard/db-manager" target="_blank">DB Manager version<br /><span class="data">{data?.["db-manager"] || "Unknown"}</span></a>
</p>
<p>
<Tooltip text="Go"><IconBrandGolang /></Tooltip>
<br />
<a class="data" href="https://git.fjla.uk/owlboard/mq-client" target="_blank">timetable-mgr<br /><span class="data">{data?.["mq-client"] || "Not installed"}</span></a>
</p>
</Island>
{:catch} {:catch}
<Island> <Island>
<p> <p>
<IconBrandSvelte /><IconBrandJavascript /><IconBrandTypescript /><br /> Web-app Version<br /><span class="data">{version}-{versionTag}</span>
Web-app Version<br /><span class="data" </p>
>{version}{#if versionTag}-{versionTag}{/if}</span <p>Unable to fetch server versions</p>
> </Island>
</p>
<p>Unable to fetch server application versions</p>
</Island>
{/await} {/await}
<Nav /> <Nav />
<style> <style>
p { p {
text-decoration: none; text-decoration: none;
padding: 15px; }
} .data {
.data { color: white;
color: white; text-decoration: none;
text-decoration: none; }
}
</style> </style>

View File

@ -1,205 +1,183 @@
<script lang="ts"> <script>
import Header from "$lib/navigation/header.svelte"; import Header from '$lib/navigation/header.svelte';
import Nav from "$lib/navigation/nav.svelte"; import Nav from '$lib/navigation/nav.svelte';
import Island from "$lib/islands/island.svelte"; import Island from '$lib/islands/island.svelte';
import Loading from "$lib/navigation/loading.svelte"; import Loading from '$lib/navigation/loading.svelte';
import { uuid } from "$lib/stores/uuid"; import { uuid } from '$lib/stores/uuid';
import StylesToc from "$lib/train/styles-toc.svelte"; import StylesToc from '$lib/train/styles-toc.svelte';
import { getApiUrl } from "$lib/scripts/upstream"; import { getApiUrl } from '$lib/scripts/upstream';
import toast from "svelte-french-toast";
import { onMount } from "svelte";
const title = "PIS Finder"; const title = 'PIS Finder';
const variables = { title: "Results" }; const variables = { title: 'Results' };
let entryPIS = ""; let entryPIS = '';
let entryStartCRS = ""; let entryStartCRS = '';
let entryEndCRS = ""; let entryEndCRS = '';
let data = []; let data = [];
let error = false; let error = false;
let errMsg = "Unknown Error"; let errMsg = 'Unknown Error';
let isLoading = false; let isLoading = false;
async function findByStartEnd() { async function findByStartEnd() {
isLoading = true; isLoading = true;
const url = `${getApiUrl()}/api/v2/pis/byStartEnd/${entryStartCRS}/${entryEndCRS}`; const url = `${getApiUrl()}/api/v2/pis/byStartEnd/${entryStartCRS}/${entryEndCRS}`;
await fetchData(url); await fetchData(url);
isLoading = false; isLoading = false;
}
async function findByPis() {
isLoading = true;
const url = `${getApiUrl()}/api/v2/pis/byCode/${entryPIS}`;
await fetchData(url);
isLoading = false;
}
async function fetchData(url) {
const options = {
method: 'GET',
headers: {
uuid: $uuid
}
};
const res = await fetch(url, options); // Enable Auth
if (res.status == 401) {
errMsg = 'You must be logged in to the staff version';
error = true;
return false;
} else if (res.status == 500) {
errMsg = 'Server Error, try again later';
error = true;
return false;
} }
const jsonData = await res.json();
/* Temporarily Disabled if (jsonData.ERROR == 'offline') {
async function findByPis() { errMsg = 'Connection error, check your internet connection and try again';
isLoading = true; error = true;
const url = `${getApiUrl()}/api/v2/pis/byCode/${entryPIS}`; return false;
await fetchData(url);
isLoading = false;
} }
*/ data = jsonData;
}
async function fetchData(url: string) { async function reset() {
const options = { data = [];
method: "GET", error = false;
headers: { entryPIS = '';
uuid: $uuid, entryStartCRS = '';
}, entryEndCRS = '';
}; }
const res = await fetch(url, options); // Enable Auth
if (res.status == 401) {
errMsg = "You must be logged in to the staff version";
toast.error("You must be registered");
error = true;
return false;
} else if (res.status == 500) {
errMsg = "Server Error, try again later";
toast.error("Server Error.", { duration: 7500 });
error = true;
return false;
}
const jsonData = await res.json();
if (jsonData.ERROR == "offline") {
errMsg = "Connection error, check your internet connection and try again";
toast.error("You are offline.");
error = true;
return false;
}
data = jsonData;
let count = data.length;
if (!count) {
toast.error("No PIS Codes found.");
} else {
toast.success(`${count} PIS Codes found`);
}
}
async function reset() {
data = [];
error = false;
entryPIS = "";
entryStartCRS = "";
entryEndCRS = "";
toast.success("Form reset");
isLoading = false;
}
onMount(() => {
toast("Registration soon required for PIS features.\n\nClick 'Register' in the menu.", {
duration: 3000,
});
});
</script> </script>
<Header {title} /> <Header {title} />
{#if isLoading} {#if isLoading}
<Loading /> <Loading />
{/if} {/if}
{#if error} {#if error}
<Island {variables}> <Island {variables}>
<p class="error">{errMsg}</p> <p class="error">{errMsg}</p>
</Island> </Island>
{:else if data.length} {:else if data.length}
<Island {variables}> <Island {variables}>
<table> <table>
<tr> <tr>
<th class="toc">TOC</th> <th class="toc">TOC</th>
<th class="code">Code</th> <th class="code">Code</th>
<th class="stops">Stops</th> <th class="stops">Stops</th>
</tr> </tr>
{#each data as item} {#each data as item}
<tr> <tr>
<td class="toc toc-data"><StylesToc toc={item.toc || "-"} /></td> <td class="toc toc-data"><StylesToc toc={item.toc || '-'} /></td>
<td class="code">{item.code}</td> <td class="code">{item.code}</td>
<td class="stops stops-data">{item.stops.join(" ")}</td> <td class="stops stops-data">{item.stops.join(' ')}</td>
</tr> </tr>
{/each} {/each}
</table> </table>
</Island> </Island>
{:else} {:else}
<p>To search by headcode use the Train Finder on the homepage</p> <p>To search by headcode use the Train Finder on the homepage</p>
<p>This feature now supports all GWR Services</p> <p>This feature is only supported for GWR West & Sleeper services</p>
<p class="label">Find By Start/End CRS:</p> <p class="label">Find By Start/End CRS:</p>
<form on:submit={findByStartEnd}> <form on:submit={findByStartEnd}>
<input type="text" maxlength="3" autocomplete="off" placeholder="Start" bind:value={entryStartCRS} /> <input type="text" maxlength="3" autocomplete="off" placeholder="Start" bind:value={entryStartCRS} />
<input type="text" maxlength="3" autocomplete="off" placeholder="End" bind:value={entryEndCRS} /> <input type="text" maxlength="3" autocomplete="off" placeholder="End" bind:value={entryEndCRS} />
<br /> <br />
<button type="submit">Search</button> <button type="submit">Search</button>
</form> </form>
<!-- FIND BY PIS CODE NOT WORKING AT PRESENT
<p class="label">Find By PIS Code:</p> <p class="label">Find By PIS Code:</p>
<form on:submit={findByPis}> <form on:submit={findByPis}>
<input type="number" max="9999" autocomplete="off" placeholder="PIS" bind:value={entryPIS} /> <input type="number" max="9999" autocomplete="off" placeholder="PIS" bind:value={entryPIS} />
<br /> <br />
<button type="submit">Search</button> <button type="submit">Search</button>
</form> </form>
-->
{/if} {/if}
<button id="reset" type="reset" on:click={reset}>Reset</button> <button id="reset" type="reset" on:click={reset}>Reset</button>
<Nav /> <Nav />
<style> <style>
p { p {
margin-left: 10px; margin-left: 10px;
margin-right: 10px; margin-right: 10px;
} }
.label { .label {
font-weight: 600; font-weight: 600;
color: var(--main-text-color); color: var(--main-text-color);
} }
input { input {
border: none; border: none;
border-radius: 50px; border-radius: 50px;
font-family: urwgothic, sans-serif; font-family: urwgothic, sans-serif;
text-align: center; text-align: center;
text-transform: uppercase; text-transform: uppercase;
width: 30%; width: 30%;
max-width: 250px; max-width: 250px;
height: 30px; height: 30px;
font-size: 16px; font-size: 16px;
margin-bottom: 15px; margin-bottom: 15px;
box-shadow: var(--box-shadow); box-shadow: var(--box-shadow);
} }
button { button {
border: none; border: none;
border-radius: 50px; border-radius: 50px;
font-family: urwgothic, sans-serif; font-family: urwgothic, sans-serif;
width: 25%; width: 25%;
max-width: 175px; max-width: 175px;
margin: 0px; margin: 0px;
margin-left: 10px; margin-left: 10px;
margin-right: 10px; margin-right: 10px;
height: 30px; height: 30px;
background-color: var(--island-bg-color); background-color: var(--island-bg-color);
color: white; color: white;
font-size: 16px; font-size: 16px;
box-shadow: var(--box-shadow); box-shadow: var(--box-shadow);
} }
table { table {
width: 100%; width: 100%;
margin: auto; margin: auto;
color: white; color: white;
} }
td { td {
padding-top: 5px; padding-top: 5px;
padding-bottom: 5px; padding-bottom: 5px;
} }
.toc { .toc {
width: 15%; width: 15%;
} }
.code { .code {
width: 20%; width: 20%;
} }
.toc-data { .toc-data {
text-transform: uppercase; text-transform: uppercase;
} }
.stops-data { .stops-data {
text-align: left; text-align: left;
font-family: firamono, monospace; font-family: firamono, monospace;
text-transform: uppercase; text-transform: uppercase;
} }
.error { .error {
color: white; color: white;
} }
#reset { #reset {
margin: 25px; margin: 25px;
} }
</style> </style>

View File

@ -1,39 +0,0 @@
<script lang="ts">
import type { LookupCardConfig } from "$lib/cards/Card.types";
import LookupCard from "$lib/cards/LookupCard.svelte";
import NearToMeCard from "$lib/cards/NearToMeCard.svelte";
import QuickLinkCard from "$lib/cards/QuickLinkCard.svelte";
import Header from "$lib/navigation/header.svelte";
import Nav from "$lib/navigation/nav.svelte";
import TimeBar from "$lib/navigation/TimeBar.svelte";
let LookupConfig: LookupCardConfig = {
title: "Live Arr/Dep Boards",
helpText: "Enter CRS, TIPLOC or STANOX code to see live departures",
placeholder: "Enter CRS/TIPLOC",
maxLen: 7,
formAction: "/ldb/",
fieldName: "station",
};
let TimetableConfig: LookupCardConfig = {
title: "Timetable & PIS",
helpText: "Enter a headcode to search the timetable and check PIS Codes",
placeholder: "Enter headcode",
maxLen: 4,
formAction: "/train/",
fieldName: "headcode",
};
function onRefresh() {
console.log("Refresh");
}
</script>
<Header title={"Test"} />
<TimeBar updatedTime={new Date()} />
<LookupCard config={LookupConfig} />
<LookupCard config={TimetableConfig} />
<NearToMeCard />
<QuickLinkCard />
<Nav />

View File

@ -1,109 +1,106 @@
<script lang="ts"> <script>
import Header from "$lib/navigation/header.svelte"; import Header from '$lib/navigation/header.svelte';
import Loading from "$lib/navigation/loading.svelte"; import Loading from '$lib/navigation/loading.svelte';
import Island from "$lib/islands/island.svelte"; import Island from '$lib/islands/island.svelte';
import Nav from "$lib/navigation/nav.svelte"; import Nav from '$lib/navigation/nav.svelte';
import { uuid } from "$lib/stores/uuid"; import { uuid } from '$lib/stores/uuid';
import { onMount } from "svelte"; import { onMount } from 'svelte';
import TrainDetail from "$lib/train/train-detail.svelte"; import TrainDetail from '$lib/train/train-detail.svelte';
import { getApiUrl } from "$lib/scripts/upstream"; import { getApiUrl } from '$lib/scripts/upstream';
import toast from "svelte-french-toast";
import TimeBar from "$lib/navigation/TimeBar.svelte";
let title = "Timetable Results"; let title = 'Timetable Results';
let id = ""; let id = '';
let data = []; let data = [];
let isLoading = true; let isLoading = true;
let error = false; let error = false;
let errMsg = ""; let errMsg = '';
$: { $: {
if (id) { if (id) {
title = id.toUpperCase(); title = id.toUpperCase();
} else { } else {
title = "Querying Timetable"; 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');
}
onMount(async () => {
isLoading = true;
id = (await getHeadcode()) || '';
const res = await fetchData(id);
if (res) {
data = res;
if (!data.length) {
error = true;
errMsg = 'No services found';
}
} }
isLoading = false;
});
onMount(async () => { async function fetchData(id = '') {
isLoading = true; const date = 'now';
id = (await getHeadcode()) || ""; const searchType = 'headcode';
const res = await fetchData(id); const options = {
if (res) { method: 'GET',
data = res; headers: {
if (!data.length) { uuid: $uuid
error = true; }
errMsg = "No services found"; };
} const url = `${getApiUrl()}/api/v2/timetable/train/${date}/${searchType}/${id}`;
} try {
isLoading = false; const res = await fetch(url, options);
if (res.status == 200) {
toast("Registration soon required for timetable features.\n\nClick 'Register' in the menu.", { return await res.json();
duration: 3000, } else if (res.status === 401) {
}); error = true;
}); errMsg = 'You must be logged into the staff version for this feature';
return false;
async function fetchData(id = "") { } else {
const date = "now"; error = true;
const searchType = "headcode"; errMsg = 'Unable to connect, check your connection and try again';
const options = { return false;
method: "GET", }
headers: { } catch (err) {
uuid: $uuid, error = true;
}, errMsg = 'Connection error, try again later';
};
const url = `${getApiUrl()}/api/v2/timetable/train/${date}/${searchType}/${id}`;
try {
const res = await fetch(url, options);
if (res.status == 200) {
return await res.json();
} else if (res.status === 401) {
error = true;
errMsg = "You must be logged into the staff version for this feature";
return false;
} else {
error = true;
errMsg = "Unable to connect, check your connection and try again";
return false;
}
} catch (err) {
error = true;
errMsg = "Connection error, try again later";
}
isLoading = false;
} }
isLoading = false;
}
</script> </script>
<Header {title} /> <Header {title} />
<TimeBar updatedTime={undefined} /> <div id="whitespace" />
{#if error} {#if error}
<Island> <Island>
<p style="font-weight:600">{errMsg}</p> <p style="font-weight:600">{errMsg}</p>
</Island> </Island>
{/if} {/if}
{#if isLoading} {#if isLoading}
<Loading /> <Loading />
{/if} {/if}
{#each data as service} {#each data as service}
{#if service} {#if service}
<TrainDetail {service} /> <TrainDetail {service} />
{/if} {/if}
{/each} {/each}
<Nav /> <Nav />
<style> <style>
p { #whitespace {
color: white; height: 15px;
font-size: 18px; }
font-weight: 600; p {
} color: white;
font-size: 18px;
font-weight: 600;
}
</style> </style>

View File

@ -1,58 +1,50 @@
/// <reference types="@sveltejs/kit" /> /// <reference types="@sveltejs/kit" />
import { build, files, version } from "$service-worker"; import { build, files, version } from '$service-worker';
const cacheName = `ob-${version}`; const cacheName = `ob-${version}`;
const pointlessConstant = true;
console.log(`pointlessContant is ${pointlessConstant}`);
const assets = [...build, ...files, "/service-worker.js"]; const assets = [...build, ...files, '/service-worker.js'];
const excludePatterns = [ self.addEventListener('install', (event) => {
"/static/images/screnshots", async function addToCache() {
"/images/screenshots", const cache = await caches.open(cacheName);
"/static/images/shortcuts", await cache.addAll(assets);
"/images/shortcuts", }
];
self.addEventListener("install", (event) => { event.waitUntil(addToCache());
async function addToCache() {
const cache = await caches.open(cacheName);
const assetsToCache = assets.filter(asset => {
return !excludePatterns.some(pattern => asset.startsWith(pattern));
});
await cache.addAll(assetsToCache);
}
event.waitUntil(addToCache());
}); });
self.addEventListener("activate", (event) => { self.addEventListener('activate', (event) => {
async function deleteOldCache() { async function deleteOldCache() {
for (const key of await caches.keys()) { for (const key of await caches.keys()) {
if (key !== cacheName) { if (key !== cacheName) {
await caches.delete(key); await caches.delete(key);
} }
}
} }
}
event.waitUntil(deleteOldCache()); event.waitUntil(deleteOldCache());
}); });
self.addEventListener("fetch", (event) => { self.addEventListener('fetch', (event) => {
if (event.request.method !== "GET") { if (event.request.method !== 'GET') {
return; return;
} }
async function respond() { async function respond() {
const cacheRes = await caches.match(event.request, { ignoreSearch: true }); const cacheRes = await caches.match(event.request, { ignoreSearch: true });
if (cacheRes) { if (cacheRes) {
return cacheRes; return cacheRes;
}
try {
return await fetch(event.request);
} catch (err) {
return { error: "OFFLINE", errorMsg: "You are offline" };
}
} }
event.respondWith(respond()); try {
return await fetch(event.request);
} catch (err) {
return { error: 'OFFLINE', errorMsg: 'You are offline' };
}
}
event.respondWith(respond());
}); });

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg enable-background="new 0 0 448 433" version="1.1" viewBox="0 0 448 433" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://web.resource.org/cc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<radialGradient id="a" cx="216.7" cy="393.79" r="296.7" gradientUnits="userSpaceOnUse">
<stop stop-color="#F4D708" offset="0"/>
<stop stop-color="#FCB400" offset="1"/>
</radialGradient>
<path d="m8.551 390.5 184.85-368.8s26.409-31.504 52.815 0c26.41 31.501 180.19 370.65 180.19 370.65s3.105 18.534-27.961 18.534-361.94 0-361.94 0-23.299 0-27.959-20.38z" fill="url(#a)"/>
<path d="m8.551 390.5 184.85-368.8s26.409-31.504 52.815 0c26.41 31.501 180.19 370.65 180.19 370.65s3.105 18.534-27.961 18.534-361.94 0-361.94 0-23.299 0-27.959-20.38z" fill="none" stroke="#E2A713" stroke-width="5"/>
<path d="m212.5 292.63c-13.168-79.969-19.75-123.12-19.75-129.45 0-7.703 2.551-13.926 7.66-18.676 5.105-4.746 10.871-7.121 17.293-7.121 6.949 0 12.82 2.535 17.609 7.598s7.188 11.023 7.188 17.883c0 6.543-6.668 49.801-20 129.77h-10zm27 38.17c0 6.098-2.156 11.301-6.469 15.613-4.313 4.309-9.461 6.465-15.453 6.465-6.098 0-11.301-2.156-15.613-6.465-4.313-4.313-6.465-9.516-6.465-15.613 0-5.992 2.152-11.141 6.465-15.453s9.516-6.469 15.613-6.469c5.992 0 11.141 2.156 15.453 6.469s6.48 9.45 6.48 15.44z"/>
<metadata><rdf:RDF><cc:Work><dc:format>image/svg+xml</dc:format><dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/><cc:license rdf:resource="http://creativecommons.org/licenses/publicdomain/"/><dc:publisher><cc:Agent rdf:about="http://openclipart.org/"><dc:title>Openclipart</dc:title></cc:Agent></dc:publisher><dc:title>Warning Notification</dc:title><dc:date>2007-02-08T17:08:47</dc:date><dc:description>Beveled yellow caution sign</dc:description><dc:source>http://openclipart.org/detail/3130/warning-notification-by-eastshores</dc:source><dc:creator><cc:Agent><dc:title>eastshores</dc:title></cc:Agent></dc:creator><dc:subject><rdf:Bag><rdf:li>alert</rdf:li><rdf:li>caution</rdf:li><rdf:li>clip art</rdf:li><rdf:li>clipart</rdf:li><rdf:li>icon</rdf:li><rdf:li>image</rdf:li><rdf:li>media</rdf:li><rdf:li>public domain</rdf:li><rdf:li>svg</rdf:li><rdf:li>warning</rdf:li></rdf:Bag></dc:subject></cc:Work><cc:License rdf:about="http://creativecommons.org/licenses/publicdomain/"><cc:permits rdf:resource="http://creativecommons.org/ns#Reproduction"/><cc:permits rdf:resource="http://creativecommons.org/ns#Distribution"/><cc:permits rdf:resource="http://creativecommons.org/ns#DerivativeWorks"/></cc:License></rdf:RDF></metadata></svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 B

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="4.191mm" height="4.191mm" version="1.1" viewBox="0 0 4.191 4.191" xmlns="http://www.w3.org/2000/svg">
<g transform="translate(-91.032 -156.47)">
<path d="m95.223 158.3v0.52916h-3.175c0.48507 0.48507 0.97014 0.97014 1.4552 1.4552-0.12524 0.12524-0.25047 0.25047-0.37571 0.37571l-2.0955-2.0955 2.0955-2.0955c0.12524 0.12524 0.25047 0.25047 0.37571 0.37571-0.48507 0.48507-0.97014 0.97014-1.4552 1.4552h3.175z" fill="#f9f9f9" stroke-width=".26458"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 510 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 468 B

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="3.7042mm" height="3.7042mm" version="1.1" viewBox="0 0 3.7042 3.7042" xmlns="http://www.w3.org/2000/svg">
<g transform="translate(-20.8 -106.38)">
<path d="m24.505 106.75-0.37306-0.37306-1.479 1.479-1.479-1.479-0.37306 0.37306 1.479 1.479-1.479 1.479 0.37306 0.37306 1.479-1.479 1.479 1.479 0.37306-0.37306-1.479-1.479z" fill="#f9f9f9" stroke-width=".26458"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 422 B

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="4.7625mm" height="3.175mm" version="1.1" viewBox="0 0 4.7625 3.175" xmlns="http://www.w3.org/2000/svg">
<g transform="translate(-54.25 -207.32)">
<path d="m54.25 207.32h4.7625v0.52917h-4.7625v-0.52917m0 1.3229h4.7625v0.52916h-4.7625v-0.52916m0 1.3229h4.7625v0.52917h-4.7625z" fill="#f9f9f9" stroke-width=".26458"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 378 B

Some files were not shown because too many files have changed in this diff Show More