diff --git a/game_manager.js b/game_manager.js index 36342c3..da425fe 100644 --- a/game_manager.js +++ b/game_manager.js @@ -23,6 +23,8 @@ class GameManager this.game_mode = "none"; + this.use_notification = false; + this.game_server_connection = game_server_connection; game_server_connection.set_game_manager(this); @@ -292,22 +294,24 @@ class GameManager this.end_game(); } + activate_notifications() + { + this.use_notification = true; + } + notify(text) { - if (!("Notification" in window)) { - return; - } + + Notification.requestPermission(function(result) { + if (result === 'granted') { + navigator.serviceWorker.ready.then(function(registration) { + registration.showNotification(text, { + icon: './icon.png', + vibrate: [200, 200], + tag: "tictactoe-notification" + }); + }); + } + }); - else if (Notification.permission === "granted") { - var notification = new Notification(text); - } - - else if (Notification.permission !== 'denied') { - Notification.requestPermission(function (permission) { - if (permission === "granted") { - var notification = new Notification(text); - } - }); - } - - } + } } \ No newline at end of file diff --git a/index.html b/index.html index f824fef..6ab51da 100644 --- a/index.html +++ b/index.html @@ -2,7 +2,7 @@ - + ultimate tictactoe diff --git a/manifest.json b/manifest.json index b381163..f0667a6 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,8 @@ "name": "Ultimate TicTacToe", "short_name": "Ultimate TicTacToe", "display": "standalone", - "start_url": "/", + "start_url": "/website/ultimate_tictactoe/", + "scope": "/website/ultimate_tictactoe/", "theme_color": "#4650e2", "background_color": "#1e2477", "icons": [ diff --git a/settings.js b/settings.js index 05824a1..0c3c835 100644 --- a/settings.js +++ b/settings.js @@ -1,2 +1,2 @@ -var server_url = "127.0.0.1"; +var server_url = "the-cake-is-a-lie.net"; var server_port = "5555"; \ No newline at end of file diff --git a/sw.js b/sw.js index df3af84..54d2a7b 100644 --- a/sw.js +++ b/sw.js @@ -3,22 +3,22 @@ self.addEventListener('install', function(e) { e.waitUntil( caches.open('your-magic-cache').then(function(cache) { return cache.addAll([ - '/', - '/index.html', - '/manifest.json', - '/icon.png', - '/LICENSE', - '/main.js', - '/grid.js', - '/game_manager.js', - '/game_server_connection.js', - '/sidebar.js', - '/settings.js', - '/subgrid.js', - '/tile.js', - '/README.md', - '/site.js', - '/style.css', + '/website/ultimate_tictactoe/', + '/website/ultimate_tictactoe/index.html', + '/website/ultimate_tictactoe/manifest.json', + '/website/ultimate_tictactoe/icon.png', + '/website/ultimate_tictactoe/LICENSE', + '/website/ultimate_tictactoe/main.js', + '/website/ultimate_tictactoe/grid.js', + '/website/ultimate_tictactoe/game_manager.js', + '/website/ultimate_tictactoe/game_server_connection.js', + '/website/ultimate_tictactoe/sidebar.js', + '/website/ultimate_tictactoe/settings.js', + '/website/ultimate_tictactoe/subgrid.js', + '/website/ultimate_tictactoe/tile.js', + '/website/ultimate_tictactoe/README.md', + '/website/ultimate_tictactoe/site.js', + '/website/ultimate_tictactoe/style.css', ]); }) );