From da19cf75c637c9ce1011b27048a04ad7aa75b661 Mon Sep 17 00:00:00 2001 From: Marie Birner Date: Wed, 27 Sep 2023 13:58:22 +0200 Subject: [PATCH] [TASK] add basic reload functionality --- frontend/main.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/frontend/main.ts b/frontend/main.ts index 42e84eb..d050c76 100644 --- a/frontend/main.ts +++ b/frontend/main.ts @@ -16,6 +16,7 @@ document.addEventListener('DOMContentLoaded', function() { initBoatActions(); selectBoatChange(); addRelationMagic(document.querySelector('body')); + reloadPage(); }); function selectBoatChange() { @@ -67,6 +68,22 @@ function selectBoatChange() { } } +function reloadPage() { + let pageTitle = document.title; + let attentionMessage = 'Riemen- und Dollenbruch'; + + document.addEventListener('visibilitychange', function() { + let isPageActive = !document.hidden; + + if(!isPageActive){ + document.title = attentionMessage; + }else { + document.title = pageTitle; + location.reload(); + } + }); +} + function setMaxAmountRowers(rowers: number){ let curSelection = choiceObjects['newrower'].getValue(true); let amount_to_delete = (curSelection).length - rowers;