simplify some of the code for notifications
This commit is contained in:
parent
1f754f53a3
commit
54f29398e2
10
js/chess.js
10
js/chess.js
|
|
@ -602,13 +602,11 @@ function disableNotify(){
|
||||||
|
|
||||||
function requestNotify(){
|
function requestNotify(){
|
||||||
try {
|
try {
|
||||||
if (Notification && Notification.permission !== 'granted') {
|
|
||||||
Notification.requestPermission(function (permission){
|
Notification.requestPermission(function (permission){
|
||||||
if (permission === 'denied') {
|
if (permission === 'denied') {
|
||||||
disableNotify();
|
disableNotify();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
disableNotify();
|
disableNotify();
|
||||||
}
|
}
|
||||||
|
|
@ -637,7 +635,9 @@ function notify(body) {
|
||||||
|
|
||||||
$(function (){
|
$(function (){
|
||||||
try {
|
try {
|
||||||
if ('serviceWorker' in navigator) {
|
if (Notification.permission === 'denied') {
|
||||||
|
disableNotify();
|
||||||
|
} else {
|
||||||
navigator.serviceWorker.register('sw.js').catch(disableNotify);
|
navigator.serviceWorker.register('sw.js').catch(disableNotify);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
@ -717,10 +717,6 @@ $(function (){
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (Notification.permission === 'denied') {
|
|
||||||
disableNotify();
|
|
||||||
}
|
|
||||||
|
|
||||||
let updateMeta = function() { putMeta(); }
|
let updateMeta = function() { putMeta(); }
|
||||||
$('#cb_light_name').on('input', updateMeta);
|
$('#cb_light_name').on('input', updateMeta);
|
||||||
$('#cb_dark_name').on('input', updateMeta);
|
$('#cb_dark_name').on('input', updateMeta);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue