focus handling

This commit is contained in:
Jonas Weinz 2019-03-21 17:17:42 +01:00
parent 5e19473e53
commit 93bec941f2
2 changed files with 17 additions and 8 deletions

20
main.js
View File

@ -199,6 +199,7 @@ logout = function()
// delete session:
session_id = get_cookie("sessionid");
set_cookie("sessionid", session_id, -100);
session_id = null;
}
}
@ -278,16 +279,19 @@ b_match_invite.addEventListener("click", invite_player);
reconnect();
/*
var websocket_connection = new WebsocketConnection('127.0.0.1', 5556);
websocket_connection.connect();
*/
// register resize event:
window.addEventListener("resize", function() {
var tilesize = getComputedStyle(document.body).getPropertyValue("--tile-size");
grid.on_screen_orientation_change(tilesize, tilesize);
})
});
window.onload = function() {
window.onfocus = function() {
if (session_id != null && connection == null)
{
reconnect();
}
};
};

View File

@ -346,6 +346,11 @@ class WebsocketConnection
notify(text) {
if (document.hasFocus())
{
return;
}
Notification.requestPermission(function(result) {
if (result === 'granted') {
navigator.serviceWorker.ready.then(function(registration) {