Notification info banner

This commit is contained in:
ostertun
2020-10-15 15:19:04 +02:00
parent 4228ec739d
commit 9f3019b4c5
3 changed files with 64 additions and 19 deletions

View File

@@ -1,8 +1,40 @@
var firstCall = true;
var today;
var onUpdatePushBadge;
var siteScript = async function() {
today = getToday();
if (firstCall) {
firstCall = false;
$('#button-notifications-activate').click(function(){
$('#menu-pushes').showMenu();
});
$('#a-notifications-later').click(function(){
createCookie('regatten_app_' + BOATCLASS + '_rejected_push', true, 1);
$('#card-notifications').hide();
});
if (readCookie('regatten_app_' + BOATCLASS + '_rejected_push')) {
$('#card-notifications').hide();
} else {
onUpdatePushBadge = function () {
if (!pushesPossible || (Notification.permission == 'denied')) {
$('#card-notifications').hide();
} else {
swRegistration.pushManager.getSubscription().then(function(subscription) {
var isSub = (subscription !== null);
if (isSub) {
$('#card-notifications').hide();
} else {
$('#card-notifications').show();
}
});
}
}
onUpdatePushBadge();
}
}
if (isLoggedIn()) {
$('#card-notloggedin').hide();