diff --git a/app/templates/js/setting.js b/app/templates/js/setting.js new file mode 100644 index 0000000..16614c8 --- /dev/null +++ b/app/templates/js/setting.js @@ -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); + } + }); +} \ No newline at end of file diff --git a/app/templates/setting.phtml b/app/templates/setting.phtml index 593ad91..ce790d7 100644 --- a/app/templates/setting.phtml +++ b/app/templates/setting.phtml @@ -20,10 +20,10 @@