diff options
-rw-r--r-- | client.html | 21 | ||||
-rw-r--r-- | sw.js | 1 |
2 files changed, 18 insertions, 4 deletions
diff --git a/client.html b/client.html index 9150a7a..8f2f7be 100644 --- a/client.html +++ b/client.html @@ -1,28 +1,43 @@ <meta charset="UTF-8"> <body onload="getNotPerm()"> +<!--- Import jquery--> +<script src="jquery-3.3.1.min.js"></script> <script> +//function called after permission has been requested function handlePermissions(result) { console.log("Permission "+ result); permissionDisplay = document.getElementsByClassName("pd")[0]; grantedMsg = "You have granted notification permissions"; deniedMsg = "You have not granted notification permissions"; + //updates permissions if(result == "granted"){ permissionDisplay.innerHTML = grantedMsg; } else { permissionDisplay.innerHTML = deniedMsg; } - poop = result; return; } +//gets notification permissions function getNotPerm() { + //makes handlePermissions() the callback Notification.requestPermission().then(handlePermissions); + //requests permissions Notification.requestPermission(); - navigator.serviceWorker.register('/sw.js'); return; } +//sends a new message function notify() { msg = new Notification("あなたはチンチンが大好き"); - msg.show(); +} +//performing an https POST on the backend +$.post("https://" + window.hostname.location + "/api/msg", + {last-displayed: 0},// data to submit + function(data, status, jqXHR) { //callback function + if (data == ""){ + return; + } + console.log(data); + } } </script> <!--- Permission display--> @@ -1 +0,0 @@ -console.log("service workers are dumb"); |