diff options
author | Mario <mario@mariovavti.com> | 2021-06-24 19:31:19 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2021-06-24 19:31:19 +0000 |
commit | 167db22e15c72c32cd67ce1a2b242dc4527e0b64 (patch) | |
tree | 5838e2d84860366a9fdb6a68dc92aeb692306c60 /view/js/main.js | |
parent | 108777251e4d5f61c9fa344f7a19c31a1b12fb44 (diff) | |
download | volse-hubzilla-167db22e15c72c32cd67ce1a2b242dc4527e0b64.tar.gz volse-hubzilla-167db22e15c72c32cd67ce1a2b242dc4527e0b64.tar.bz2 volse-hubzilla-167db22e15c72c32cd67ce1a2b242dc4527e0b64.zip |
slightly refactor for desktop notifications and fix minor issues
Diffstat (limited to 'view/js/main.js')
-rw-r--r-- | view/js/main.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/view/js/main.js b/view/js/main.js index 78bd790cd..a286d53bf 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -1730,3 +1730,29 @@ function makeid(length) { return result; } +function push_notification_request(e) { + if (!('Notification' in window)) { + alert('This browser does not support push notifications'); + } + else if (Notification.permission !== 'granted') { + Notification.requestPermission(function(permission) { + if(permission === 'granted') { + $(e.target).closest('button').hide(); + } + }); + } +} + + +function push_notification(body, title) { + let options = { + body: body, + icon: '/images/hz-64.png', + silent: false + } + + let n = new Notification(title, options); + n.onclick = function (event) { + setTimeout(n.close.bind(n), 300); + } +} |