+ const checkDisplayThenAnimate = () => {
+ if (boardContainer.style.display == "none") {
+ alert("New move! Let's go back to game...");
+ document.getElementById("gameInfos").style.display = "none";
+ boardContainer.style.display = "block";
+ setTimeout(launchAnimation, 700);
+ }
+ else launchAnimation(); //focused user!
+ };
+ let boardContainer = document.getElementById("boardContainer");
+ if (!document.hasFocus()) {
+ window.onfocus = () => {
+ window.onfocus = undefined;
+ checkDisplayThenAnimate();
+ };
+ }
+ else checkDisplayThenAnimate();