Prettier formatting

This commit is contained in:
Fred Boniface 2023-07-07 11:27:28 +01:00
parent 039b57efe7
commit 7dc24646b9
49 changed files with 2796 additions and 2419 deletions

View File

@ -1,11 +1,6 @@
module.exports = {
root: true,
extends: ['eslint:recommended', 'plugin:svelte/recommended', 'prettier'],
overrides: [
{
"files": ["**/*.svelte"]
}
],
parserOptions: {
sourceType: 'module',
ecmaVersion: 2020,
@ -17,6 +12,6 @@ module.exports = {
node: true
},
rules: {
indent: ['error', 2, {SwitchCase: 2}],
indent: ['error', 2, { SwitchCase: 2 }]
}
};

View File

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

View File

@ -58,14 +58,17 @@
body {
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(--second-text-color);
font-family: urwgothic, sans-serif;
text-align: center;
padding-bottom: 60px; /*Footer height*/
}
a {
color: var(--link-color)
color: var(--link-color);
}
button:hover {
cursor: pointer;

View File

@ -1,4 +1,4 @@
<img src="/images/logo/wide_logo.svg" alt="Logo">
<img src="/images/logo/wide_logo.svg" alt="Logo" />
<style>
img {

View File

@ -1,17 +1,24 @@
<script>
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>
<Island {variables}>
<form action={variables.action}>
<input class="form-input" type="text" id="input-headcode" name={variables.queryName} placeholder={variables.placeholder} autocomplete="off">
<br>
<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>
@ -25,7 +32,8 @@
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;
}
@ -36,7 +44,8 @@
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(--main-bg-color);

View File

@ -1,5 +1,5 @@
<script>
export let variables = {title:""}
export let variables = { title: '' };
</script>
<div>
@ -9,10 +9,11 @@
<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(--main-text-color)
color: var(--main-text-color);
}
div {
width: 85%;

View File

@ -1,7 +1,7 @@
<script>
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,8 @@
<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(--main-text-color);
font-weight: 600;
font-size: 20px;

View File

@ -1,14 +1,12 @@
<script>
import Island from "$lib/islands/island.svelte";
import { ql } from "$lib/stores/quick-links.js"
import Island from '$lib/islands/island.svelte';
import { ql } from '$lib/stores/quick-links.js';
export let variables = {
title: "Quick Links",
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}
@ -25,7 +23,6 @@
{/if}
{/each}
</div>
</Island>
<style>
@ -46,7 +43,8 @@
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;
@ -54,4 +52,3 @@
color: var(--link-color);
}
</style>

View File

@ -1,54 +1,54 @@
<script>
import Island from "$lib/islands/island.svelte";
import { ql } from "$lib/stores/quick-links.js";
import Island from '$lib/islands/island.svelte';
import { ql } from '$lib/stores/quick-links.js';
export let variables = {
title: "Quick Links",
title: 'Quick Links'
};
let qlData =[]
let qlData = [];
$: {
qlData = $ql;
console.log(qlData);
}
let saveButton = "Save"
let saveButton = 'Save';
async function timeout(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
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 = []
let inputLinks = [];
for (let item of inputs) {
let text = item?.value;
if (text !== '') {
inputLinks.push(text);
}
}
console.log(inputLinks)
ql.set(inputLinks)
saveButton = "&#10004;"
console.log(inputLinks);
ql.set(inputLinks);
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) {
// 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>
@ -60,7 +60,7 @@
<div id="buttons" class="buttons">
<p>Quick links can be CRS Codes or Headcodes</p>
{#each qlData as link}
<input class="qlInput" type="text" value={link}>
<input class="qlInput" type="text" value={link} />
{/each}
<button on:click={addQlBox} id="qlAdd">+</button>
</div>
@ -68,7 +68,6 @@
<button on:click={clearQl}>Clear</button>
</Island>
<style>
p {
margin-bottom: 0;
@ -93,7 +92,8 @@
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,8 @@
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(--main-bg-color);

View File

@ -1,23 +1,20 @@
<script>
import Island from "$lib/islands/island.svelte";
import Island from '$lib/islands/island.svelte';
export let resultObject = {
results: true,
title: "",
title: '',
resultLines: []
};
let variables = {
title: resultObject.title
}
};
</script>
<Island {variables}>
{#each resultObject.resultLines as line}
<p>{line}</p>
{/each}
</Island>
<style>

View File

@ -1,5 +1,5 @@
<script>
import { fly } from "svelte/transition";
import { fly } from 'svelte/transition';
export let alerts = [];
$: uniqueAlerts = [...new Set(alerts)];
@ -7,11 +7,21 @@
let displayAlerts = false;
async function alertsToggle() {
displayAlerts = !displayAlerts
displayAlerts = !displayAlerts;
}
function numberAsWord(number) {
const words = ['zero', 'one', 'two','three','four','five','six','seven','eight'];
const words = [
'zero',
'one',
'two',
'three',
'four',
'five',
'six',
'seven',
'eight'
];
let word = words[number];
if (word) {
return word;
@ -22,18 +32,24 @@
<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="">
<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>
<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 }}>
<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}

View File

@ -1,7 +1,7 @@
<script>
export let station = "";
export let title = "Loading...";
import { onMount } from 'svelte'
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 './alert-bar.svelte';
@ -43,9 +43,9 @@
}
if (jsonData?.GetStationBoardResult?.locationName) {
title = jsonData.GetStationBoardResult.locationName
title = jsonData.GetStationBoardResult.locationName;
} else {
title = requestedStation.toUpperCase()
title = requestedStation.toUpperCase();
}
}
@ -54,62 +54,64 @@
isLoading = true; // Set loading state
try {
console.log(`Requested Station: ${requestedStation}`);
const data = await fetch(`https://owlboard.info/api/v1/ldb/${requestedStation}`);
const data = await fetch(
`https://owlboard.info/api/v1/ldb/${requestedStation}`
);
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
}
prepareNrcc()
prepareNrcc();
}
function parseTime(string) {
let output
let change
let output;
let change;
switch (string) {
case 'Delayed':
output = 'LATE'
change = "changed"
break
output = 'LATE';
change = 'changed';
break;
case 'Cancelled':
output = 'CANC'
change = "cancelled"
break
output = 'CANC';
change = 'cancelled';
break;
case 'On Time':
case 'On time':
output = 'RT'
change = ""
break
output = 'RT';
change = '';
break;
case '':
output = '-'
change = ""
break
output = '-';
change = '';
break;
case undefined:
output = '-'
change = ""
break
output = '-';
change = '';
break;
case 'No report':
output = '-'
change = ""
break
output = '-';
change = '';
break;
case 'undefined':
output = false
change = ""
break
output = false;
change = '';
break;
default:
output = string
change = "changed"
output = string;
change = 'changed';
}
return {data: output, changed: change}
return { data: output, changed: change };
}
async function loadService(sid) {
for (const service of services) {
if (service.serviceID == sid) {
serviceDetail = service
serviceDetail = service;
}
}
}
@ -117,7 +119,7 @@
async function loadBusService(sid) {
for (const service of busServices) {
if (service.serviceID == sid) {
serviceDetail = service
serviceDetail = service;
}
}
}
@ -130,7 +132,7 @@
if (jsonData?.GetStationBoardResult?.nrccMessages?.message) {
const nrcc = jsonData.GetStationBoardResult.nrccMessages.message;
if (Array.isArray(nrcc)) {
alerts = nrcc
alerts = nrcc;
return;
}
alerts.push(nrcc);
@ -151,8 +153,7 @@
{#if isLoading}
<Loading />
{:else}
{#if dataAge}
{:else if dataAge}
<p id="timestamp">Updated: {dataAge.toLocaleTimeString()}</p>
{#if services.length}
<table class="ldbTable">
@ -167,19 +168,27 @@
</tr>
{#each services as service}
<tr>
<td class="origdest from" on:click={loadService(service.serviceID)} on:keypress={loadService(service.serviceID)}>
<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']}
{:else}
{service.origin?.location?.locationName || ''}
{/if}
</td>
<td class="origdest to" on:click={loadService(service.serviceID)} on:keypress={loadService(service.serviceID)}>
<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']}
{:else}
{service.destination?.location?.locationName || ''}
@ -187,12 +196,17 @@
</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.eta).changed}"
>{parseTime(service.eta).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><td colspan="7">
<tr
><td colspan="7">
<p class="service-detail">
A {service.operator || 'Unknown'} service
{#if service['length']}
@ -205,15 +219,20 @@
{#if service.cancelReason}
<p class="service-detail">{service.cancelReason}</p>
{/if}
</td></tr>
</td></tr
>
{/each}
</table>
{:else}
<p class="table-head-text">No Scheduled Train Services</p>
{/if}
{#if busServices.length}
<br>
<img class="transport-mode" src="/images/transport-modes/bus.svg" alt="Bus services"><br>
<br />
<img
class="transport-mode"
src="/images/transport-modes/bus.svg"
alt="Bus services"
/><br />
<span class="table-head-text">Bus Services</span>
<table class="ldbTable">
<tr>
@ -226,15 +245,30 @@
</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 to" on:click={loadBusService(service.serviceID)} on:keypress={loadBusService(service.serviceID)}>{service.destination?.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
>
<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.etd).changed}">{parseTime(service.etd).data}</td>
<td class="time {parseTime(service.etd).changed}"
>{parseTime(service.etd).data}</td
>
</tr>
<tr><td colspan="7">
<tr
><td colspan="7">
<p class="service-detail">
A {service.operator || 'Unknown'} service
</p>
@ -244,13 +278,18 @@
{#if service.cancelReason}
<p class="service-detail">{service.cancelReason}</p>
{/if}
</td></tr>
</td></tr
>
{/each}
</table>
{/if}
{#if ferryServices.length}
<br>
<img class="transport-mode" src="/images/transport-modes/ferry.svg" alt="Bus services"><br>
<br />
<img
class="transport-mode"
src="/images/transport-modes/ferry.svg"
alt="Bus services"
/><br />
<span class="table-head-text">Ferry Services</span>
<table class="ldbTable">
<tr>
@ -263,29 +302,38 @@
</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.eta).changed}"
>{parseTime(service.eta).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><td colspan="7">
<tr
><td colspan="7">
{#if service.delayReason}
<p class="service-detail">{service.delayReason}</p>
{/if}
{#if service.cancelReason}
<p class="service-detail">{service.cancelReason}</p>
{/if}
</td></tr>
</td></tr
>
{/each}
</table>
{/if}
{:else}
<p>Unable to find this station</p>
{/if}
{/if}
{#if serviceDetail}
<OverlayIsland>
@ -304,21 +352,47 @@
<tr>
<td>{prevPoint.locationName}</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>
{/each}
{:else}
<tr>
<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>
<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
>
</tr>
{/if}
{/if}
<tr class="thisStop">
<td>{title}</td>
<td>{serviceDetail.std || serviceDetail.sta}</td>
<td class="time {parseTime(serviceDetail.etd || serviceDetail.eta).changed}">{parseTime(serviceDetail.etd || serviceDetail.eta).data}</td>
<td
class="time {parseTime(serviceDetail.etd || serviceDetail.eta)
.changed}"
>{parseTime(serviceDetail.etd || serviceDetail.eta).data}</td
>
</tr>
{#if serviceDetail?.subsequentCallingPoints?.callingPointList?.callingPoint}
{#if Array.isArray(serviceDetail?.subsequentCallingPoints?.callingPointList?.callingPoint)}
@ -326,14 +400,31 @@
<tr>
<td>{nextPoint.locationName}</td>
<td>{nextPoint.st}</td>
<td class="time {parseTime(nextPoint.et).changed}">{parseTime(nextPoint.et).data}</td>
<td class="time {parseTime(nextPoint.et).changed}"
>{parseTime(nextPoint.et).data}</td
>
</tr>
{/each}
{:else}
<tr class="detailRow">
<td>{serviceDetail.subsequentCallingPoints.callingPointList.callingPoint.locationName}</td>
<td>{serviceDetail.subsequentCallingPoints.callingPointList.callingPoint.st}</td>
<td class="time {parseTime(serviceDetail.subsequentCallingPoints.callingPointList.callingPoint.et).changed}">{parseTime(serviceDetail.subsequentCallingPoints.callingPointList.callingPoint.et).data}</td>
<td
>{serviceDetail.subsequentCallingPoints.callingPointList
.callingPoint.locationName}</td
>
<td
>{serviceDetail.subsequentCallingPoints.callingPointList
.callingPoint.st}</td
>
<td
class="time {parseTime(
serviceDetail.subsequentCallingPoints.callingPointList
.callingPoint.et
).changed}"
>{parseTime(
serviceDetail.subsequentCallingPoints.callingPointList
.callingPoint.et
).data}</td
>
</tr>
{/if}
{/if}
@ -372,19 +463,38 @@
font-size: 14px;
}
@media (min-width: 800px) {
table {font-size: 15px; max-width: 850px;}
.service-detail {font-size: 14px;}
.transport-mode {width: 50px;}
#timestamp {font-size: 16px;}
table {
font-size: 15px;
max-width: 850px;
}
.service-detail {
font-size: 14px;
}
.transport-mode {
width: 50px;
}
#timestamp {
font-size: 16px;
}
}
@media (min-width: 1000px) {
table {font-size: 17px;}
.service-detail{font-size: 16px;}
.table-head-text {font-size: 16px;}
table {
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;}
table {
font-size: 19px;
}
.service-detail {
font-size: 18px;
}
}
.origdest {
color: yellow;
@ -398,7 +508,7 @@
text-align: left;
}
.plat {
width: 10%
width: 10%;
}
.time {
width: 10%;

View File

@ -1,7 +1,7 @@
<script>
export let station = "";
export let title = "Loading...";
import { onMount } from 'svelte'
export let station = '';
export let title = 'Loading...';
import { onMount } from 'svelte';
import AlertBar from './alert-bar.svelte';
import StaffTrainDetail from '$lib/ldb/staff-train-detail.svelte';
import Loading from '$lib/navigation/loading.svelte';
@ -29,13 +29,13 @@
}
if (jsonData?.GetBoardResult?.locationName) {
title = jsonData.GetBoardResult.locationName
title = jsonData.GetBoardResult.locationName;
} else {
title = "Loading Board"
title = 'Loading Board';
}
if (jsonData?.GetBoardResult?.nrccMessages) {
alerts = processNrcc(jsonData.GetBoardResult?.nrccMessages?.message)
alerts = processNrcc(jsonData.GetBoardResult?.nrccMessages?.message);
}
}
@ -45,25 +45,25 @@
console.log(`Requested Station: ${requestedStation}`);
const url = `https://owlboard.info/api/v2/live/station/${requestedStation}/staff`;
const opt = {
method: "GET",
method: 'GET',
headers: {
"uuid": $uuid
}
uuid: $uuid
}
};
const data = await fetch(url, opt);
jsonData = await data.json();
} catch (error) {
console.error("Error fetching data:", error);
console.error('Error fetching data:', error);
} finally {
isLoading = false; // Clear loading state
}
}
async function getReasonCodeData(code) {
const url = `https://owlboard.info/api/v2/ref/reasonCode/${code}`
const url = `https://owlboard.info/api/v2/ref/reasonCode/${code}`;
const res = await fetch(url);
const json = await res.json();
return json
return json;
}
async function generateServiceData(service) {
@ -72,8 +72,8 @@
from: await parseLocation(service.origin),
to: await parseLocation(service.destination),
length: await getTrainLength(service),
platform: await parsePlatform(service?.platform || "undefined"),
platformHidden: service?.platformIsHidden === "true",
platform: await parsePlatform(service?.platform || 'undefined'),
platformHidden: service?.platformIsHidden === 'true',
schArr: timeDetails.schArr,
expArr: timeDetails.expArr,
schDep: timeDetails.schDep,
@ -84,12 +84,12 @@
isLateDep: timeDetails.delDep,
isCancelledDep: false,
isCancelled: Boolean(service?.isCancelled),
isDelayed: service?.arrivalType === "Delayed",
isArrDelayed: service?.arrivalType === "Delayed",
isDepDelayed: service?.departureType === "Delayed",
isDelayed: service?.arrivalType === 'Delayed',
isArrDelayed: service?.arrivalType === 'Delayed',
isDepDelayed: service?.departureType === 'Delayed',
isEarly: false,
isNonPublic: false
}
};
return serviceData;
}
@ -97,7 +97,7 @@
if (service?.length) {
return parseInt(service?.length);
} else if (service?.formation?.coaches) {
return service.formation.coaches.coach.length
return service.formation.coaches.coach.length;
}
return null;
}
@ -105,25 +105,25 @@
async function parseLocation(location) {
if (!Array.isArray(location.location)) {
//console.log(location.location?.tiploc)
return location.location?.tiploc
return location.location?.tiploc;
}
let locations = [];
for (const singleLocation of location?.location) {
locations.push(singleLocation?.tiploc)
locations.push(singleLocation?.tiploc);
}
return locations.join(' & ');
}
async function parsePlatform(platform) {
if (!platform) {
return '-'
return '-';
}
if (platform === "TBC" || platform == "undefined") {
return '-'
if (platform === 'TBC' || platform == 'undefined') {
return '-';
}
return {
number: platform
}
};
}
function parseTimes(service) {
@ -131,8 +131,12 @@
let expArr = new Date(service?.eta || service?.ata);
let schDep = new Date(service?.std);
let expDep = new Date(service?.etd || service?.atd);
let isEarlyArr = false, isDelayedArr = false, isArr = false
let isEarlyDep = false, isDelayedDep = false, isDep = false
let isEarlyArr = false,
isDelayedArr = false,
isArr = false;
let isEarlyDep = false,
isDelayedDep = false,
isDep = false;
const timeDifferenceThreshold = 60 * 1000; // 60 seconds in milliseconds
if (expArr - schArr < -timeDifferenceThreshold) {
isEarlyArr = true;
@ -179,19 +183,23 @@ if (expDep instanceof Date && !isNaN(expDep)) {
delArr: isDelayedArr,
earDep: isEarlyDep,
delDep: isDelayedDep
}
};
}
function parseIndividualTime(input) {
const dt = new Date(input);
const output = dt.toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'})
if (output !== "Invalid Date") {
return output
const output = dt.toLocaleTimeString([], {
hour: '2-digit',
minute: '2-digit'
});
if (output !== 'Invalid Date') {
return output;
}
return '-'
return '-';
}
function processNrcc(messages) { // Remove newlines and then <p> tags from input and append to array
function processNrcc(messages) {
// Remove newlines and then <p> tags from input and append to array
let arrMessages;
if (!Array.isArray(messages)) {
arrMessages = [messages];
@ -200,8 +208,10 @@ if (expDep instanceof Date && !isNaN(expDep)) {
}
let processedMessages = [];
for (const message of arrMessages) {
const msgText = message.xhtmlMessage
processedMessages.push(msgText.replace(/[\n\r]/g, '').replace(/<\/?p[^>]*>/g, ''));
const msgText = message.xhtmlMessage;
processedMessages.push(
msgText.replace(/[\n\r]/g, '').replace(/<\/?p[^>]*>/g, '')
);
}
return processedMessages;
}
@ -218,7 +228,11 @@ if (expDep instanceof Date && !isNaN(expDep)) {
<AlertBar {alerts} />
{/if}
<table>
<tr><td colspan="8" id="timestamp">Updated: {dataAge.toLocaleTimeString()} - Staff Boards under development</td></tr>
<tr
><td colspan="8" id="timestamp"
>Updated: {dataAge.toLocaleTimeString()} - Staff Boards under development</td
></tr
>
<tr>
<th class="id">ID</th>
<th class="from">From</th>
@ -232,35 +246,58 @@ if (expDep instanceof Date && !isNaN(expDep)) {
{#each services as service}
{#await generateServiceData(service)}
<tr>
<td colspan="8">
Loading...
</td>
<td colspan="8"> Loading... </td>
</tr>
{:then serviceStats}
<!-- Await a 'Generate Stats' function here which can evaluate the data and provide
relevant BOOLs like isCancelled, isEarly, isLate, isNonPassenger and calculate train length
where 'length' is not provided but 'formation' is. -->
<tr>
<td class="id id-data data">{service.trainid}</td>
<td class="from from-data data {serviceStats.isCancelled && 'can-dat'}">{serviceStats.from}</td>
<td class="to to-data data {serviceStats.isCancelled && 'can-dat'}">{serviceStats.to}</td>
<td class="plat plat-data data {serviceStats.isCancelled && 'can-dat'} {serviceStats.platformHidden && 'hidden'}">{serviceStats.platform.number || '-'}</td>
<td class="time time-data data {serviceStats.isCancelled && 'can-dat'}">{serviceStats.schArr}</td>
<td class="time time-data data {serviceStats.isArrDelayed && 'late'} {serviceStats.isEarlyArr && 'early'} {serviceStats.isLateArr && 'late'}">{serviceStats.isArrDelayed ? 'LATE' : serviceStats.expArr}</td>
<td class="time time-data data {serviceStats.isCancelled && 'can-dat'}">{serviceStats.schDep}</td>
<td class="time time-data data {serviceStats.isDepDelayed && 'late'} {serviceStats.isEarlyDep && 'early'} {serviceStats.isLateDep && 'late'}">{serviceStats.isDepDelayed ? 'LATE' : serviceStats.expDep}</td>
<td
class="from from-data data {serviceStats.isCancelled && 'can-dat'}"
>{serviceStats.from}</td
>
<td class="to to-data data {serviceStats.isCancelled && 'can-dat'}"
>{serviceStats.to}</td
>
<td
class="plat plat-data data {serviceStats.isCancelled &&
'can-dat'} {serviceStats.platformHidden && 'hidden'}"
>{serviceStats.platform.number || '-'}</td
>
<td
class="time time-data data {serviceStats.isCancelled && 'can-dat'}"
>{serviceStats.schArr}</td
>
<td
class="time time-data data {serviceStats.isArrDelayed &&
'late'} {serviceStats.isEarlyArr &&
'early'} {serviceStats.isLateArr && 'late'}"
>{serviceStats.isArrDelayed ? 'LATE' : serviceStats.expArr}</td
>
<td
class="time time-data data {serviceStats.isCancelled && 'can-dat'}"
>{serviceStats.schDep}</td
>
<td
class="time time-data data {serviceStats.isDepDelayed &&
'late'} {serviceStats.isEarlyDep &&
'early'} {serviceStats.isLateDep && 'late'}"
>{serviceStats.isDepDelayed ? 'LATE' : serviceStats.expDep}</td
>
</tr>
<tr class="text-row">
<td colspan="8" class="text-data">
{service.operator} {#if serviceStats.length} | {serviceStats.length} carriages{/if}
<br>
{service.operator}
{#if serviceStats.length} | {serviceStats.length} carriages{/if}
<br />
{#if service.isCancelled}
{#await getReasonCodeData(service.cancelReason)}
This train has been cancelled
{:then reasonCode}
{reasonCode[0].cancReason}
<br>
<br />
{/await}
{/if}
{#if service?.delayReason}
@ -268,7 +305,7 @@ if (expDep instanceof Date && !isNaN(expDep)) {
This train has been delayed
{:then reasonCode}
{reasonCode[0].lateReason}
<br>
<br />
{/await}
{/if}
</td>
@ -306,7 +343,8 @@ if (expDep instanceof Date && !isNaN(expDep)) {
text-align: left;
}
.from-data, .to-data {
.from-data,
.to-data {
color: yellow;
text-decoration: none;
text-align: left;

View File

@ -20,7 +20,7 @@
padding: 20px;
padding-bottom: 1px;
min-width: 90px;
max-width:90px
max-width: 90px;
}
p {
padding-top: 0px;

View File

@ -1,12 +1,12 @@
<script>
export let title = 'title'
export let title = 'title';
</script>
<div class="headerBar">
<a href="/">
<picture>
<source srcset="/images/logo/wide_logo.svg" type="image/svg+xml">
<img src="/images/logo/wide_logo_200.png" alt="OwlBoard Logo">
<source srcset="/images/logo/wide_logo.svg" type="image/svg+xml" />
<img src="/images/logo/wide_logo_200.png" alt="OwlBoard Logo" />
</picture>
</a>
<header>{title}</header>
@ -14,12 +14,14 @@
<div class="headerBlock">
<!-- This exists to prevent the headerBar overlapping anything below it -->
</div>
<style>
.headerBar {
background: var(--overlay-color-solid);
color: var(--main-text-color);
position: fixed;
top: 0; left: 0;
top: 0;
left: 0;
width: 100%;
margin: 0;
padding: 0;

View File

@ -1,19 +1,23 @@
<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}}>
<div class="spinner"></div>
<div
id="container"
in:fade={{ delay: 150, duration: 250 }}
out:fade={{ duration: 250 }}
>
<div class="spinner" />
<p>Loading...</p>
</div>
<style>
@keyframes spinner {
0% {
transform:translate3d(-50%,-50%,0) rotate(0)
transform: translate3d(-50%, -50%, 0) rotate(0);
}
100% {
transform:translate3d(-50%,-50%,0) rotate(360deg)
transform: translate3d(-50%, -50%, 0) rotate(360deg);
}
}
.spinner::before {
@ -22,14 +26,14 @@
border: solid 5px var(--overlay-color);
border-bottom-color: white;
border-radius: 50%;
content:"";
content: '';
height: 40px;
width: 40px;
position: absolute;
top: 30%;
margin: auto;
transform: translate3d(-50%, -50%, 0);
will-change:transform
will-change: transform;
}
#container {
position: fixed;
@ -42,7 +46,7 @@
padding: 20px;
padding-bottom: 1px;
min-width: 90px;
max-width:90px
max-width: 90px;
}
p {
padding-top: 50px;

View File

@ -1,28 +1,36 @@
<script>
const links = [
{
title: "Home",
path: "/",
svgPath: "/images/navigation/home.svg"
title: 'Home',
path: '/',
svgPath: '/images/navigation/home.svg'
}
]
import { page } from "$app/stores";
];
import { page } from '$app/stores';
</script>
<footer>
{#each links as item}
<a class="footerLink" href={item.path} class:active={$page.url.pathname == item.path}>
<img src="{item.svgPath}" alt="{item.title}">
<br>
<a
class="footerLink"
href={item.path}
class:active={$page.url.pathname == item.path}
>
<img src={item.svgPath} alt={item.title} />
<br />
<span>{item.title}</span>
</a>
{/each}
<div class="data-source">
<a href="https://nationalrail.co.uk" target="_blank">
<picture>
<source srcset="/images/nre/nre-powered_200w.jxl" type="image/jxl">
<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">
<source srcset="/images/nre/nre-powered_200w.jxl" type="image/jxl" />
<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"
/>
</picture>
</a>
</div>
@ -68,7 +76,11 @@
@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%);
background: linear-gradient(
90deg,
rgba(255, 255, 255, 0) 0%,
rgba(255, 255, 255, 1) 40%
);
}
#nre-logo {
position: absolute;

View File

@ -1,29 +1,29 @@
<script>
const links = [
{
title: "Home",
path: "/",
svgPath: "/images/navigation/home.svg"
title: 'Home',
path: '/',
svgPath: '/images/navigation/home.svg'
},
{
title: "PIS Finder",
path: "/pis",
svgPath: "/images/navigation/info.svg"
title: 'PIS Finder',
path: '/pis',
svgPath: '/images/navigation/info.svg'
},
{
title: "More",
path: "/more",
svgPath: "/images/navigation/more.svg"
title: 'More',
path: '/more',
svgPath: '/images/navigation/more.svg'
}
]
import { page } from "$app/stores";
];
import { page } from '$app/stores';
</script>
<footer>
{#each links as item}
<a href={item.path} class:active={$page.url.pathname == item.path}>
<img src="{item.svgPath}" alt="{item.title}">
<br>
<img src={item.svgPath} alt={item.title} />
<br />
<span>{item.title}</span>
</a>
{/each}

View File

@ -1,36 +1,36 @@
<script>
import OverlayIsland from "$lib/islands/overlay-island.svelte";
import OverlayIsland from '$lib/islands/overlay-island.svelte';
const variables = {
title: "Welcome to OwlBoard"
}
const version = "2023.7.1"
title: 'Welcome to OwlBoard'
};
const version = '2023.7.1';
let pageNum = 0;
function pageUp() {
pageNum++;
console.log(`Welcome page: ${pageNum}`)
console.log(`Welcome page: ${pageNum}`);
}
function pageDn() {
pageNum--;
console.log(`Welcome page: ${pageNum}`)
console.log(`Welcome page: ${pageNum}`);
}
const pageText = [
"<h3>A brand new look</h3>" +
"<p>OwlBoard has a brand new look, making it even faster for you to access the data</p>" +
'<h3>A brand new look</h3>' +
'<p>OwlBoard has a brand new look, making it even faster for you to access the data</p>' +
"<p>If you have signed up before, you won't have to to it again and any customised Quick Links are here waiting for you</p>",
"<h3>Faster Access</h3>" +
"<p>Both live station data, and timetable search is available from the homepage. Making it faster to get the info you need</p>" +
"<p>Search the timetable using a headcode to see a trains details - OwlBoard now shows data for all TOCs and FOCs.</p>" +
'<h3>Faster Access</h3>' +
'<p>Both live station data, and timetable search is available from the homepage. Making it faster to get the info you need</p>' +
'<p>Search the timetable using a headcode to see a trains details - OwlBoard now shows data for all TOCs and FOCs.</p>' +
"<p>For GWR services: if a PIS code is available for a service, you'll see it alongside the train details.</p>",
"<h3>PIS Finder</h3>" +
'<h3>PIS Finder</h3>' +
"<p>Don't worry, the PIS finder hasn't gone away. It has even been moved to the new navigation bar for faster access</p>" +
"<p>If there isn't a PIS code available for a given headcode, you can use this tool to search by start and end stations, enabling you to utilise a different code and skipping stops as needed.</p>",
"<h3>Everything Else</h3>" +
'<h3>Everything Else</h3>' +
"<p>Everything else has moved to the 'More' menu, where you'll find the Reference Code lookup and software details."
]
];
</script>
<OverlayIsland {variables}>

View File

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

View File

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

View File

@ -1,19 +1,24 @@
<script>
import { fly } from "svelte/transition";
import { fly } from 'svelte/transition';
export let service = ""
export let service = '';
let isExpanded = false;
async function expand() {
isExpanded = !isExpanded
isExpanded = !isExpanded;
}
</script>
<div class="container">
<div class="container-header" on:click={expand} on:keypress={expand}>
<span class="header">{service.operator || "GW"}: {service.stops[0]['publicDeparture'] || service.stops[0]['wttDeparture']} {service.stops[0]['tiploc']} to {service.stops[service['stops'].length -1]['tiploc']}</span>
<span class="header"
>{service.operator || 'GW'}: {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>
{#if isExpanded}
@ -21,9 +26,23 @@
{#if service.pis}
<p class="pis">PIS: {service.pis}</p>
{/if}
<p class="svc-detail">Planned Type: {parseInt(service.planSpeed) || 68 }mph {service.powerType || "Bus" }</p>
<p class="svc-detail">Days Run: {service.daysRun.join(", ").toUpperCase()}</p>
<p class="svc-detail validity">Valid From: {new Date(service.scheduleStartDate).toLocaleDateString('en-GB', {timeZone: 'UTC'})} - {new Date(service.scheduleEndDate).toLocaleDateString('en-GB', {timeZone: 'UTC'})}</p>
<p class="svc-detail">
Planned Type: {parseInt(service.planSpeed) || 68}mph {service.powerType ||
'Bus'}
</p>
<p class="svc-detail">
Days Run: {service.daysRun.join(', ').toUpperCase()}
</p>
<p class="svc-detail validity">
Valid From: {new Date(service.scheduleStartDate).toLocaleDateString(
'en-GB',
{
timeZone: 'UTC'
}
)} - {new Date(service.scheduleEndDate).toLocaleDateString('en-GB', {
timeZone: 'UTC'
})}
</p>
<table>
<tr>
<th>Location</th>

View File

@ -2,7 +2,7 @@
import { page } from '$app/stores';
import Header from '$lib/navigation/header.svelte';
import Nav from '$lib/navigation/nav.svelte';
const title = "OwlBoard - Error"
const title = 'OwlBoard - Error';
</script>
<Header {title} />
@ -11,14 +11,21 @@
{#if $page.status === 404}
<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}
<p>Something went wrong loading the app.<br>
Try going <a href="/">home</a> and try again.</p>
<p>
Something went wrong loading the app.<br />
Try going <a href="/">home</a> and try again.
</p>
<p>If the problem persists, you can report an issue from the 'More' menu.</p>
{: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}
<Nav />

View File

@ -1,16 +1,20 @@
<script>
import '../app.css'
import '../app.css';
</script>
<svelte:head>
<meta charset="utf-8">
<meta name="application-name" content="OwlBoard">
<meta name="author" content="Frederick Boniface">
<meta name="description" content="Live train data, PIS Codes & reference data. Built by railway staff, for railway staff.">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#00b7b7">
<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">
<meta charset="utf-8" />
<meta name="application-name" content="OwlBoard" />
<meta name="author" content="Frederick Boniface" />
<meta
name="description"
content="Live train data, PIS Codes & reference data. Built by railway staff, for railway staff."
/>
<meta name="viewport" content="width=device-width" />
<meta name="theme-color" content="#00b7b7" />
<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>
<slot />

View File

@ -1,28 +1,27 @@
<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 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';
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'
}
]
const isWelcomed = "false"; // Usually a bool - <Welcome /> is incomplete so should be hidden for now.
];
const isWelcomed = 'false'; // Usually a bool - <Welcome /> is incomplete so should be hidden for now.
</script>
{#if !isWelcomed}

View File

@ -1,42 +1,41 @@
<script>
import Header from '$lib/navigation/header.svelte'
import Nav from '$lib/navigation/nav-ldb.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-ldb.svelte';
import { uuid } from '$lib/stores/uuid.js';
import {onMount} from 'svelte'
import { onMount } from 'svelte';
let title = "Loading"
let title = 'Loading';
async function getHeadcode() {
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>
<Header {title} />
<!-- If 'uuid' exists in store then load StaffLdb else load PublicLdb -->
{#if !staff}
<PublicLdb {station} bind:title={title} />
<PublicLdb {station} bind:title />
{:else}
<StaffLdb {station} bind:title={title} />
<StaffLdb {station} bind:title />
<!--<StaffLdb {station} bind:title={title} /> -- Temporary, Disable StaffLdb - it isn't implemented -->
{/if}

View File

@ -1,20 +1,20 @@
<script>
import Header from '$lib/navigation/header.svelte'
import Nav from '$lib/navigation/nav.svelte'
const title = "More"
import Header from '$lib/navigation/header.svelte';
import Nav from '$lib/navigation/nav.svelte';
const title = 'More';
const links = [
{title: "Your Data", path: "/more/data"},
{title: "Registration", path: "/more/reg"},
{title: "Location Reference Code Lookup", path: "/more/corpus"},
{title: "Reason Code Lookup", path: "/more/reasons"},
{title: "Privacy Policy", path: "/more/privacy"},
{title: "Component Versions", path: "/more/versions"},
{title: "Statictics", path: "/more/statistics"},
{title: "Settings", path: "/more/settings"},
{title: "Report Issue", path: "/more/report"},
{title: "About", path: "/more/about"}
]
{ title: 'Your Data', path: '/more/data' },
{ title: 'Registration', path: '/more/reg' },
{ title: 'Location Reference Code Lookup', path: '/more/corpus' },
{ title: 'Reason Code Lookup', path: '/more/reasons' },
{ title: 'Privacy Policy', path: '/more/privacy' },
{ title: 'Component Versions', path: '/more/versions' },
{ title: 'Statictics', path: '/more/statistics' },
{ title: 'Settings', path: '/more/settings' },
{ title: 'Report Issue', path: '/more/report' },
{ title: 'About', path: '/more/about' }
];
</script>
<Header {title} />

View File

@ -1,18 +1,24 @@
<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} />
<LargeLogo />
<p class="neg">&copy; 2022-2023 Frederick Boniface</p>
<p>OwlBoard was created by train-crew for train-crew</p>
<p>I created OwlBoard in 2022 to freely give fast and easy access to the information
that we need every day.</p>
<p>Data sourced from: National Rail Enquiries, OwlBoard Project and Network Rail.</p>
<p>OwlBoard components are available under various Open Source licenses, see the
<p>
I created OwlBoard in 2022 to freely give fast and easy access to the
information that we need every day.
</p>
<p>
Data sourced from: National Rail Enquiries, OwlBoard Project and Network Rail.
</p>
<p>
OwlBoard components are available under various Open Source licenses, see the
<a href="https://git.fjla.uk/OwlBoard" target="_blank">code repository</a>
for more information.
</p>

View File

@ -1,22 +1,22 @@
<script>
import Header from '$lib/navigation/header.svelte'
import Header from '$lib/navigation/header.svelte';
import Loading from '$lib/navigation/loading.svelte';
import Nav from '$lib/navigation/nav.svelte'
const title = "Location Codes"
import Nav from '$lib/navigation/nav.svelte';
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 = "") {
const url = `https://owlboard.info/api/v2/ref/locationCode/${type}/${value}`
async function getData(type = '', value = '') {
const url = `https://owlboard.info/api/v2/ref/locationCode/${type}/${value}`;
const res = await fetch(url);
const data = await res.json();
isLoading = false;
@ -25,17 +25,17 @@
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"
}
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));
}
@ -43,13 +43,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;
}
@ -58,15 +58,14 @@
async function reset() {
val = {
crs: "",
tiploc: "",
stanox: "",
nlc: "",
name: "",
uic: "",
crs: '',
tiploc: '',
stanox: '',
nlc: '',
name: '',
uic: ''
};
}
}
</script>
<Header {title} />
@ -81,18 +80,49 @@
<div class="inputs">
<form on:submit={submit}>
<input type="text" readonly placeholder="Name" bind:value={val.name}>
<br>
<input type="text" maxlength="3" autocomplete="off" placeholder="CRS/3ALPHA" bind:value={val.crs}>
<br>
<input type="text" maxlength="7" autocomplete="off" placeholder="TIPLOC" bind:value={val.tiploc}>
<br>
<input type="text" maxlength="10" autocomplete="off" placeholder="STANOX" bind:value={val.stanox}>
<br>
<input type="number" maxlength="6" min="0" autocomplete="off" placeholder="NLC" bind:value={val.nlc}>
<br>
<input type="text" readonly autocomplete="off" placeholder="UIC" bind:value={val.uic}>
<br>
<input type="text" readonly placeholder="Name" bind:value={val.name} />
<br />
<input
type="text"
maxlength="3"
autocomplete="off"
placeholder="CRS/3ALPHA"
bind:value={val.crs}
/>
<br />
<input
type="text"
maxlength="7"
autocomplete="off"
placeholder="TIPLOC"
bind:value={val.tiploc}
/>
<br />
<input
type="text"
maxlength="10"
autocomplete="off"
placeholder="STANOX"
bind:value={val.stanox}
/>
<br />
<input
type="number"
maxlength="6"
min="0"
autocomplete="off"
placeholder="NLC"
bind:value={val.nlc}
/>
<br />
<input
type="text"
readonly
autocomplete="off"
placeholder="UIC"
bind:value={val.uic}
/>
<br />
<button type="submit">Submit</button>
<button type="reset" on:click={reset}>Reset</button>
</form>

View File

@ -4,24 +4,24 @@
import Nav from '$lib/navigation/nav.svelte';
import { uuid } from '$lib/stores/uuid.js';
import { onMount } from 'svelte';
const title = "Your Data";
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") {
const url = `https://owlboard.info/api/v2/user/${$uuid}`
if ($uuid != 'null') {
const url = `https://owlboard.info/api/v2/user/${$uuid}`;
const res = await fetch(url);
const json = await res.json();
if (json.length) {
data = json
data = json;
}
}
}
@ -30,25 +30,33 @@
isLoading = true;
await fetchData();
isLoading = false;
})
});
</script>
<Header {title} />
<p>OwlBoard stores as little data about you as possible to offer the service.</p>
<p>Your randomly generated UUID is not displayed, this is stored in your browser and on the OwlBoard server.</p>
<p>The data below is the entirity of the data we hold about you and constitutes a response to a `Subject Access Request` under GDPR legislation.</p>
<br><br>
<p>
OwlBoard stores as little data about you as possible to offer the service.
</p>
<p>
Your randomly generated UUID is not displayed, this is stored in your browser
and on the OwlBoard server.
</p>
<p>
The data below is the entirity of the data we hold about you and constitutes a
response to a `Subject Access Request` under GDPR legislation.
</p>
<br /><br />
{#if isLoading}
<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">Access Time: {data[0]['atime']}</p>
{:else}
<p class="api_response">You are not registered, we don't have any data stored.</p>
{/if}
<p class="api_response">
You are not registered, we don't have any data stored.
</p>
{/if}
<Nav />

View File

@ -1,24 +1,65 @@
<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>.</p>
<p>OwlBoard does not utilize any cookies. IP addresses and browser fingerprints are not logged.</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 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.</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 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.</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 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.</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>
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 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.
</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>
<h2>Reporting an Issue</h2>
<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>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>
<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>
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>
<Nav />

View File

@ -5,49 +5,45 @@
import Loading from '$lib/navigation/loading.svelte';
import ResultIsland from '$lib/islands/result-island.svelte';
const title = "Reason Codes";
const title = 'Reason Codes';
let isLoading = false;
let inputValue = '';
let resultObject = {
results: false,
title: "",
title: '',
resultLines: []
}
};
function load() {
isLoading = true;
resultObject.results = false;
getData().then(result => {
getData().then((result) => {
handleData(result);
isLoading = false;
});
}
async function getData() {
if (inputValue) {
const url = `https://owlboard.info/api/v2/ref/reasonCode/${inputValue}`;
const res = await fetch(url);
return await res.json();
} else {
return []
return [];
}
}
async function handleData(data) {
let resultLines = []
let resultLines = [];
if (data.length) {
resultObject.title = data[0]['code'];
resultLines = [
data[0]['lateReason'],
data[0]['cancReason']
]
resultLines = [data[0]['lateReason'], data[0]['cancReason']];
} else {
resultObject = {
results: false,
title: "Not Found",
title: 'Not Found',
resultLines: []
}
};
}
resultObject.resultLines = resultLines;
resultObject.results = true;
@ -68,11 +64,20 @@
</script>
<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}>
<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>
</form>
@ -100,7 +105,8 @@
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;
}
@ -112,7 +118,8 @@
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(--overlay-color);

View File

@ -1,15 +1,15 @@
<script>
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 { uuid } from "$lib/stores/uuid.js";
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 { uuid } from '$lib/stores/uuid.js';
const title = "Register";
const title = 'Register';
let state = "unreg";
let state = 'unreg';
let isLoading = false;
let inputValue = "";
let inputValue = '';
function handleInput(event) {
inputValue = event.target.value;
@ -19,31 +19,30 @@
isLoading = true;
const url = 'https://owlboard.info/api/v2/user/request';
const request = {
method: "POST",
method: 'POST',
headers: {
"Content-Type": "application/json"
'Content-Type': 'application/json'
},
body: JSON.stringify({
email: inputValue
})
}
};
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;
}
onMount(async () => {
if ($uuid != "null") {
state = "reg"
if ($uuid != 'null') {
state = 'reg';
}
})
});
</script>
{#if isLoading}
@ -51,7 +50,7 @@
{/if}
<Header {title} />
{#if state == "unreg"}
{#if state == 'unreg'}
<p>The staff version of OwlBoard offers several extra features:</p>
<ul>
<li>Access the Train Finder</li>
@ -63,28 +62,51 @@
<li>Display up to 40 services</li>
</ul>
</ul>
<p>To register, you will need to enter a work email address to receive a confirmation email</p>
<p>
To register, you will need to enter a work email address to receive a
confirmation email
</p>
<form on:submit={request}>
<input type="text" autocomplete="email" placeholder="Enter work email" bind:value={inputValue} on:input={handleInput}><br>
<input
type="text"
autocomplete="email"
placeholder="Enter work email"
bind:value={inputValue}
on:input={handleInput}
/><br />
<label for="checkbox">
I have read and accept the terms of the <a href="/more/privacy">Privacy Policy</a><br>
<input id="checkbox" type="checkbox" required>
</label><br>
I have read and accept the terms of the <a href="/more/privacy"
>Privacy Policy</a
><br />
<input id="checkbox" type="checkbox" required />
</label><br />
<button type="submit">Submit</button>
</form>
{:else if state == "sent"}
<p>An email has been sent, click the link in the email to activate your profile.</p>
<p>When you click the link, your authorisation key will be automatically be stored in your browser.</p>
<p>If you use multiple browsers, you will only be logged in using the browser you open the link with.</p>
{:else if state == 'sent'}
<p>
An email has been sent, click the link in the email to activate your
profile.
</p>
<p>
When you click the link, your authorisation key will be automatically be
stored in your browser.
</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"}
<p>The email address you entered does not belong to an authorised business.</p>
<p>If you think this is an error, you can report an issue in the 'More' menu.</p>
{:else if state == "error"}
{: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 report an issue in the 'More' menu.
</p>
{: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</p>
{/if}
<Nav />
@ -98,7 +120,8 @@
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,72 +1,73 @@
<script>
import Header from "$lib/navigation/header.svelte";
import Loading from "$lib/navigation/loading.svelte";
import Nav from "$lib/navigation/nav.svelte";
import { uuid } from "$lib/stores/uuid.js";
import { onMount } from "svelte";
import Header from '$lib/navigation/header.svelte';
import Loading from '$lib/navigation/loading.svelte';
import Nav from '$lib/navigation/nav.svelte';
import { uuid } from '$lib/stores/uuid.js';
import { onMount } from 'svelte';
const title = "Registration"
let state = "";
let isLoading = true
const title = 'Registration';
let state = '';
let isLoading = true;
async function getUUID() {
return new URLSearchParams(window.location.search).get('key');
}
async function submit(id) {
const url = "https://owlboard.info/api/v2/user/register"
const url = 'https://owlboard.info/api/v2/user/register';
const request = {
method: "POST",
method: 'POST',
headers: {
"Content-Type": "application/json"
'Content-Type': 'application/json'
},
body: JSON.stringify({
uuid: id
})
}
};
const res = await fetch(url, request);
const body = await res.json();
if (body.api_key) {
uuid.set(body.api_key);
return 201
return 201;
}
return res.status;
}
onMount(async () => {
const id = await getUUID() || "";
if (id == "" || !id) {
state = "none"
isLoading = false
return
const id = (await getUUID()) || '';
if (id == '' || !id) {
state = 'none';
isLoading = false;
return;
}
const status = await submit(id)
const status = await submit(id);
if (status == 201) {
console.log("Registered Successfully")
state = "done"
console.log('Registered Successfully');
state = 'done';
} else if (status == 401) {
console.log("Invalid Key")
state = "unauth"
console.log('Invalid Key');
state = 'unauth';
} else {
console.log("Error")
state = "error"
console.log('Error');
state = 'error';
}
isLoading = false
})
isLoading = false;
});
</script>
<Header {title} />
{#if isLoading}
<Loading />
{/if}
{#if state == "none"}
{#if state == 'none'}
<p>Unable to read your access key.</p>
<p>Please click the link in your email again.</p>
{:else if state == "unauth"}
{:else if state == 'unauth'}
<p>Your link is not valid, links expire after 30 minutes.</p>
<p>You can try to register again.</p>
{:else if state == "error"}
{:else if state == 'error'}
<p>There was an error on our end, please try again later</p>
{:else if state == "done"}
{:else if state == 'done'}
<p>You are now logged in</p>
{/if}
<Nav />

View File

@ -1,62 +1,66 @@
<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 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';
const title = "Report Issue";
const title = 'Report Issue';
let isLoading = false;
let isDone = false;
let isError = false;
let reportType = "", reportSubject = "", reportMsg = "", reportCollected
let reportType = '',
reportSubject = '',
reportMsg = '',
reportCollected;
onMount(async () => {
reportCollected = {
userAgent: navigator.userAgent,
browser: navigator.appName,
version: navigator.appVersion,
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)
console.log(reportType, reportSubject, reportMsg);
preFlight = true;
}
async function send() {
console.log("SEND DATA REQUESTED")
isLoading = true
console.log('SEND DATA REQUESTED');
isLoading = true;
const formData = JSON.stringify({
label: reportType,
subject: reportSubject,
msg: `User Agent: ${reportCollected.userAgent}\n` +
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 = `https://owlboard.info/misc/issue`
});
const url = `https://owlboard.info/misc/issue`;
const options = {
method: "POST",
method: 'POST',
headers: {
"Content-Type": "application/json"
'Content-Type': 'application/json'
},
body: formData
}
const res = await fetch(url, options)
};
const res = await fetch(url, options);
if (res.status == 200) {
isLoading = false;
isDone = true;
await new Promise(r => setTimeout(r, 2000));
window.location.href = "/";
await new Promise((r) => setTimeout(r, 2000));
window.location.href = '/';
} else {
isLoading = false;
isError = true;
@ -69,8 +73,8 @@
isDone = false;
isError = false;
}
</script>
<Header {title} />
{#if isLoading}
@ -82,23 +86,42 @@
{/if}
{#if !preFlight && !isDone}
<p>Any data that you enter here will be visible publicly
<a href="https://git.fjla.uk/OwlBoard/backend/issues" target="_blank">here</a>
<p>
Any data that you enter here will be visible publicly
<a href="https://git.fjla.uk/OwlBoard/backend/issues" target="_blank"
>here</a
>
</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}>
<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="bug">Problem</option>
<option value="enhancement">Feature Request</option>
<option value="question">Question</option>
<option value="user-support">Unable to sign up</option>
</select>
<br>
<input class="formInputs" type="text" bind:value={reportSubject} placeholder="Subject">
<br>
<textarea class="formInputs" bind:value={reportMsg} placeholder="Enter your message..."/>
<br>
<br />
<input
class="formInputs"
type="text"
bind:value={reportSubject}
placeholder="Subject"
/>
<br />
<textarea
class="formInputs"
bind:value={reportMsg}
placeholder="Enter your message..."
/>
<br />
<button type="submit">Submit</button>
<button type="reset">Reset</button>
</form>
@ -106,7 +129,9 @@
<Island>
<h2>Device Data:</h2>
<p><span class="dataType">User Agent: </span>{reportCollected.userAgent}</p>
<p><span class="dataType">Browser: </span>{reportCollected.browser} - {reportCollected.version}</p>
<p>
<span class="dataType">Browser: </span>{reportCollected.browser} - {reportCollected.version}
</p>
<p><span class="dataType">Platform: </span>{reportCollected.platform}</p>
<p><span class="dataType">Viewport: </span> {reportCollected.viewport}</p>
<h2>Reported Data:</h2>
@ -161,8 +186,12 @@
height: 30px;
max-width: 100px;
}
h2 {color: white;}
.dataType {color: white;}
h2 {
color: white;
}
.dataType {
color: white;
}
.overlayButtons {
background-color: var(--main-bg-color);
}

View File

@ -1,9 +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,16 +1,16 @@
<script>
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 Nav from '$lib/navigation/nav.svelte'
import Nav from '$lib/navigation/nav.svelte';
import { onMount } from 'svelte';
const title = "Statistics"
const title = 'Statistics';
let isLoading = true;
let data, error;
onMount(async () => {
const url = "https://owlboard.info/misc/server/stats"
const url = 'https://owlboard.info/misc/server/stats';
const res = await fetch(url);
if (res.status == 200) {
data = await res.json();
@ -18,18 +18,17 @@ import Header from '$lib/navigation/header.svelte'
error = true;
}
isLoading = false;
})
});
function U2L(input) {
try {
const datetime = new Date(input*1000)
return datetime.toLocaleString()
const datetime = new Date(input * 1000);
return datetime.toLocaleString();
} catch (err) {
console.log(err);
return false;
}
}
</script>
<Header {title} />
@ -43,7 +42,7 @@ import Header from '$lib/navigation/header.svelte'
{#if isLoading}
<Loading />
{:else if !isLoading && !error}
<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>Stats Reset: <span>{U2L(data?.reset) || 'Unknown'}</span></p>
<h2>Last Update</h2>

View File

@ -1,18 +1,19 @@
<script>
import Header from '$lib/navigation/header.svelte'
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 Nav from '$lib/navigation/nav.svelte';
import LargeLogo from '$lib/images/large-logo.svelte';
import { onMount } from 'svelte';
const title = "Versions"
const variable = {title:""};
const title = 'Versions';
const variable = { title: '' };
let data, isLoading = true;
let data,
isLoading = true;
async function getData() {
const url = 'https://owlboard.info/misc/server/versions'
const res = await fetch(url)
const url = 'https://owlboard.info/misc/server/versions';
const res = await fetch(url);
data = await res.json();
isLoading = false;
}
@ -20,7 +21,6 @@
onMount(() => {
getData();
});
</script>
<Header {title} />
@ -31,13 +31,17 @@
<Loading />
{:else}
<Island>
<p>Web-app Version<br><span class="data">{"2023.7.1-Svelte-Dev"}</span></p>
<p>API Server Version<br><span class="data">{data.backend}</span></p>
<p>DBManager Version<br><span class="data">{data['db-manager']}</span></p>
<p>
Web-app Version<br /><span class="data">{'2023.7.1-Svelte-Dev'}</span>
</p>
<p>API Server Version<br /><span class="data">{data.backend}</span></p>
<p>DBManager Version<br /><span class="data">{data['db-manager']}</span></p>
</Island>
{/if}
<Nav />
<style>
.data {color: white;}
.data {
color: white;
}
</style>

View File

@ -1,56 +1,56 @@
<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';
import Island from '$lib/islands/island.svelte';
import Loading from '$lib/navigation/loading.svelte';
import { uuid } from '$lib/stores/uuid';
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 isLoading = false
let errMsg = 'Unknown Error';
let isLoading = false;
async function findByStartEnd() {
isLoading = true
const url = `https://owlboard.info/api/v2/pis/byStartEnd/${entryStartCRS}/${entryEndCRS}`
isLoading = true;
const url = `https://owlboard.info/api/v2/pis/byStartEnd/${entryStartCRS}/${entryEndCRS}`;
await fetchData(url);
isLoading = false
isLoading = false;
}
async function findByPis() {
isLoading = true
const url = `https://owlboard.info/api/v2/pis/byCode/${entryPIS}`
isLoading = true;
const url = `https://owlboard.info/api/v2/pis/byCode/${entryPIS}`;
await fetchData(url);
isLoading = false;
}
async function fetchData(url) {
const options = {
method: "GET",
method: 'GET',
headers: {
"uuid": $uuid
}
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
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
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"
error = true
return false
if (jsonData.ERROR == 'offline') {
errMsg = 'Connection error, check your internet connection and try again';
error = true;
return false;
}
data = jsonData;
}
@ -58,9 +58,9 @@
async function reset() {
data = [];
error = false;
entryPIS = "";
entryStartCRS = "";
entryEndCRS = "";
entryPIS = '';
entryStartCRS = '';
entryEndCRS = '';
}
</script>
@ -84,9 +84,9 @@
</tr>
{#each data as item}
<tr>
<td class="toc toc-data">{item.operator || "-"}</td>
<td class="toc toc-data">{item.operator || '-'}</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>
@ -96,16 +96,34 @@
<p>This feature is only supported for GWR West & Sleeper services</p>
<p class="label">Find By Start/End CRS:</p>
<form on:submit={findByStartEnd}>
<input type="text" maxlength="3" autocomplete="off" placeholder="Start" bind:value={entryStartCRS}>
<input type="text" maxlength="3" autocomplete="off" placeholder="End" bind:value={entryEndCRS}>
<br>
<input
type="text"
maxlength="3"
autocomplete="off"
placeholder="Start"
bind:value={entryStartCRS}
/>
<input
type="text"
maxlength="3"
autocomplete="off"
placeholder="End"
bind:value={entryEndCRS}
/>
<br />
<button type="submit">Search</button>
</form>
<p class="label">Find By PIS Code:</p>
<form on:submit={findByPis}>
<input type="number" max="9999" autocomplete="off" placeholder="PIS" bind:value={entryPIS}>
<br>
<input
type="number"
max="9999"
autocomplete="off"
placeholder="PIS"
bind:value={entryPIS}
/>
<br />
<button type="submit">Search</button>
</form>
{/if}

View File

@ -1,25 +1,25 @@
<script>
import Header from '$lib/navigation/header.svelte'
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 { onMount } from 'svelte';
import TrainDetail from '$lib/train/train-detail.svelte';
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';
}
}
@ -29,47 +29,46 @@
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 = "") {
async function fetchData(id = '') {
const date = 'now';
const searchType = 'headcode'
const searchType = 'headcode';
const options = {
method: "GET",
method: 'GET',
headers: {
"uuid": $uuid
uuid: $uuid
}
}
const url = `https://owlboard.info/api/v2/timetable/train/${date}/${searchType}/${id}`
};
const url = `https://owlboard.info/api/v2/timetable/train/${date}/${searchType}/${id}`;
const res = await fetch(url, options);
isLoading = false;
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"
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;
}
}
</script>
<Header {title} />
<div id="whitespace"></div>
<div id="whitespace" />
{#if error}
<Island>

View File

@ -4,11 +4,7 @@ import { build, files, version } from '$service-worker';
const cacheName = `ob-${version}`;
const assets = [
...build,
...files,
"/service-worker.js"
];
const assets = [...build, ...files, '/service-worker.js'];
self.addEventListener('install', (event) => {
async function addToCache() {
@ -17,7 +13,7 @@ self.addEventListener('install', (event) => {
}
event.waitUntil(addToCache());
})
});
self.addEventListener('activate', (event) => {
async function deleteOldCache() {
@ -29,10 +25,12 @@ self.addEventListener('activate', (event) => {
}
event.waitUntil(deleteOldCache());
})
});
self.addEventListener('fetch', (event) => {
if (event.request.method !== 'GET') {return}
if (event.request.method !== 'GET') {
return;
}
async function respond() {
const cacheRes = await caches.match(event.request, { ignoreSearch: true });
if (cacheRes) {
@ -40,11 +38,11 @@ self.addEventListener('fetch', (event) => {
}
try {
return await fetch(event.request)
return await fetch(event.request);
} catch (err) {
return {"error": "OFFLINE", "errorMsg": "You are not online"};
return { error: 'OFFLINE', errorMsg: 'You are not online' };
}
}
event.respondWith(respond());
})
});