notifications
This commit is contained in:
		| @ -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); | ||||
|                 } | ||||
|             }); | ||||
|         } | ||||
|        | ||||
|       } | ||||
|     } | ||||
| } | ||||
| @ -2,7 +2,7 @@ | ||||
|     <link rel="stylesheet" type="text/css" href="style.css"> | ||||
| 	<head> | ||||
|         <meta name="viewport" content="width=device-width, user-scalable=no" /> | ||||
|         <link rel="manifest" href="manifest.json" /> | ||||
|         <link rel="manifest" href="./manifest.json" /> | ||||
|         <link rel="icon" href="icon.png" type="image/png"/> | ||||
|         <script defer src="site.js"></script> | ||||
| 		<title>ultimate tictactoe</title> | ||||
|  | ||||
| @ -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": [ | ||||
|  | ||||
| @ -1,2 +1,2 @@ | ||||
| var server_url = "127.0.0.1"; | ||||
| var server_url = "the-cake-is-a-lie.net"; | ||||
| var server_port = "5555"; | ||||
							
								
								
									
										32
									
								
								sw.js
									
									
									
									
									
								
							
							
						
						
									
										32
									
								
								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', | ||||
|         ]); | ||||
|       }) | ||||
|     ); | ||||
|  | ||||
		Reference in New Issue
	
	Block a user