aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/RenderUtil.ts
diff options
context:
space:
mode:
authorLibravatarLarge Libravatar 7222e800-c703-472d-a787-71b6b5cba4ef <memestrogenzone>2025-09-14 17:22:36 +0000
committerLibravatarLarge Libravatar 7222e800-c703-472d-a787-71b6b5cba4ef <memestrogenzone>2025-09-14 17:22:36 +0000
commit93dacfa69ac9c4c1e53b977e7f74defe8e9c63f2 (patch)
tree8122ea8d609817a23e685d4f9824d244ee543e9d /src/lib/RenderUtil.ts
parentea68e415925946b44fa645bbf3f6087f48fe63cf (diff)
downloadfahrplan-93dacfa69ac9c4c1e53b977e7f74defe8e9c63f2.tar.gz
fahrplan-93dacfa69ac9c4c1e53b977e7f74defe8e9c63f2.tar.bz2
fahrplan-93dacfa69ac9c4c1e53b977e7f74defe8e9c63f2.tar.lz
fahrplan-93dacfa69ac9c4c1e53b977e7f74defe8e9c63f2.zip

refactor: maybe also move notices out

Diffstat (limited to 'src/lib/RenderUtil.ts')
-rw-r--r--src/lib/RenderUtil.ts31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/lib/RenderUtil.ts b/src/lib/RenderUtil.ts
index c6963bc..bf360ab 100644
--- a/src/lib/RenderUtil.ts
+++ b/src/lib/RenderUtil.ts
@@ -83,3 +83,34 @@ export const stopTimeShouldRenderGlyph = (
(stopTime.mode === 'METRO' && stopTime.routeShortName.startsWith('S'))) &&
!stopTime.routeShortName.startsWith('FlixTrain');
export const blacklistedAgencyURLs = ['http://www.rta.ae'];
+
+export const getNotices = (
+ stopTime: StopTime,
+ delayMinutes: number,
+ isArrivals: boolean
+) => {
+ let notices = [] as [pictogram: string[], content: string][];
+ if (stopTime.cancelled)
+ notices.push([['Cancellation', 'Attention'], m.connection_cancelled()]);
+ if (delayMinutes < -0.5) {
+ notices.push([
+ ['Hint'],
+ m.connection_early({
+ minutes: -delayMinutes,
+ arrival: isArrivals.toString(),
+ }),
+ ]);
+ } else if (delayMinutes >= 1) {
+ notices.push([
+ delayMinutes >= 3
+ ? ['Delay', 'Attention']
+ : delayMinutes >= 2
+ ? ['Delay', 'Hint']
+ : ['Hint'],
+ m.connection_delayed({
+ minutes: delayMinutes.toFixed(0),
+ }),
+ ]);
+ }
+ return notices;
+};