mirror of
https://git.steelants.cz/SH/PHP_SMART_HOME_V3.git
synced 2026-10-11 17:54:34 +00:00
Notification Section -> Setting
This commit is contained in:
1 parent
669b873a4f
commit
15c429e151
3 files changed
+68
-7
No files matched your search
@@ -0,0 +1,40 @@
|
||||
navigator.permissions.query({name:'notifications'}).then(function(result) {
|
||||
var element = document.getElementById("notifications");
|
||||
if (result.state === 'granted') {
|
||||
element.checked = true;
|
||||
} else if (result.state === 'denied') {
|
||||
element.checked = false;
|
||||
} else if (result.state === 'prompt') {
|
||||
element.checked = false;
|
||||
}
|
||||
});
|
||||
|
||||
function toggleNotificationPermissions(input){
|
||||
navigator.permissions.query({name:'notifications'}).then(function(result) {
|
||||
if (result.state === 'granted') {
|
||||
input.checked = true;
|
||||
} else if (result.state === 'denied') {
|
||||
input.checked = false;
|
||||
} else if (result.state === 'prompt') {
|
||||
input.checked = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function sendTestNotification(){
|
||||
console.log("sending test notification");
|
||||
$.ajax({
|
||||
url: 'ajax',
|
||||
type: 'POST',
|
||||
data: {
|
||||
"notification" : 'X',
|
||||
"action": 'sendTest'
|
||||
},
|
||||
success: function(data){
|
||||
console.log(data);
|
||||
},
|
||||
error: function (request, status, error) {
|
||||
console.log("ERROR ", request, error);
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user