PHP_SMART_HOME_V3/public/js/setting.js

60 lines
1.6 KiB
JavaScript
Raw Normal View History

2020-10-26 08:44:59 +00:00
2019-10-11 08:44:13 +00:00
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);
}
});
2019-10-25 16:48:48 +00:00
}
$( "button[name='deactivateOta']" ).click(function(){
console.log("Didabling ota");
$.ajax({
url: 'ajax',
type: 'POST',
data: {
2020-10-26 08:44:59 +00:00
"ota": 'X',
2019-10-25 16:48:48 +00:00
"action": 'disable'
},
success: function(data){
console.log(data);
},
error: function (request, status, error) {
console.log("ERROR ", request, error);
}
});
})