From 11944e43b67c079ccb1ec398e468b2d774b9ec40 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 14 Jul 2021 15:58:39 +0200 Subject: Stop blinking READY TO START when window is in focus. --- public/join.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/public/join.js b/public/join.js index 19efcde..4c2b0a8 100644 --- a/public/join.js +++ b/public/join.js @@ -14,13 +14,16 @@ let blink_title = document.title; let blink_timer = 0; function start_blinker(message) { - let tick = true; + let tick = false; if (blink_timer) stop_blinker(); - blink_timer = setInterval(function () { - document.title = tick ? message : blink_title; - tick = !tick; - }, 1000); + if (!document.hasFocus()) { + document.title = message; + blink_timer = setInterval(function () { + document.title = tick ? message : blink_title; + tick = !tick; + }, 1000); + } } function stop_blinker() { @@ -29,6 +32,8 @@ function stop_blinker() { blink_timer = 0; } +window.addEventListener("focus", stop_blinker); + function send(url) { fetch(url) .then(r => r.text()) -- cgit v1.2.3