From dd165d03e95f252150a94fc27d0280551d7e041b Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sun, 27 Jun 2021 13:50:05 +0200 Subject: Blink title when game is ready to start. --- public/join.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'public/join.js') diff --git a/public/join.js b/public/join.js index f69879e..d2d39ab 100644 --- a/public/join.js +++ b/public/join.js @@ -9,6 +9,25 @@ function confirm_delete(status) { window.location.href = "/delete/" + game.game_id; } +let blink_title = document.title; +let blink_timer = 0; + +function start_blinker(message) { + let tick = true; + if (blink_timer) + stop_blinker(); + blink_timer = setInterval(function () { + document.title = tick ? message : blink_title; + tick = !tick; + }, 1000); +} + +function stop_blinker() { + document.title = blink_title; + clearInterval(blink_timer); + blink_timer = 0; +} + function send(url) { fetch(url) .then(r => r.text()) @@ -105,6 +124,11 @@ function update() { window.start_button.classList = (game.status === 0) ? "" : "hide"; window.delete_button.classList = (game.status === 0 || solo) ? "" : "hide"; } + + if (game.status === 0 && ready) + start_blinker("READY TO START"); + else + stop_blinker(); } window.onload = function () { -- cgit v1.2.3