diff options
author | Haoran S. Diao <0@hairydiode.xyz> | 2019-11-21 23:29:27 -0800 |
---|---|---|
committer | Haoran S. Diao <0@hairydiode.xyz> | 2019-11-21 23:29:27 -0800 |
commit | 19b4d5e0330fddd92d43cd30a3757c1c7fd565f5 (patch) | |
tree | 91f18c3891199a4fde786702d652e227195f2013 | |
parent | 1f841e272d8fe999357aa6f7a0c30deb0d6e99cd (diff) |
Removed redundant webworkers code, added experimental jquery post test
-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"); |