summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaoran S. Diao <0@hairydiode.xyz>2019-11-21 23:29:27 -0800
committerHaoran S. Diao <0@hairydiode.xyz>2019-11-21 23:29:27 -0800
commit19b4d5e0330fddd92d43cd30a3757c1c7fd565f5 (patch)
tree91f18c3891199a4fde786702d652e227195f2013
parent1f841e272d8fe999357aa6f7a0c30deb0d6e99cd (diff)
Removed redundant webworkers code, added experimental jquery post test
-rw-r--r--client.html21
-rw-r--r--sw.js1
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-->
diff --git a/sw.js b/sw.js
deleted file mode 100644
index c7802a0..0000000
--- a/sw.js
+++ /dev/null
@@ -1 +0,0 @@
-console.log("service workers are dumb");