Update prettier settings

This commit is contained in:
Fred Boniface 2024-04-30 11:17:06 +01:00
parent 1484a9068e
commit af58e923de
71 changed files with 4133 additions and 4114 deletions

View File

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

View File

@ -1,8 +1,8 @@
{
"useTabs": false,
"tabWidth": 2,
"tabWidth": 4,
"semi": true,
"singleQuote": true,
"singleQuote": false,
"trailingComma": "none",
"printWidth": 180,
"plugins": ["prettier-plugin-svelte"],

View File

@ -1,5 +1,5 @@
<script lang="ts">
import { onMount, onDestroy } from 'svelte';
import { onMount, onDestroy } from "svelte";
export let text: string;
let isVisible: boolean = false;

View File

@ -1,10 +1,10 @@
<script lang="ts">
import Island from '$lib/islands/island.svelte';
import Island from "$lib/islands/island.svelte";
export let variables = {
title: 'Uninitialised',
action: '/',
placeholder: 'Uninitialised',
queryName: 'uninitiailsed'
title: "Uninitialised",
action: "/",
placeholder: "Uninitialised",
queryName: "uninitiailsed"
};
</script>
@ -25,7 +25,7 @@
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;
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);
@ -37,7 +37,7 @@
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-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);

View File

@ -1,7 +1,7 @@
<script lang="ts">
import { fade } from 'svelte/transition';
import { fade } from "svelte/transition";
export let variables = { title: '' };
export let variables = { title: "" };
</script>
<div in:fade={{ duration: 250 }}>
@ -11,7 +11,7 @@
<style>
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-size: 20px;
color: var(--island-header-color);

View File

@ -1,7 +1,7 @@
<script lang="ts">
import { fade } from 'svelte/transition';
import { fade } from "svelte/transition";
export let variables = { title: '' };
export let variables = { title: "" };
</script>
<div in:fade={{ duration: 150 }} out:fade={{ duration: 150 }}>
@ -11,7 +11,7 @@
<style>
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);
font-weight: 600;
font-size: 20px;

View File

@ -1,8 +1,8 @@
<script lang="ts">
import Island from '$lib/islands/island.svelte';
import { ql } from '$lib/stores/quick-links';
import Island from "$lib/islands/island.svelte";
import { ql } from "$lib/stores/quick-links";
export let variables = {
title: 'Quick Links'
title: "Quick Links"
};
</script>
@ -43,7 +43,7 @@
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-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;

View File

@ -1,8 +1,8 @@
<script lang="ts">
import Island from '$lib/islands/island.svelte';
import { ql } from '$lib/stores/quick-links';
import Island from "$lib/islands/island.svelte";
import { ql } from "$lib/stores/quick-links";
export let variables = {
title: 'Quick Links'
title: "Quick Links"
};
let qlData: string[] = [];
@ -11,7 +11,7 @@
console.log(qlData);
}
let saveButton = 'Save';
let saveButton = "Save";
async function timeout(ms: number): Promise<any> {
return new Promise((resolve) => setTimeout(resolve, ms));
@ -19,36 +19,36 @@
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');
const inputs = document.getElementsByClassName("qlInput");
let inputLinks: string[] = [];
for (let item of inputs) {
let text = (<HTMLInputElement>item)?.value;
if (text !== '') {
if (text !== "") {
inputLinks.push(text);
}
}
console.log(inputLinks);
ql.set(inputLinks);
saveButton = '&#10004;';
saveButton = "&#10004;";
await timeout(3000);
saveButton = 'Saved';
saveButton = "Saved";
}
function clearQl() {
ql.set([]);
saveButton = 'Saved';
saveButton = "Saved";
}
function addQlBox() {
saveButton = 'Save';
const updatedQl = [...$ql, ''];
saveButton = "Save";
const updatedQl = [...$ql, ""];
$ql = updatedQl;
ql.set(updatedQl);
}
function handleClick(event: any) {
// Handle the click event here
console.log('Island Clicked');
console.log("Island Clicked");
// You can access the `variables` passed to the Island component here if needed
}
</script>
@ -92,7 +92,7 @@
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-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;
@ -107,7 +107,7 @@
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-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);

View File

@ -1,5 +1,5 @@
<script lang="ts">
import Island from '$lib/islands/island.svelte';
import Island from "$lib/islands/island.svelte";
interface resultObj {
results: boolean;
@ -9,7 +9,7 @@
export let resultObject: resultObj = {
results: true,
title: '',
title: "",
resultLines: []
};

View File

@ -1,5 +1,5 @@
<script>
import { fly } from 'svelte/transition';
import { fly } from "svelte/transition";
export let alerts = [];
$: uniqueAlerts = [...new Set(alerts)];
@ -11,7 +11,7 @@
}
function numberAsWord(number) {
const words = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'];
const words = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"];
let word = words[number];
if (word) {
return word;

View File

@ -1,12 +1,12 @@
<script>
export let station = '';
export let title = 'Loading...';
import { onMount } from 'svelte';
import Loading from '$lib/navigation/loading.svelte';
import OverlayIsland from '$lib/islands/overlay-island.svelte';
import AlertBar from '$lib/ldb/nrcc/alert-bar.svelte';
import Island from '$lib/islands/island.svelte';
import { getApiUrl } from '$lib/scripts/upstream';
export let station = "";
export let title = "Loading...";
import { onMount } from "svelte";
import Loading from "$lib/navigation/loading.svelte";
import OverlayIsland from "$lib/islands/overlay-island.svelte";
import AlertBar from "$lib/ldb/nrcc/alert-bar.svelte";
import Island from "$lib/islands/island.svelte";
import { getApiUrl } from "$lib/scripts/upstream";
let requestedStation;
$: requestedStation = station;
@ -59,9 +59,9 @@
const data = await fetch(`${getApiUrl()}/api/v2/live/station/${requestedStation}/public`);
jsonData = await data.json();
} catch (error) {
console.error('Error fetching data:', error);
console.error("Error fetching data:", error);
dataExists = false;
title = 'Not Found';
title = "Not Found";
} finally {
isLoading = false; // Clear loading state
}
@ -72,38 +72,38 @@
let output;
let change;
switch (string) {
case 'Delayed':
output = 'LATE';
change = 'changed';
case "Delayed":
output = "LATE";
change = "changed";
break;
case 'Cancelled':
output = 'CANC';
change = 'cancelled';
case "Cancelled":
output = "CANC";
change = "cancelled";
break;
case 'On Time':
case 'On time':
output = 'RT';
change = '';
case "On Time":
case "On time":
output = "RT";
change = "";
break;
case '':
output = '-';
change = '';
case "":
output = "-";
change = "";
break;
case undefined:
output = '-';
change = '';
output = "-";
change = "";
break;
case 'No report':
output = '-';
change = '';
case "No report":
output = "-";
change = "";
break;
case 'undefined':
case "undefined":
output = false;
change = '';
change = "";
break;
default:
output = string;
change = 'changed';
change = "changed";
}
return { data: output, changed: change };
}
@ -170,19 +170,19 @@
<tr>
<td class="origdest from" on:click={loadService(service.serviceID)} on:keypress={loadService(service.serviceID)}>
{#if Array.isArray(service.origin?.location)}
{service.origin.location[0]['locationName'] + ' & ' + service.origin.location[1]['locationName']}
{service.origin.location[0]["locationName"] + " & " + service.origin.location[1]["locationName"]}
{:else}
{service.origin?.location?.locationName || ''}
{service.origin?.location?.locationName || ""}
{/if}
</td>
<td class="origdest to" on:click={loadService(service.serviceID)} on:keypress={loadService(service.serviceID)}>
{#if Array.isArray(service.destination?.location)}
{service.destination.location[0]['locationName'] + ' & ' + service.destination.location[0]['locationName']}
{service.destination.location[0]["locationName"] + " & " + service.destination.location[0]["locationName"]}
{:else}
{service.destination?.location?.locationName || ''}
{service.destination?.location?.locationName || ""}
{/if}
</td>
<td class="plat">{service.platform || '-'}</td>
<td class="plat">{service.platform || "-"}</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.std).data}</td>
@ -192,9 +192,9 @@
<tr
><td colspan="7">
<p class="service-detail">
A {service.operator || 'Unknown'} service
{#if service['length']}
with {service['length'] || 'some'} coaches
A {service.operator || "Unknown"} service
{#if service["length"]}
with {service["length"] || "some"} coaches
{/if}
</p>
{#if service.delayReason}
@ -225,9 +225,11 @@
</tr>
{#each busServices as service}
<tr>
<td class="origdest from" on:click={loadBusService(service.serviceID)} on:keypress={loadBusService(service.serviceID)}>{service.origin?.location?.locationName || ''}</td>
<td class="origdest from" on:click={loadBusService(service.serviceID)} on:keypress={loadBusService(service.serviceID)}
>{service.origin?.location?.locationName || ""}</td
>
<td class="origdest to" on:click={loadBusService(service.serviceID)} on:keypress={loadBusService(service.serviceID)}
>{service.destination?.location?.locationName || ''}</td
>{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>
@ -238,7 +240,7 @@
<tr
><td colspan="7">
<p class="service-detail">
A {service.operator || 'Unknown'} service
A {service.operator || "Unknown"} service
</p>
{#if service.delayReason}
<p class="service-detail">{service.delayReason}</p>
@ -266,8 +268,8 @@
</tr>
{#each ferryServices as service}
<tr>
<td class="origdest from">{service.origin?.location?.locationName || ''}</td>
<td class="origdest to">{service.destination?.location?.locationName || ''}</td>
<td class="origdest from">{service.origin?.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.eta).changed}">{parseTime(service.eta).data}</td>
<td class="time">{parseTime(service.std).data}</td>
@ -318,9 +320,12 @@
<td>{serviceDetail.previousCallingPoints.callingPointList.callingPoint.locationName}</td>
<td>{serviceDetail.previousCallingPoints.callingPointList.callingPoint.st}</td>
<td
class="time {parseTime(serviceDetail.previousCallingPoints.callingPointList.callingPoint.at || serviceDetail.previousCallingPoints.callingPointList.callingPoint.et)
.changed}"
>{parseTime(serviceDetail.previousCallingPoints.callingPointList.callingPoint.at || serviceDetail.previousCallingPoints.callingPointList.callingPoint.et).data}</td
class="time {parseTime(
serviceDetail.previousCallingPoints.callingPointList.callingPoint.at || serviceDetail.previousCallingPoints.callingPointList.callingPoint.et
).changed}"
>{parseTime(
serviceDetail.previousCallingPoints.callingPointList.callingPoint.at || serviceDetail.previousCallingPoints.callingPointList.callingPoint.et
).data}</td
>
</tr>
{/if}

View File

@ -1,20 +1,20 @@
// Fetches StaffLDB Data, correctly formats DATE fields and returns the data
import { getApiUrl } from '$lib/scripts/upstream';
import { uuid } from '$lib/stores/uuid';
import type { ApiResponse, StaffLdb } from '@owlboard/ts-types';
import { getApiUrl } from "$lib/scripts/upstream";
import { uuid } from "$lib/stores/uuid";
import type { ApiResponse, StaffLdb } from "@owlboard/ts-types";
// Fetch StaffLDB Data, and returns the data after hydration (convert date types etc.)
export async function fetchStaffLdb(station: string): Promise<ApiResponse<StaffLdb>> {
const url = `${getApiUrl()}/api/v2/live/station/${station}/staff`;
let uuid_value: string = '';
let uuid_value: string = "";
const unsubscribe = uuid.subscribe((value) => {
uuid_value = value;
});
const fetchOpts = {
method: 'GET',
method: "GET",
headers: {
uuid: uuid_value
}
@ -28,7 +28,7 @@ export async function fetchStaffLdb(station: string): Promise<ApiResponse<StaffL
// Parse dates within the JSON response
function parseFormat(jsonString: any): ApiResponse<StaffLdb> {
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$/;
if (dateRegex.test(value)) {
return new Date(value);

View File

@ -1,18 +1,18 @@
<script lang="ts">
import TableGenerator from './table/table-generator.svelte';
import Loading from '$lib/navigation/loading.svelte';
import type { ApiResponse, StaffLdb } from '@owlboard/ts-types';
import { detailInit, defineDetail } from './train-detail';
import TrainDetail from './train-detail.svelte';
import { fetchStaffLdb } from './fetch';
import AlertBar from '../nrcc/alert-bar.svelte';
import TableGenerator from "./table/table-generator.svelte";
import Loading from "$lib/navigation/loading.svelte";
import type { ApiResponse, StaffLdb } from "@owlboard/ts-types";
import { detailInit, defineDetail } from "./train-detail";
import TrainDetail from "./train-detail.svelte";
import { fetchStaffLdb } from "./fetch";
import AlertBar from "../nrcc/alert-bar.svelte";
export let station: string;
export let title: string | undefined = 'Loading...';
export let title: string | undefined = "Loading...";
let errorDetail = {
code: '',
message: ''
code: "",
message: ""
};
let nrcc: string[] = [];
@ -37,9 +37,9 @@
}
return data.data;
}
errorDetail.code = data.obStatus.toString() || 'UNKNOWN';
errorDetail.message = data.obMsg || 'An unknown error occoured';
throw new Error('Unable to Fetch Data');
errorDetail.code = data.obStatus.toString() || "UNKNOWN";
errorDetail.message = data.obMsg || "An unknown error occoured";
throw new Error("Unable to Fetch Data");
}
</script>

View File

@ -1,8 +1,8 @@
<script lang="ts">
import Reason from '$lib/raw-fetchers/reason.svelte';
import { tocs as tocMap } from '$lib/stores/tocMap';
import Reason from "$lib/raw-fetchers/reason.svelte";
import { tocs as tocMap } from "$lib/stores/tocMap";
import type { TrainServices, ServiceLocation } from '@owlboard/ts-types';
import type { TrainServices, ServiceLocation } from "@owlboard/ts-types";
export let services: TrainServices[];
export let click: Function;
@ -17,7 +17,7 @@
for (const location of locations) {
tiplocs.push(location.tiploc);
}
return tiplocs.join(' & ');
return tiplocs.join(" & ");
}
async function classGenerator(service: TrainServices) {
@ -28,21 +28,21 @@
let platArr: string[] = [];
if (service.isCancelled) {
otherArr.push('canc');
otherArr.push("canc");
}
if (service.serviceIsSupressed) {
otherArr.push('nonPass');
otherArr.push("nonPass");
}
if (service.platformIsHidden) {
platArr.push('nonPass');
platArr.push("nonPass");
}
function checkLateEarly(originalTime: Date | undefined, comparedTime: Date | undefined, arr: string[]) {
if (originalTime !== undefined && comparedTime instanceof Date) {
if (originalTime < comparedTime) {
arr.push('late');
arr.push("late");
} else if (originalTime > comparedTime) {
arr.push('early');
arr.push("early");
}
}
}
@ -53,18 +53,18 @@
checkLateEarly(service.std, service.atd, depArr);
return {
other: otherArr.join(' '),
arr: arrArr.join(' '),
dep: depArr.join(' '),
plat: platArr.join(' ')
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 (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');
const hours = date.getHours().toString().padStart(2, "0");
const minutes = date.getMinutes().toString().padStart(2, "0");
return `${hours}:${minutes}`;
} else {
return false;
@ -104,15 +104,15 @@
<!-- 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>
<td class="plat {classes.other} {classes.plat}">{service.platform || "-"}</td>
<!-- SCHEDULED ARR -->
<td class="time schTime {classes.other}">{fmtTime(service?.sta) || '-'}</td>
<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>
<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>
<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>
<td class="time {classes.other} {classes.dep}">{fmtTime(service.etd) || fmtTime(service.atd) || "-"}</td>
{/await}
</tr>
<tr>
@ -124,13 +124,13 @@
{#if service.delayReason}
<br />
<span class="delayTxt">
<Reason type={'delay'} code={service.delayReason} />
<Reason type={"delay"} code={service.delayReason} />
</span>
{/if}
{#if service.cancelReason}
<br />
<span class="cancTxt">
<Reason type={'cancel'} code={service.cancelReason} />
<Reason type={"cancel"} code={service.cancelReason} />
</span>
{/if}
</td>

View File

@ -1,14 +1,14 @@
<script>
import OverlayIsland from '$lib/islands/overlay-island.svelte';
import { fade } from 'svelte/transition';
import Reason from '$lib/raw-fetchers/reason.svelte';
import { uuid } from '$lib/stores/uuid';
import StylesToc from '$lib/train/styles-toc.svelte';
import { getApiUrl } from '$lib/scripts/upstream';
import OverlayIsland from "$lib/islands/overlay-island.svelte";
import { fade } from "svelte/transition";
import Reason from "$lib/raw-fetchers/reason.svelte";
import { uuid } from "$lib/stores/uuid";
import StylesToc from "$lib/train/styles-toc.svelte";
import { getApiUrl } from "$lib/scripts/upstream";
export let detail = {
uid: '',
rid: '',
headcode: '',
uid: "",
rid: "",
headcode: "",
show: true
};
export let close;
@ -22,7 +22,7 @@
console.log(`Requested Station: ${rid}`);
const url = `${getApiUrl()}/api/v2/live/train/rid/${rid}`;
const opt = {
method: 'GET',
method: "GET",
headers: {
uuid: $uuid
}
@ -30,7 +30,7 @@
const data = await fetch(url, opt);
return await data.json();
} catch (error) {
console.error('Error fetching data:', error);
console.error("Error fetching data:", error);
}
}
@ -40,19 +40,19 @@
try {
const result = Math.floor(location.lateness / 60);
if (result === 0) {
(string = 'RT'), (state = '');
(string = "RT"), (state = "");
} else if (result < 0) {
(string = -result + 'E'), (state = 'early');
(string = -result + "E"), (state = "early");
} else if (result > 0) {
(string = result + 'L'), (state = 'late');
(string = result + "L"), (state = "late");
}
} catch {
(string = ''), (state = '');
(string = ""), (state = "");
}
} else if (location.arrivalType === 'Delayed') {
(string = ''), (state = 'late');
} else if (location.arrivalType === "Delayed") {
(string = ""), (state = "late");
} else {
(string = ''), (state = 'noreport');
(string = ""), (state = "noreport");
}
return {
string: string,
@ -61,8 +61,8 @@
}
function parseTime(date) {
const parsedTime = date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
return parsedTime !== 'Invalid Date' ? parsedTime : null;
const parsedTime = date.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
return parsedTime !== "Invalid Date" ? parsedTime : null;
}
function parseTimes(service) {
@ -79,19 +79,19 @@
parsedEtd = parseTime(etd),
parsedAtd = parseTime(atd);
if (service.isCancelled) {
(parsedEta = 'CANC'), (parsedEtd = 'CANC');
(parsedEta = "CANC"), (parsedEtd = "CANC");
}
let times = {
sta: parsedSta || '-',
eata: parsedEta || parsedAta || '-',
aEst: parsedEta ? 'estimate' : '',
std: parsedStd || '-',
eatd: parsedEtd || parsedAtd || '-',
dEst: parsedEtd ? 'estimate' : ''
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');
(parsedEta = "CANC"), (parsedEtd = "CANC");
(times.aEst = "canc"), (times.dEst = "canc");
}
return times;
}
@ -139,16 +139,16 @@
{#each train.GetServiceDetailsResult.locations.location as location}
<tr>
<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)}
<td />
<td />
<td />
<td />
{: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.std}</td>
<td class={location?.isPass === "true" ? "pass" : ""}>{times.std}</td>
<td class="{location?.isPass === 'true' ? 'pass' : ''} {times.dEst}">{times.eatd}</td>
{/await}
{#await parseDelay(location)}

View File

@ -10,9 +10,9 @@ export interface Detail {
export function detailInit(): Detail {
const detail: Detail = {
show: false,
headcode: '',
rid: '',
uid: ''
headcode: "",
rid: "",
uid: ""
};
return detail;
}

View File

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

View File

@ -1,35 +1,35 @@
/* FONTS */
@font-face {
font-family: 'firamono';
src: url('/font/firamono/firamono-regular.woff2') format('woff2'), url('/font/firamono/firamono-regular.woff') format('woff'),
url('/font/firamono/firamono-regular.ttf') format('truetype');
font-family: "firamono";
src: url("/font/firamono/firamono-regular.woff2") format("woff2"), url("/font/firamono/firamono-regular.woff") format("woff"),
url("/font/firamono/firamono-regular.ttf") format("truetype");
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'firamono';
src: url('/font/firamono/firamono-500.woff2') format('woff2'), url('/font/firamono/firamono-500.woff') format('woff'), url('/font/firamono/firamono-500.ttf') format('truetype');
font-family: "firamono";
src: url("/font/firamono/firamono-500.woff2") format("woff2"), url("/font/firamono/firamono-500.woff") format("woff"), url("/font/firamono/firamono-500.ttf") format("truetype");
font-weight: 500;
font-style: normal;
}
@font-face {
font-family: 'urwgothic';
src: url('/font/urwgothic/urwgothic.woff2') format('woff2'), url('/font/urwgothic/urwgothic.woff') format('woff'), url('/font/urwgothic/urwgothic.ttf') format('truetype');
font-family: "urwgothic";
src: url("/font/urwgothic/urwgothic.woff2") format("woff2"), url("/font/urwgothic/urwgothic.woff") format("woff"), url("/font/urwgothic/urwgothic.ttf") format("truetype");
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'urwgothic';
src: url('/font/urwgothic/urwgothicDemi.woff2') format('woff2'), url('/font/urwgothic/urwgothicDemi.woff') format('woff'),
url('/font/urwgothic/urwgothicDemi.ttf') format('truetype');
font-family: "urwgothic";
src: url("/font/urwgothic/urwgothicDemi.woff2") format("woff2"), url("/font/urwgothic/urwgothicDemi.woff") format("woff"),
url("/font/urwgothic/urwgothicDemi.ttf") format("truetype");
font-weight: 900;
font-style: normal;
}
@font-face {
font-family: 'ubuntu';
src: url('/font/ubuntumono/ubuntumono-regular.woff2') format('woff2'), url('/font/ubuntumono/ubuntumono-regular.woff') format('woff'),
url('/font/ubuntumono/ubuntumono-regular.ttf') format('truetype');
font-family: "ubuntu";
src: url("/font/ubuntumono/ubuntumono-regular.woff2") format("woff2"), url("/font/ubuntumono/ubuntumono-regular.woff") format("woff"),
url("/font/ubuntumono/ubuntumono-regular.ttf") format("truetype");
font-weight: 400;
font-style: normal;
}

View File

@ -1,5 +1,5 @@
<script lang="ts">
import { logout } from '$lib/libauth';
import { logout } from "$lib/libauth";
async function logoutAction() {
await logout();

View File

@ -1,5 +1,5 @@
<script>
export let title = 'title';
export let title = "title";
</script>
<div class="headerBar">

View File

@ -1,5 +1,5 @@
<script>
import { fade } from 'svelte/transition';
import { fade } from "svelte/transition";
</script>
<div id="container" in:fade={{ delay: 150, duration: 250 }} out:fade={{ duration: 250 }}>
@ -22,7 +22,7 @@
border: solid 5px var(--overlay-island-bg-color);
border-bottom-color: white;
border-radius: 50%;
content: '';
content: "";
height: 40px;
width: 40px;
position: absolute;

View File

@ -1,13 +1,13 @@
<script>
const links = [
{
title: 'Home',
path: '/',
title: "Home",
path: "/",
icon: IconHome
}
];
import { page } from '$app/stores';
import { IconHome } from '@tabler/icons-svelte';
import { page } from "$app/stores";
import { IconHome } from "@tabler/icons-svelte";
</script>
<footer>

View File

@ -1,28 +1,28 @@
<script>
const links = [
{
title: 'Home',
path: '/',
title: "Home",
path: "/",
icon: IconHome
},
{
title: 'PIS Finder',
path: '/pis/',
title: "PIS Finder",
path: "/pis/",
icon: IconDialpad
},
{
title: 'Menu',
path: '/more/',
title: "Menu",
path: "/more/",
icon: IconMenu2
}
];
import { page } from '$app/stores';
import { IconHome, IconMenu2, IconDialpad } from '@tabler/icons-svelte';
import { page } from "$app/stores";
import { IconHome, IconMenu2, IconDialpad } from "@tabler/icons-svelte";
</script>
<footer>
{#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 || $page.url.pathname == item.path + "/"}>
<svelte:component this={item.icon} />
<br />
<span>{item.title}</span>

View File

@ -1,7 +1,7 @@
<script lang="ts">
import { welcome } from '$lib/stores/welcome';
import { fade } from 'svelte/transition';
import { version } from '$lib/stores/version';
import { welcome } from "$lib/stores/welcome";
import { fade } from "svelte/transition";
import { version } from "$lib/stores/version";
let pageNum: number = 0;
@ -20,14 +20,14 @@
}
const pageText: string[] = [
'<h3>PIS Codes</h3>' +
'<p>An effort has been made to support PIS codes accross the GWR network</p>' +
'<p>The vast majority of codes across West, LTV, HEx and Sleeper services are now available.</p>' +
'<p>The easiest way to find a PIS code is to type your headcode into the homepage, then select your service</p>',
'<h3>Resgistration Update</h3>' +
'<p>The registration issue has been fixed and registrations are now open.</p>' +
'<p>Headcode and PIS Lookups will still be possible without registering but only for a limited time.</p>' +
'<p>You will receive further warning before mandatory registration is re-enabled.</p>'
"<h3>PIS Codes</h3>" +
"<p>An effort has been made to support PIS codes accross the GWR network</p>" +
"<p>The vast majority of codes across West, LTV, HEx and Sleeper services are now available.</p>" +
"<p>The easiest way to find a PIS code is to type your headcode into the homepage, then select your service</p>",
"<h3>Resgistration Update</h3>" +
"<p>The registration issue has been fixed and registrations are now open.</p>" +
"<p>Headcode and PIS Lookups will still be possible without registering but only for a limited time.</p>" +
"<p>You will receive further warning before mandatory registration is re-enabled.</p>"
];
</script>

View File

@ -1,26 +1,26 @@
<script>
import { getApiUrl } from '$lib/scripts/upstream';
import { uuid } from '$lib/stores/uuid';
import { getApiUrl } from "$lib/scripts/upstream";
import { uuid } from "$lib/stores/uuid";
export let code = '';
export let type = '';
export let code = "";
export let type = "";
async function getDelay(code = '') {
async function getDelay(code = "") {
console.log(`Fetching delay reason ${code}`);
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 = '') {
async function getCancel(code = "") {
console.log(`Fetching cancel reason ${code}`);
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 = '') {
async function getReason(code = "") {
const url = `${getApiUrl()}/api/v2/ref/reasonCode/${code}`;
const options = {
method: 'GET',
method: "GET",
headers: {
uuid: $uuid
}
@ -30,7 +30,7 @@
}
</script>
{#if type === 'cancel'}
{#if type === "cancel"}
{#await getCancel(code)}
This train has been cancelled
{:then reason}
@ -38,7 +38,7 @@
{:catch}
This train has been cancelled
{/await}
{:else if type === 'delay'}
{:else if type === "delay"}
{#await getDelay(code)}
This train has been delayed
{:then reason}

View File

@ -1,11 +1,11 @@
import { dev } from '$app/environment';
import { uuid } from '$lib/stores/uuid';
import type { Unsubscriber } from 'svelte/store';
import { dev } from "$app/environment";
import { uuid } from "$lib/stores/uuid";
import type { Unsubscriber } from "svelte/store";
function getUrlString(): string {
if (dev) {
const testUrl: string = 'http://localhost:8460';
console.info('DEVMODE active, using testing URL: ', testUrl);
const testUrl: string = "http://localhost:8460";
console.info("DEVMODE active, using testing URL: ", testUrl);
return testUrl;
} else {
const currentUrl: string = `https://${window.location.host}`;
@ -14,18 +14,18 @@ function getUrlString(): string {
}
export async function apiGet(path: string): Promise<any> {
let uuidString: string = '';
let uuidString: string = "";
let unsubscribe: Unsubscriber;
try {
unsubscribe = uuid.subscribe((value) => {
uuidString = value;
});
} catch (err) {
throw new Error('Unable to read UUID');
throw new Error("Unable to read UUID");
}
const options = {
method: 'GET',
method: "GET",
headers: {
uuid: uuidString
}
@ -35,15 +35,15 @@ export async function apiGet(path: string): Promise<any> {
const res = await fetch(getUrlString() + path, options);
if (!res.ok) {
throw new Error('Network response not ok');
throw new Error("Network response not ok");
}
const contentType = res.headers.get('content-type');
if (!contentType || !contentType.includes('application/json')) {
throw new Error('Invalid response. Require JSON.');
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);
console.error("Error fetching data:", err);
throw err;
} finally {
unsubscribe();

View File

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

View File

@ -1,14 +1,14 @@
import { writable, type Writable } from 'svelte/store';
import { browser } from '$app/environment';
import { writable, type Writable } from "svelte/store";
import { browser } from "$app/environment";
export const ql = writable(fromLocalStorage('ql', []));
toLocalStorage(ql, 'ql');
export const ql = writable(fromLocalStorage("ql", []));
toLocalStorage(ql, "ql");
function fromLocalStorage(storageKey: string, fallback: string[]): string[] {
if (browser) {
const storedValue = localStorage.getItem(storageKey);
if (storedValue !== 'undefined' && storedValue !== null) {
return typeof fallback === 'object' ? JSON.parse(storedValue) : storedValue;
if (storedValue !== "undefined" && storedValue !== null) {
return typeof fallback === "object" ? JSON.parse(storedValue) : storedValue;
}
}
return fallback;
@ -17,7 +17,7 @@ function fromLocalStorage(storageKey: string, fallback: string[]): string[] {
function toLocalStorage(store: Writable<string[]>, storageKey: string) {
if (browser) {
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);
});

View File

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

View File

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

View File

@ -1,3 +1,3 @@
export const version: string = '2024.04.5';
export const versionTag: string = '';
export const version: string = "2024.04.5";
export const versionTag: string = "";
export const showWelcome: boolean = false;

View File

@ -1,13 +1,13 @@
import { writable, type Writable } from 'svelte/store';
import { browser } from '$app/environment';
import { writable, type Writable } from "svelte/store";
import { browser } from "$app/environment";
export const welcome = writable(fromLocalStorage('welcome', '0'));
toLocalStorage(welcome, 'welcome');
export const welcome = writable(fromLocalStorage("welcome", "0"));
toLocalStorage(welcome, "welcome");
function fromLocalStorage(storageKey: string, fallback: string) {
if (browser) {
const storedValue = localStorage.getItem(storageKey);
if (storedValue !== 'undefined') {
if (storedValue !== "undefined") {
return storedValue;
}
}

View File

@ -1,19 +1,19 @@
<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;
</script>
{#if pisObject}
{#if typeof pisObject === 'string' || typeof pisObject === 'number'}
{#if typeof pisObject === "string" || typeof pisObject === "number"}
<span class="pis">PIS: {pisObject}</span>
{:else if pisObject['skipCount'] === 0}
{:else if pisObject["skipCount"] === 0}
<span class="pis">PIS: {pisObject.code}</span>
{:else if pisObject['skipCount'] > 0}
{:else if pisObject["skipCount"] > 0}
<span class="pis">PIS: {pisObject.code}</span>
<br />
<span class="pis-text"
>(skip {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}

View File

@ -2,7 +2,7 @@
export let toc: string;
export let full: boolean = false;
import { tocs as map } from '$lib/stores/tocMap';
import { tocs as map } from "$lib/stores/tocMap";
let text: string;

View File

@ -1,22 +1,22 @@
<script lang="ts">
import { fly } from 'svelte/transition';
import { uuid } from '$lib/stores/uuid';
import LoadingText from '$lib/navigation/loading-text.svelte';
import StylesToc from './styles-toc.svelte';
import { getApiUrl } from '$lib/scripts/upstream';
import PisHandler from '$lib/train/pis-handler.svelte';
import { fly } from "svelte/transition";
import { uuid } from "$lib/stores/uuid";
import LoadingText from "$lib/navigation/loading-text.svelte";
import StylesToc from "./styles-toc.svelte";
import { getApiUrl } from "$lib/scripts/upstream";
import PisHandler from "$lib/train/pis-handler.svelte";
import type { OB_TrainTT_service } from '@owlboard/ts-types';
import TrainIcons from './trainIcons.svelte';
import type { OB_TrainTT_service } from "@owlboard/ts-types";
import TrainIcons from "./trainIcons.svelte";
export let service: OB_TrainTT_service;
let isExpanded = false;
async function getTrainByUID(tuid = '') {
async function getTrainByUID(tuid = "") {
const url = `${getApiUrl()}/api/v2/timetable/train/now/byTrainUid/${tuid}`;
const options = {
method: 'GET',
method: "GET",
headers: {
uuid: $uuid
}
@ -25,7 +25,7 @@
if (res.status === 200) {
return await res.json();
} else {
throw new Error('Unable to Fetch');
throw new Error("Unable to Fetch");
}
}
@ -37,9 +37,9 @@
<div class="container">
<div class="container-header" on:click={expand} on:keypress={expand}>
<span class="header"
><StylesToc toc={service?.operator || ''} />
{service?.stops[0]['publicDeparture'] || service?.stops[0]['wttDeparture']}
{service?.stops[0]['tiploc']} to {service?.stops[service['stops'].length - 1]['tiploc']}</span
><StylesToc toc={service?.operator || ""} />
{service?.stops[0]["publicDeparture"] || service?.stops[0]["wttDeparture"]}
{service?.stops[0]["tiploc"]} to {service?.stops[service["stops"].length - 1]["tiploc"]}</span
>
<span id="container-arrow" class:isExpanded>V</span>
</div>
@ -48,28 +48,28 @@
{#await getTrainByUID(service.trainUid)}
<LoadingText />
{: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">The service may have been retimed, re-routed or removed from todays timetable completely.</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}
<div class="detailOperator"><StylesToc toc={service?.operator || ''} full={true} /></div>
<div class="detailOperator"><StylesToc toc={service?.operator || ""} full={true} /></div>
<TrainIcons serviceDetails={serviceDetail.serviceDetail} />
{#if serviceDetail.pis}
<PisHandler pisObject={serviceDetail.pis} />
{/if}
<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 class="svc-detail">
Days Run: {serviceDetail?.daysRun.join(', ').toUpperCase() || 'Unknown'}
Days Run: {serviceDetail?.daysRun.join(", ").toUpperCase() || "Unknown"}
</p>
<p class="svc-detail validity">
Valid From: {new Date(serviceDetail.scheduleStart).toLocaleDateString('en-GB', {
timeZone: 'UTC'
})} - {new Date(serviceDetail.scheduleEnd).toLocaleDateString('en-GB', {
timeZone: 'UTC'
Valid From: {new Date(serviceDetail.scheduleStart).toLocaleDateString("en-GB", {
timeZone: "UTC"
})} - {new Date(serviceDetail.scheduleEnd).toLocaleDateString("en-GB", {
timeZone: "UTC"
})}
</p>
<table>
@ -84,19 +84,19 @@
<tr>
{#if stop.publicArrival || stop.publicDeparture}
<td>{stop.tiploc}</td>
<td>{stop.platform || '-'}</td>
<td>{stop.publicArrival || '-'}</td>
<td>{stop.publicDeparture || '-'}</td>
<td>{stop.platform || "-"}</td>
<td>{stop.publicArrival || "-"}</td>
<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>
<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">{stop.platform || stop.depLine || stop.arrLine || "-"}</td>
<td class="pass">-</td>
<td class="pass">{stop.pass || '-'}</td>
<td class="pass">{stop.pass || "-"}</td>
{/if}
</tr>
{/each}

View File

@ -1,7 +1,7 @@
<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';
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>

View File

@ -1,8 +1,8 @@
<script>
import { page } from '$app/stores';
import Header from '$lib/navigation/header.svelte';
import Nav from '$lib/navigation/nav.svelte';
const title = 'OwlBoard - Error';
import { page } from "$app/stores";
import Header from "$lib/navigation/header.svelte";
import Nav from "$lib/navigation/nav.svelte";
const title = "OwlBoard - Error";
</script>
<Header {title} />

View File

@ -1,9 +1,9 @@
<script>
import '$lib/themes.css';
import '$lib/main.css';
import { dev } from '$app/environment';
import DevBanner from '$lib/DevBanner.svelte';
import { page } from '$app/stores';
import "$lib/themes.css";
import "$lib/main.css";
import { dev } from "$app/environment";
import DevBanner from "$lib/DevBanner.svelte";
import { page } from "$app/stores";
</script>
<svelte:head>

View File

@ -1,30 +1,30 @@
<script>
import Header from '$lib/navigation/header.svelte';
import Nav from '$lib/navigation/nav.svelte';
import InputIsland from '$lib/islands/input-island-form.svelte';
import QuickLinkIsland from '$lib/islands/quick-link-island.svelte';
import Welcome from '$lib/overlays/welcome.svelte';
import { welcome } from '$lib/stores/welcome';
import { version, showWelcome } from '$lib/stores/version';
import Header from "$lib/navigation/header.svelte";
import Nav from "$lib/navigation/nav.svelte";
import InputIsland from "$lib/islands/input-island-form.svelte";
import QuickLinkIsland from "$lib/islands/quick-link-island.svelte";
import Welcome from "$lib/overlays/welcome.svelte";
import { welcome } from "$lib/stores/welcome";
import { version, showWelcome } from "$lib/stores/version";
const title = 'OwlBoard';
const title = "OwlBoard";
const inputIslands = [
{
title: 'Live Departure Boards',
action: '/ldb',
placeholder: 'Enter CRS/TIPLOC',
queryName: 'station'
title: "Live Departure Boards",
action: "/ldb",
placeholder: "Enter CRS/TIPLOC",
queryName: "station"
},
{
title: 'Train Details & PIS',
action: '/train',
placeholder: 'Enter Headcode',
queryName: 'headcode'
title: "Train Details & PIS",
action: "/train",
placeholder: "Enter Headcode",
queryName: "headcode"
}
];
</script>
{#if showWelcome && ($welcome === 'null' || !$welcome || parseInt($welcome.replace(/\./g, '')) < parseInt(version.replace(/\./g, '')))}
{#if showWelcome && ($welcome === "null" || !$welcome || parseInt($welcome.replace(/\./g, "")) < parseInt(version.replace(/\./g, "")))}
<Welcome />
{/if}
<Header {title} />

View File

@ -1,8 +1,8 @@
<script lang="ts">
import Header from '$lib/navigation/header.svelte';
import Nav from '$lib/navigation/nav.svelte';
import Header from "$lib/navigation/header.svelte";
import Nav from "$lib/navigation/nav.svelte";
const title = '404 - Not Found';
const title = "404 - Not Found";
</script>
<Header {title} />

View File

@ -1,8 +1,8 @@
<script lang="ts">
import Header from '$lib/navigation/header.svelte';
import Nav from '$lib/navigation/nav.svelte';
import Header from "$lib/navigation/header.svelte";
import Nav from "$lib/navigation/nav.svelte";
const title = '50x - Server Error';
const title = "50x - Server Error";
</script>
<Header {title} />

View File

@ -1,30 +1,30 @@
<script>
import Header from '$lib/navigation/header.svelte';
import Nav from '$lib/navigation/nav-ldb.svelte';
import PublicLdb from '$lib/ldb/public-ldb.svelte';
import StaffLdb from '$lib/ldb/staff/staff-ldb.svelte';
import { uuid } from '$lib/stores/uuid.js';
import { onMount } from 'svelte';
import Header from "$lib/navigation/header.svelte";
import Nav from "$lib/navigation/nav-ldb.svelte";
import PublicLdb from "$lib/ldb/public-ldb.svelte";
import StaffLdb from "$lib/ldb/staff/staff-ldb.svelte";
import { uuid } from "$lib/stores/uuid.js";
import { onMount } from "svelte";
let title = 'Loading';
let title = "Loading";
async function getHeadcode() {
return new URLSearchParams(window.location.search).get('station');
return new URLSearchParams(window.location.search).get("station");
}
let station = '';
let station = "";
let staff = false;
let uuidValue = '';
let uuidValue = "";
$: uuidValue = $uuid;
onMount(async () => {
station = (await getHeadcode()) || '';
if (uuidValue !== null && uuidValue !== '' && uuidValue !== 'null') {
station = (await getHeadcode()) || "";
if (uuidValue !== null && uuidValue !== "" && uuidValue !== "null") {
staff = true;
title = 'Staff Board';
title = "Staff Board";
} else {
title = 'Public Board';
title = "Public Board";
}
});
</script>

View File

@ -1,20 +1,32 @@
<script>
import Header from '$lib/navigation/header.svelte';
import Nav from '$lib/navigation/nav.svelte';
import { IconCode, IconHelp, IconInfoCircle, IconLocation, IconMessageCode, IconNumber, IconSettings, IconSpy, IconUser, IconUserPlus, IconVersions } from '@tabler/icons-svelte';
const title = 'More';
import Header from "$lib/navigation/header.svelte";
import Nav from "$lib/navigation/nav.svelte";
import {
IconCode,
IconHelp,
IconInfoCircle,
IconLocation,
IconMessageCode,
IconNumber,
IconSettings,
IconSpy,
IconUser,
IconUserPlus,
IconVersions
} from "@tabler/icons-svelte";
const title = "More";
const links = [
{ title: 'Your Data', path: '/more/data', icon: IconUser },
{ title: 'Registration', path: '/more/reg', icon: IconUserPlus },
{ title: 'Settings', path: '/more/settings', icon: IconSettings },
{ title: 'Help', path: '/more/help', icon: IconHelp },
{ title: 'About', path: '/more/about', icon: IconInfoCircle },
{ title: 'Location Reference Code Lookup', path: '/more/corpus', icon: IconLocation },
{ title: 'Reason Code Lookup', path: '/more/reasons', icon: IconMessageCode },
{ title: 'Privacy Policy', path: '/more/privacy', icon: IconSpy },
{ title: 'Component Versions', path: '/more/versions', icon: IconVersions },
{ title: 'Statistics', path: '/more/statistics', icon: IconNumber }
{ title: "Your Data", path: "/more/data", icon: IconUser },
{ title: "Registration", path: "/more/reg", icon: IconUserPlus },
{ title: "Settings", path: "/more/settings", icon: IconSettings },
{ title: "Help", path: "/more/help", icon: IconHelp },
{ title: "About", path: "/more/about", icon: IconInfoCircle },
{ title: "Location Reference Code Lookup", path: "/more/corpus", icon: IconLocation },
{ title: "Reason Code Lookup", path: "/more/reasons", icon: IconMessageCode },
{ title: "Privacy Policy", path: "/more/privacy", icon: IconSpy },
{ title: "Component Versions", path: "/more/versions", icon: IconVersions },
{ title: "Statistics", path: "/more/statistics", icon: IconNumber }
];
</script>

View File

@ -1,9 +1,9 @@
<script>
import LargeLogo from '$lib/images/large-logo.svelte';
import Header from '$lib/navigation/header.svelte';
import Nav from '$lib/navigation/nav.svelte';
import LargeLogo from "$lib/images/large-logo.svelte";
import Header from "$lib/navigation/header.svelte";
import Nav from "$lib/navigation/nav.svelte";
const title = 'About';
const title = "About";
</script>
<Header {title} />

View File

@ -1,22 +1,22 @@
<script>
import Header from '$lib/navigation/header.svelte';
import Loading from '$lib/navigation/loading.svelte';
import Nav from '$lib/navigation/nav.svelte';
import { getApiUrl } from '$lib/scripts/upstream';
const title = 'Location Codes';
import Header from "$lib/navigation/header.svelte";
import Loading from "$lib/navigation/loading.svelte";
import Nav from "$lib/navigation/nav.svelte";
import { getApiUrl } from "$lib/scripts/upstream";
const title = "Location Codes";
let val = {
crs: '',
tiploc: '',
stanox: '',
nlc: '',
name: '',
uic: ''
crs: "",
tiploc: "",
stanox: "",
nlc: "",
name: "",
uic: ""
};
let isLoading = false;
async function getData(type = '', value = '') {
async function getData(type = "", value = "") {
const url = `${getApiUrl()}/api/v2/ref/locationCode/${type}/${value}`;
const res = await fetch(url);
const data = await res.json();
@ -26,16 +26,16 @@
async function processData(data) {
//console.log("data",JSON.stringify(data))
if (data.ERROR == 'Offline') {
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'
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));
}
@ -44,13 +44,13 @@
isLoading = true;
let data = [];
if (val?.crs) {
data = await getData('crs', val.crs);
data = await getData("crs", val.crs);
} else if (val?.tiploc) {
data = await getData('tiploc', val.tiploc);
data = await getData("tiploc", val.tiploc);
} else if (val?.stanox) {
data = await getData('stanox', val.stanox);
data = await getData("stanox", val.stanox);
} else if (val?.nlc) {
data = await getData('nlc', val.nlc);
data = await getData("nlc", val.nlc);
} else {
return;
}
@ -59,12 +59,12 @@
async function reset() {
val = {
crs: '',
tiploc: '',
stanox: '',
nlc: '',
name: '',
uic: ''
crs: "",
tiploc: "",
stanox: "",
nlc: "",
name: "",
uic: ""
};
}
</script>

View File

@ -1,24 +1,24 @@
<script>
import LogoutButton from '$lib/navigation/LogoutButton.svelte';
import Header from '$lib/navigation/header.svelte';
import Loading from '$lib/navigation/loading.svelte';
import Nav from '$lib/navigation/nav.svelte';
import { getApiUrl } from '$lib/scripts/upstream';
import { uuid } from '$lib/stores/uuid.js';
import { onMount } from 'svelte';
const title = 'Your Data';
import LogoutButton from "$lib/navigation/LogoutButton.svelte";
import Header from "$lib/navigation/header.svelte";
import Loading from "$lib/navigation/loading.svelte";
import Nav from "$lib/navigation/nav.svelte";
import { getApiUrl } from "$lib/scripts/upstream";
import { uuid } from "$lib/stores/uuid.js";
import { onMount } from "svelte";
const title = "Your Data";
let data = [
{
domain: 'User not Found',
atime: 'User not Found'
domain: "User not Found",
atime: "User not Found"
}
];
let isLoading = false;
async function fetchData() {
if ($uuid != 'null') {
if ($uuid != "null") {
const url = `${getApiUrl()}/api/v2/user/${$uuid}`;
const res = await fetch(url);
const json = await res.json();
@ -44,13 +44,13 @@
{#if isLoading}
<Loading />
{:else if data[0].domain != 'User not Found'}
<p class="api_response">Registration Domain: {data[0]['domain']}</p>
<p class="api_response">Access Time: {data[0]['atime']}</p>
{:else if data[0].domain != "User not Found"}
<p class="api_response">Registration Domain: {data[0]["domain"]}</p>
<p class="api_response">Access Time: {data[0]["atime"]}</p>
<LogoutButton />
<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 90
days.
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 days.
</p>
{:else}
<p class="api_response">You are not registered, we don't have any data stored.</p>

View File

@ -1,9 +1,9 @@
<script>
import Header from '$lib/navigation/header.svelte';
import Nav from '$lib/navigation/nav.svelte';
import Header from "$lib/navigation/header.svelte";
import Nav from "$lib/navigation/nav.svelte";
</script>
<Header title={'Help'} />
<Header title={"Help"} />
<Nav />
<br /><br />
<p>

View File

@ -1,25 +1,25 @@
<script>
import Header from '$lib/navigation/header.svelte';
import Nav from '$lib/navigation/nav.svelte';
const title = 'Privacy Policy';
import Header from "$lib/navigation/header.svelte";
import Nav from "$lib/navigation/nav.svelte";
const title = "Privacy Policy";
</script>
<Header {title} />
<div>
<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 data
that we store, please visit <a href="/more/data">My Data</a>.
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 that we store, please visit <a href="/more/data">My Data</a>.
</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>
<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 leave
your device.
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 your device.
</p>
<h2>If You Sign Up</h2>
<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 personal
settings are stored locally in your browser and do not leave your device.
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 settings are stored locally in your browser and do not leave your device.
</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

View File

@ -1,17 +1,17 @@
<script>
import { onMount } from 'svelte';
import Header from '$lib/navigation/header.svelte';
import Nav from '$lib/navigation/nav.svelte';
import Loading from '$lib/navigation/loading.svelte';
import ResultIsland from '$lib/islands/result-island.svelte';
import { getApiUrl } from '$lib/scripts/upstream';
import { onMount } from "svelte";
import Header from "$lib/navigation/header.svelte";
import Nav from "$lib/navigation/nav.svelte";
import Loading from "$lib/navigation/loading.svelte";
import ResultIsland from "$lib/islands/result-island.svelte";
import { getApiUrl } from "$lib/scripts/upstream";
const title = 'Reason Codes';
const title = "Reason Codes";
let isLoading = false;
let inputValue = '';
let inputValue = "";
let resultObject = {
results: false,
title: '',
title: "",
resultLines: []
};
@ -37,12 +37,12 @@
async function handleData(data) {
let resultLines = [];
if (data.length) {
resultObject.title = data[0]['code'];
resultLines = [data[0]['lateReason'], data[0]['cancReason']];
resultObject.title = data[0]["code"];
resultLines = [data[0]["lateReason"], data[0]["cancReason"]];
} else {
resultObject = {
results: false,
title: 'Not Found',
title: "Not Found",
resultLines: []
};
}
@ -98,7 +98,7 @@
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;
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);
@ -111,7 +111,7 @@
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-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-bg-color);

View File

@ -1,17 +1,17 @@
<script lang="ts">
import Header from '$lib/navigation/header.svelte';
import Nav from '$lib/navigation/nav.svelte';
import Loading from '$lib/navigation/loading.svelte';
import { onMount } from 'svelte';
import { checkAuth } from '$lib/libauth';
import LogoutButton from '$lib/navigation/LogoutButton.svelte';
import { getApiUrl } from '$lib/scripts/upstream';
import Header from "$lib/navigation/header.svelte";
import Nav from "$lib/navigation/nav.svelte";
import Loading from "$lib/navigation/loading.svelte";
import { onMount } from "svelte";
import { checkAuth } from "$lib/libauth";
import LogoutButton from "$lib/navigation/LogoutButton.svelte";
import { getApiUrl } from "$lib/scripts/upstream";
const title = 'Register';
const title = "Register";
let state = 'unreg';
let state = "unreg";
let isLoading = true;
let inputValue = '';
let inputValue = "";
function handleInput(event: KeyboardEvent) {
inputValue = event?.target?.value;
@ -21,9 +21,9 @@
isLoading = true;
const url = `${getApiUrl()}/api/v2/user/request`;
const request = {
method: 'POST',
method: "POST",
headers: {
'Content-Type': 'application/json'
"Content-Type": "application/json"
},
body: JSON.stringify({
email: inputValue
@ -31,11 +31,11 @@
};
const res = await fetch(url, request);
if (res.status == 400 || res.status == 403) {
state = 'unauth';
state = "unauth";
} else if (res.status == 201) {
state = 'sent';
state = "sent";
} else {
state = 'error';
state = "error";
}
isLoading = false;
}
@ -43,9 +43,9 @@
onMount(async () => {
const auth = await checkAuth();
if (auth.uuidPresent === false) {
state = 'unreg';
state = "unreg";
} else if (auth.uuidPresent === true) {
state = 'reg';
state = "reg";
}
isLoading = false;
});
@ -56,7 +56,7 @@
<section class="content">
{#if isLoading}
<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 class="bold">Already have a registration code? <a href="/more/reg/submit">enter it here</a></p>
<form on:submit={request}>
@ -75,21 +75,21 @@
<li>Non-Public trains on departure boards</li>
<li>Hidden platform numbers on departure boards</li>
<li>See up to the next 40 trains departing a station over the next two hours</li>
{:else if state == 'sent'}
{:else if state == "sent"}
<p>An email has been sent, enter the code in the email to activate your profile.</p>
<p class="bold"><a href="/more/reg/submit">Ready to enter your code?</a></p>
<p>If you use multiple browsers, you will only be logged in using the browser you open the link with.</p>
<p>You will be able to register again using the same email address</p>
{:else if state == 'unauth'}
{:else if state == "unauth"}
<p>The email address you entered does not belong to an authorised business.</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 == 'error'}
{:else if state == "error"}
<p>There was an error processing your request.</p>
<p>Check that the email you entered was correct or try again later.</p>
{:else if state == 'reg'}
{:else if state == "reg"}
<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
browser.
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 browser.
</p>
<LogoutButton />
{/if}
@ -121,7 +121,7 @@
height: 40px;
width: 80%;
max-width: 375px;
font-family: urwgothic, 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
font-family: urwgothic, "Franklin Gothic Medium", "Arial Narrow", Arial, sans-serif;
text-align: center;
font-size: 20px;
border-radius: 50px;

View File

@ -1,24 +1,24 @@
<script lang="ts">
import Header from '$lib/navigation/header.svelte';
import Nav from '$lib/navigation/nav.svelte';
import { getApiUrl } from '$lib/scripts/upstream';
import { uuid } from '$lib/stores/uuid';
import Header from "$lib/navigation/header.svelte";
import Nav from "$lib/navigation/nav.svelte";
import { getApiUrl } from "$lib/scripts/upstream";
import { uuid } from "$lib/stores/uuid";
const title = 'Submit Registration';
const title = "Submit Registration";
let state = false;
let status: string;
let inputs: { id: string; value: string }[] = [
{ id: '1', value: '' },
{ id: '2', value: '' },
{ id: '3', value: '' },
{ id: '4', value: '' },
{ id: '5', value: '' },
{ id: '6', value: '' }
{ id: "1", value: "" },
{ id: "2", value: "" },
{ id: "3", value: "" },
{ id: "4", value: "" },
{ id: "5", value: "" },
{ id: "6", value: "" }
];
function handleInput(index: number, event: KeyboardEvent): void {
if (event.key === 'Backspace' && index > 0 && inputs[index].value === '') {
if (event.key === "Backspace" && index > 0 && inputs[index].value === "") {
const prevInput = document.getElementById(`input-${index}`);
if (prevInput) {
prevInput.focus();
@ -32,7 +32,7 @@
}
async function handleSubmit() {
let submitString: string = '';
let submitString: string = "";
for (const input of inputs) {
submitString += input.value.toUpperCase();
}
@ -40,11 +40,11 @@
const res = await submit(submitString);
console.log(`Registration Status: ${res}`);
if (res == 201) {
status = 'okay';
status = "okay";
} else if (res == 401) {
status = 'fail';
status = "fail";
} else {
console.error('Unable to register: ', status);
console.error("Unable to register: ", status);
}
state = true;
}
@ -52,9 +52,9 @@
async function submit(id: string): Promise<number> {
const url = `${getApiUrl()}/api/v2/user/register`;
const request = {
method: 'POST',
method: "POST",
headers: {
'Content-Type': 'application/json'
"Content-Type": "application/json"
},
body: JSON.stringify({
uuid: id
@ -74,11 +74,11 @@
<Header {title} />
{#if state}
{#if status == 'okay'}
{#if status == "okay"}
<p class="title-ish">You are now registered</p>
<p>Your secret key will be stored in your browser.</p>
<p>If you change browsers, change device or clear your browsing data, you may have to register again.</p>
{:else if status == 'fail'}
{:else if status == "fail"}
<p class="title-ish">Your code was not accepted</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>
{/if}

View File

@ -1,20 +1,20 @@
<script>
import Header from '$lib/navigation/header.svelte';
import Island from '$lib/islands/island.svelte';
import Nav from '$lib/navigation/nav.svelte';
import { onMount } from 'svelte';
import Loading from '$lib/navigation/loading.svelte';
import Done from '$lib/navigation/done.svelte';
import { getApiUrl } from '$lib/scripts/upstream';
import Header from "$lib/navigation/header.svelte";
import Island from "$lib/islands/island.svelte";
import Nav from "$lib/navigation/nav.svelte";
import { onMount } from "svelte";
import Loading from "$lib/navigation/loading.svelte";
import Done from "$lib/navigation/done.svelte";
import { getApiUrl } from "$lib/scripts/upstream";
const title = 'Report Issue';
const title = "Report Issue";
let isLoading = false;
let isDone = false;
let isError = false;
let reportType = '',
reportSubject = '',
reportMsg = '',
let reportType = "",
reportSubject = "",
reportMsg = "",
reportCollected;
onMount(async () => {
reportCollected = {
@ -34,7 +34,7 @@
}
async function send() {
console.log('SEND DATA REQUESTED');
console.log("SEND DATA REQUESTED");
isLoading = true;
const formData = JSON.stringify({
label: reportType,
@ -50,9 +50,9 @@
});
const url = `${getApiUrl()}/misc/issue`;
const options = {
method: 'POST',
method: "POST",
headers: {
'Content-Type': 'application/json'
"Content-Type": "application/json"
},
body: formData
};
@ -61,7 +61,7 @@
isLoading = false;
isDone = true;
await new Promise((r) => setTimeout(r, 2000));
window.location.href = '/';
window.location.href = "/";
} else {
isLoading = false;
isError = true;

View File

@ -1,8 +1,8 @@
<script>
import Header from '$lib/navigation/header.svelte';
import Nav from '$lib/navigation/nav.svelte';
import QlSet from '$lib/islands/quick-link-set-island.svelte';
const title = 'Settings';
import Header from "$lib/navigation/header.svelte";
import Nav from "$lib/navigation/nav.svelte";
import QlSet from "$lib/islands/quick-link-set-island.svelte";
const title = "Settings";
</script>
<Header {title} />

View File

@ -1,10 +1,10 @@
<script>
import Island from '$lib/islands/island.svelte';
import Header from '$lib/navigation/header.svelte';
import Loading from '$lib/navigation/loading.svelte';
import Nav from '$lib/navigation/nav.svelte';
import { getApiUrl } from '$lib/scripts/upstream';
const title = 'Statistics';
import Island from "$lib/islands/island.svelte";
import Header from "$lib/navigation/header.svelte";
import Loading from "$lib/navigation/loading.svelte";
import Nav from "$lib/navigation/nav.svelte";
import { getApiUrl } from "$lib/scripts/upstream";
const title = "Statistics";
async function getData() {
const url = `${getApiUrl()}/misc/server/stats`;
@ -31,7 +31,7 @@
<br />
<p>API Server:<br /><span>{data?.hostname}</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>
<p>Timetable: <span>{U2L(data?.updateTimes?.timetable)}</span></p>
<p>Location Ref: <span>{U2L(data?.updateTimes?.corpus)}</span></p>

View File

@ -1,14 +1,14 @@
<script>
import Header from '$lib/navigation/header.svelte';
import Island from '$lib/islands/island.svelte';
import Loading from '$lib/navigation/loading.svelte';
import Nav from '$lib/navigation/nav.svelte';
import LargeLogo from '$lib/images/large-logo.svelte';
import { version, versionTag } from '$lib/stores/version';
import { getApiUrl } from '$lib/scripts/upstream';
import { IconBrandGolang, IconBrandJavascript, IconBrandNodejs, IconBrandPython, IconBrandSvelte, IconBrandTypescript, IconFileTypeSql } from '@tabler/icons-svelte';
import Tooltip from '$lib/Tooltip.svelte';
const title = 'Versions';
import Header from "$lib/navigation/header.svelte";
import Island from "$lib/islands/island.svelte";
import Loading from "$lib/navigation/loading.svelte";
import Nav from "$lib/navigation/nav.svelte";
import LargeLogo from "$lib/images/large-logo.svelte";
import { version, versionTag } from "$lib/stores/version";
import { getApiUrl } from "$lib/scripts/upstream";
import { IconBrandGolang, IconBrandJavascript, IconBrandNodejs, IconBrandPython, IconBrandSvelte, IconBrandTypescript, IconFileTypeSql } from "@tabler/icons-svelte";
import Tooltip from "$lib/Tooltip.svelte";
const title = "Versions";
async function getData() {
const url = `${getApiUrl()}/misc/server/versions`;
@ -41,17 +41,19 @@
<Tooltip text="Javascript"><IconBrandJavascript /></Tooltip>
<Tooltip text="Typescript"><IconBrandTypescript /></Tooltip>
<br />
<a class="data" href="https://git.fjla.uk/owlboard/backend" target="_blank">API Server version<br /><span class="data">{data?.backend || 'Unknown'}</span></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>
<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>
<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">MQ Client version<br /><span class="data">{data?.['mq-client'] || 'Not installed'}</span></a>
<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
>
</p>
</Island>
{:catch}

View File

@ -1,20 +1,20 @@
<script>
import Header from '$lib/navigation/header.svelte';
import Nav from '$lib/navigation/nav.svelte';
import Island from '$lib/islands/island.svelte';
import Loading from '$lib/navigation/loading.svelte';
import { uuid } from '$lib/stores/uuid';
import StylesToc from '$lib/train/styles-toc.svelte';
import { getApiUrl } from '$lib/scripts/upstream';
import Header from "$lib/navigation/header.svelte";
import Nav from "$lib/navigation/nav.svelte";
import Island from "$lib/islands/island.svelte";
import Loading from "$lib/navigation/loading.svelte";
import { uuid } from "$lib/stores/uuid";
import StylesToc from "$lib/train/styles-toc.svelte";
import { getApiUrl } from "$lib/scripts/upstream";
const title = 'PIS Finder';
const variables = { title: 'Results' };
let entryPIS = '';
let entryStartCRS = '';
let entryEndCRS = '';
const title = "PIS Finder";
const variables = { title: "Results" };
let entryPIS = "";
let entryStartCRS = "";
let entryEndCRS = "";
let data = [];
let error = false;
let errMsg = 'Unknown Error';
let errMsg = "Unknown Error";
let isLoading = false;
async function findByStartEnd() {
@ -33,24 +33,24 @@
async function fetchData(url) {
const options = {
method: 'GET',
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';
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';
errMsg = "Server Error, try again later";
error = true;
return false;
}
const jsonData = await res.json();
if (jsonData.ERROR == 'offline') {
errMsg = 'Connection error, check your internet connection and try again';
if (jsonData.ERROR == "offline") {
errMsg = "Connection error, check your internet connection and try again";
error = true;
return false;
}
@ -60,9 +60,9 @@
async function reset() {
data = [];
error = false;
entryPIS = '';
entryStartCRS = '';
entryEndCRS = '';
entryPIS = "";
entryStartCRS = "";
entryEndCRS = "";
}
</script>
@ -86,9 +86,9 @@
</tr>
{#each data as item}
<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="stops stops-data">{item.stops.join(' ')}</td>
<td class="stops stops-data">{item.stops.join(" ")}</td>
</tr>
{/each}
</table>

View File

@ -1,52 +1,52 @@
<script lang="ts">
import Header from '$lib/navigation/header.svelte';
import Loading from '$lib/navigation/loading.svelte';
import Island from '$lib/islands/island.svelte';
import Nav from '$lib/navigation/nav.svelte';
import { uuid } from '$lib/stores/uuid';
import Header from "$lib/navigation/header.svelte";
import Loading from "$lib/navigation/loading.svelte";
import Island from "$lib/islands/island.svelte";
import Nav from "$lib/navigation/nav.svelte";
import { uuid } from "$lib/stores/uuid";
import { onMount } from 'svelte';
import TrainDetail from '$lib/train/train-detail.svelte';
import { getApiUrl } from '$lib/scripts/upstream';
import { onMount } from "svelte";
import TrainDetail from "$lib/train/train-detail.svelte";
import { getApiUrl } from "$lib/scripts/upstream";
let title = 'Timetable Results';
let id = '';
let title = "Timetable Results";
let id = "";
let data = [];
let isLoading = true;
let error = false;
let errMsg = '';
let errMsg = "";
$: {
if (id) {
title = id.toUpperCase();
} else {
title = 'Querying Timetable';
title = "Querying Timetable";
}
}
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()) || '';
id = (await getHeadcode()) || "";
const res = await fetchData(id);
if (res) {
data = res;
if (!data.length) {
error = true;
errMsg = 'No services found';
errMsg = "No services found";
}
}
isLoading = false;
});
async function fetchData(id = '') {
const date = 'now';
const searchType = 'headcode';
async function fetchData(id = "") {
const date = "now";
const searchType = "headcode";
const options = {
method: 'GET',
method: "GET",
headers: {
uuid: $uuid
}
@ -58,16 +58,16 @@
return await res.json();
} else if (res.status === 401) {
error = true;
errMsg = 'You must be logged into the staff version for this feature';
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';
errMsg = "Unable to connect, check your connection and try again";
return false;
}
} catch (err) {
error = true;
errMsg = 'Connection error, try again later';
errMsg = "Connection error, try again later";
}
isLoading = false;
}

View File

@ -1,14 +1,14 @@
/// <reference types="@sveltejs/kit" />
import { build, files, version } from '$service-worker';
import { build, files, version } from "$service-worker";
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"];
self.addEventListener('install', (event) => {
self.addEventListener("install", (event) => {
async function addToCache() {
const cache = await caches.open(cacheName);
await cache.addAll(assets);
@ -17,7 +17,7 @@ self.addEventListener('install', (event) => {
event.waitUntil(addToCache());
});
self.addEventListener('activate', (event) => {
self.addEventListener("activate", (event) => {
async function deleteOldCache() {
for (const key of await caches.keys()) {
if (key !== cacheName) {
@ -29,8 +29,8 @@ self.addEventListener('activate', (event) => {
event.waitUntil(deleteOldCache());
});
self.addEventListener('fetch', (event) => {
if (event.request.method !== 'GET') {
self.addEventListener("fetch", (event) => {
if (event.request.method !== "GET") {
return;
}
async function respond() {
@ -42,7 +42,7 @@ self.addEventListener('fetch', (event) => {
try {
return await fetch(event.request);
} catch (err) {
return { error: 'OFFLINE', errorMsg: 'You are offline' };
return { error: "OFFLINE", errorMsg: "You are offline" };
}
}

View File

@ -1,7 +1,7 @@
// Remove the service worker /sw.js from legacy installations
// This should then enable the new /service-worker.js to be installed
self.addEventListener('activate', function (e) {
self.addEventListener("activate", function (e) {
console.log(`Unregistering service worker`);
self.registration
.unregister()

View File

@ -1,12 +1,12 @@
import adapter from '@sveltejs/adapter-static';
import { vitePreprocess } from '@sveltejs/kit/vite';
import adapter from "@sveltejs/adapter-static";
import { vitePreprocess } from "@sveltejs/kit/vite";
const config = {
preprocess: vitePreprocess(),
kit: {
adapter: adapter({
pages: 'build',
assets: 'build',
pages: "build",
assets: "build",
precompress: true,
strict: true
})

View File

@ -1,5 +1,5 @@
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
import { sveltekit } from "@sveltejs/kit/vite";
import { defineConfig } from "vite";
export default defineConfig({
plugins: [sveltekit()]