summaryrefslogtreecommitdiff
path: root/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'index.html')
-rw-r--r--index.html47
1 files changed, 47 insertions, 0 deletions
diff --git a/index.html b/index.html
new file mode 100644
index 0000000..8f2f7be
--- /dev/null
+++ b/index.html
@@ -0,0 +1,47 @@
+<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;
+ }
+ return;
+}
+//gets notification permissions
+function getNotPerm() {
+ //makes handlePermissions() the callback
+ Notification.requestPermission().then(handlePermissions);
+ //requests permissions
+ Notification.requestPermission();
+ return;
+}
+//sends a new message
+function notify() {
+ msg = new Notification("あなたはチンチンが大好き");
+}
+//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-->
+<p class="pd">You have not granted notification permissions</p>
+<button onclick="getNotPerm()">Re-request Notification Permissions</button>
+<button onclick="notify()">Send Notifications</button>
+</body>