diff options
author | Haoran S. Diao <0@hairydiode.xyz> | 2019-11-21 23:35:02 -0800 |
---|---|---|
committer | Haoran S. Diao <0@hairydiode.xyz> | 2019-11-21 23:35:02 -0800 |
commit | 221ca22e1c51ab6ef8a9d870899be10eceb22706 (patch) | |
tree | b540b4b27a5422946f033af276c59a574796b7ce /index.html | |
parent | 19b4d5e0330fddd92d43cd30a3757c1c7fd565f5 (diff) |
Added jquery and related licenses, moved client.html to index.html
Diffstat (limited to 'index.html')
-rw-r--r-- | index.html | 47 |
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> |