-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit_prefs.js
30 lines (27 loc) · 1.09 KB
/
init_prefs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* global __, Plugins */
Plugins.Af_Notifications = {
_node: null,
setPrefNode: (node) => { Plugins.Af_Notifications._node = node },
refreshPrefNodeContent: () => {
let content = '';
switch (Notification.permission) {
case 'granted':
content += `<div class='alert alert-info'>${__('You have accepted receiving notifications. Add a filter action in Filters to get started!')}</div>`;
break;
case 'denied':
content += `<div class='alert'>${__('Receiving notifications from this site has been denied. ' +
'Remove the explicit block in your browser and click the link below to continue.')}</div>`;
// eslint-disable-next-line no-fallthrough
default:
content += '<div class="alert alert-info"><a href="#" onclick="Plugins.Af_Notifications.requestPermission(); return false">' +
__('Click here to accept receiving notifications from this site.') +
'</a></div>';
}
Plugins.Af_Notifications._node.attr('content', content);
},
requestPermission: () => {
Notification.requestPermission(() => {
Plugins.Af_Notifications.refreshPrefNodeContent();
});
},
};