diff --git a/main.js b/main.js index 55635ad..4d7cf8a 100644 --- a/main.js +++ b/main.js @@ -17,4 +17,28 @@ var sidebar = new Sidebar(create_game_container, setting_container, control_cont window.addEventListener("resize", function() { var tilesize = getComputedStyle(document.body).getPropertyValue("--tile-size"); grid.on_screen_orientation_change(tilesize, tilesize); -}) +}); + +window.addEventListener('notificationclick', function(event) { + event.waitUntil(async function() { + const allClients = await clients.matchAll({ + includeUncontrolled: true + }); + + var instance = None; + + + // Let's see if we already have a window open: + for (const client of allClients) { + client.focus(); + instance = client; + break; + } + + // If we didn't find an existing window, + // open a new one: + if (!instance) { + instance = await clients.openWindow(rel_home); + } + }()); +}); diff --git a/settings.js b/settings.js index 0c3c835..d22e1c7 100644 --- a/settings.js +++ b/settings.js @@ -1,2 +1,4 @@ +var home = "https://the-cake-is-a-lie.net/website/ultimate_tictactoe/"; +var rel_home = "/website/ultimate_tictactoe"; var server_url = "the-cake-is-a-lie.net"; var server_port = "5555"; \ No newline at end of file