Compare commits

..

2 Commits

3 changed files with 181 additions and 176 deletions

View File

@@ -46,6 +46,7 @@
background: transparent; background: transparent;
position: relative; position: relative;
z-index: 10; z-index: 10;
margin-bottom: 0;
width: 95%; width: 95%;
max-width: 750px; max-width: 750px;
} }
@@ -112,7 +113,7 @@
filter: brightness(1.2); filter: brightness(1.2);
color: var(--color-title); color: var(--color-title);
font-family: 'URW Gothic', sans-serif; font-family: 'URW Gothic', sans-serif;
font-size: 1.0rem; font-size: 1rem;
font-weight: 600; font-weight: 600;
line-height: 1.2; line-height: 1.2;
z-index: 1; z-index: 1;

View File

@@ -3,7 +3,10 @@ import type { ApiTrainsTrainDetails } from '@owlboard/owlboard-ts';
* Converts ISO/JSON time to UK-formatted HH:MM string, with optional (default off) seconds * Converts ISO/JSON time to UK-formatted HH:MM string, with optional (default off) seconds
* Ensures Europe/London timezone irrespective of browser timezone. * Ensures Europe/London timezone irrespective of browser timezone.
*/ */
export function formatUkTime(dateStr: string | Date | undefined, includeSeconds: boolean = false): string { export function formatUkTime(
dateStr: string | Date | undefined,
includeSeconds: boolean = false
): string {
if (!dateStr) return '--:--'; if (!dateStr) return '--:--';
const date = typeof dateStr === 'string' ? new Date(dateStr) : dateStr; const date = typeof dateStr === 'string' ? new Date(dateStr) : dateStr;
@@ -22,14 +25,18 @@ return date.toLocaleTimeString('en-GB', {
* Converts ISO/JSON time to UK-formatted DD/MM/YY HH:MM:SS string. * Converts ISO/JSON time to UK-formatted DD/MM/YY HH:MM:SS string.
* Ensures Europe/London timezone irrespective of browser timezone. * Ensures Europe/London timezone irrespective of browser timezone.
*/ */
export function formatUkDateTime(dateStr: string | Date | undefined, includeSeconds: boolean = false): string { export function formatUkDateTime(
dateStr: string | Date | undefined,
includeSeconds: boolean = false
): string {
if (!dateStr) return '--/--/-- --:--:--'; if (!dateStr) return '--/--/-- --:--:--';
const date = typeof dateStr === 'string' ? new Date(dateStr) : dateStr; const date = typeof dateStr === 'string' ? new Date(dateStr) : dateStr;
if (isNaN(date.getTime())) return '--/--/-- --:--:--'; if (isNaN(date.getTime())) return '--/--/-- --:--:--';
return date.toLocaleString('en-GB', { return date
.toLocaleString('en-GB', {
day: '2-digit', day: '2-digit',
month: '2-digit', month: '2-digit',
year: '2-digit', year: '2-digit',
@@ -38,7 +45,8 @@ export function formatUkDateTime(dateStr: string | Date | undefined, includeSeco
...(includeSeconds && { second: '2-digit' }), ...(includeSeconds && { second: '2-digit' }),
hour12: false, hour12: false,
timeZone: 'Europe/London' timeZone: 'Europe/London'
}).replace(',', ''); })
.replace(',', '');
} }
/** /**

View File

@@ -13,7 +13,7 @@
}, 1000); }, 1000);
return () => clearInterval(interval); return () => clearInterval(interval);
}) });
// Update 'QuickLinks' // Update 'QuickLinks'
$effect(() => { $effect(() => {
@@ -33,21 +33,17 @@
// Load Data Invalidation Handling // Load Data Invalidation Handling
// Refresh countdown logic // Refresh countdown logic
</script> </script>
<section class="board-wrapper"> <section class="board-wrapper">
{#if data.boardData.data.m?.length} {#if data.boardData.data.m?.length}
<StationAlertCard messages={data.boardData.data.m} /> <StationAlertCard messages={data.boardData.data.m} />
{/if}
<div class="time-data"> <div class="time-data">
<span class="time-loaded">Fetched: {formatUkDateTime(data.boardData.producedAt, true)}</span> <span class="time-loaded">Updated: {formatUkDateTime(data.boardData.producedAt, true)}</span>
<span class="time-now">{formatUkTime(now, true)}</span> <span class="time-now">{formatUkTime(now, true)}</span>
</div> </div>
{/if}
</section>
<section class="section-t">Live boards are not yet fully implemented on the server</section>
<pre class="json-dump">{JSON.stringify(data.boardData.data.s, null, 2)}</pre> <pre class="json-dump">{JSON.stringify(data.boardData.data.s, null, 2)}</pre>
</section>
<style> <style>
.board-wrapper { .board-wrapper {
@@ -65,11 +61,12 @@
align-items: center; align-items: center;
width: 90%; width: 90%;
max-width: 700px; max-width: 700px;
margin: 0 auto; margin: 10px auto;
font-family: 'URW Gothic', sans-serif; font-family: 'URW Gothic', sans-serif;
} }
.time-loaded, .time-now { .time-loaded,
.time-now {
font-variant-numeric: tabular-nums; font-variant-numeric: tabular-nums;
} }
@@ -81,22 +78,21 @@
font-weight: 600; font-weight: 600;
font-size: 1rem; font-size: 1rem;
} }
.section-t { pre {
font-family: 'URW Gothic', sans-serif; max-width: 100%;
text-align: center; white-space: pre-wrap;
font-size: 2rem; word-wrap: break-word;
width: 90%; box-sizing: border-box;
margin: auto; overflow-x: auto;
padding-top: 25px;
max-width: 500px;
} }
.json-dump { .json-dump {
background: #222; background: #222;
color: #0f0; color: #0f0;
padding: 1rem; padding: 1rem;
border-radius: 4px; border-radius: 4px;
font-size: 0.9rem; font-size: 0.9rem;
max-height: 500px;
width: 95%; width: 95%;
margin: 1rem auto; } margin: 1rem auto;
}
</style> </style>