diff --git a/client/scripts/regatten.js.php b/client/scripts/regatten.js.php
index d85764a..21a5d22 100644
--- a/client/scripts/regatten.js.php
+++ b/client/scripts/regatten.js.php
@@ -406,6 +406,7 @@ function pushesOpenMenu() {
}
function updatePushBadge() {
+ if (typeof onUpdatePushBadge === 'function') onUpdatePushBadge();
if (!pushesPossible) return;
if (Notification.permission == 'denied') {
$('#badge-pushes').removeClass('bg-green2-dark').addClass('bg-red2-dark').text('BLOCKED');
diff --git a/server/content/index.php b/server/content/index.php
index 0df2a33..e35051d 100644
--- a/server/content/index.php
+++ b/server/content/index.php
@@ -1,14 +1,14 @@
$_CLASS[name]";
$content .= "
$_CLASS[desc]
";
-
+
$sp['output'] .= $tpl->load('card', [$content]);
-
+
// Favorites
$content = 'Deine Favoriten
';
$thead = '| Segler | Rangliste |
';
@@ -17,45 +17,57 @@
$content .= 'Du folgst keinen Seglern.
';
$content .= 'Um jemandem zu folgen, gehe zur Segler-Liste und wähle bis zu fünf Segler aus.';
$content .= '';
-
+
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-favorites']);
-
+
// Planning next
$content = 'Deine nächsten Regatten
';
$content .= '';
$content .= '';
$content .= 'Du fährst in den nächsten vier Wochen auf keine Regatta!';
$content .= '
';
-
+
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-yournext']);
-
+
// Not logged in
$content = 'Nicht angemeldet
';
$content .= '';
$content .= 'Um alle Funktionen dieser Seite nutzen zu können, logge Dich bitte ein.
';
$content .= 'Solltest Du noch kein Benutzerkonto haben, kannst Du Dich kostenlos registrieren.';
$content .= '
';
-
+
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-notloggedin']);
-
+
+ // Notification Info
+ $content = 'Push-Benachrichtigungen
';
+ $content .= '';
+ $content .= 'Bleibe immer auf dem Laufendem!
';
+ $content .= 'Aktiviere einfach unsere Push-Benachrichtigungen und wir informieren Dich über alle Änderungen.
';
+ $content .= 'Du bestimmst natürlich, welche Benachrichtigungen Du bekommen möchtest.';
+ $content .= '
';
+ $content .= $tpl->load('button', ['Jetzt aktivieren', '#', 'html-id' => 'button-notifications-activate', 'css-class' => 'bg-green2-dark']);
+ $content .= 'Vielleicht später
';
+
+ $sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-notifications', 'css-class' => 'bg-blue2-dark']);
+
// Next
$content = 'Nächste Regatten
';
$content .= '';
$content .= '';
$content .= 'Keine Regatten in den nächsten zwei Wochen!';
$content .= '
';
-
+
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-next']);
-
+
// Last
$content = 'Letzte Regatten
';
$content .= '';
$content .= '';
$content .= 'Keine Regatten in den letzten zwei Wochen!';
$content .= '
';
-
+
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-last']);
-
+
// Calendar
$content = 'Regatta-Kalender
';
$content .= 'Du willst alle Regatta-Termine in deinem Kalender, aber nicht alles abtippen?
Kein Problem! Abonniere einfach unseren ics-Kalender.
';
@@ -65,9 +77,9 @@
$content .= '';
$content .= $tpl->load('button', [' Regatta-Kalender', 'https://regatten.net/client/calendar/' . BOATCLASS . '/everything.ics', 'css-class' => 'mb-2']);
$content .= $tpl->load('button', [' Kalender für ', 'https://regatten.net/client/calendar/' . BOATCLASS . '/user_%USERID%.ics', 'css-class' => 'show-loggedin replace-userid-href']);
-
+
$sp['output'] .= $tpl->load('card', [$content]);
-
+
// Regattas Menu
$items = '';
$items .= $tpl->load('menu/item-icon', ['Saison-Planungen', '', 'html-id' => 'menu-item-plannings', 'icon' => 'fa-calendar-alt']);
@@ -78,8 +90,8 @@
$items .= $tpl->load('menu/item-icon', ['offizielle Ergebnisse', '', 'html-id' => 'menu-item-oresults', 'icon' => 'fa-poll']);
$items .= $tpl->load('menu/item-icon', ['Vereins-Website', '', 'html-id' => 'menu-item-clubwebsite', 'icon' => 'fa-globe']);
$sp['menus'] .= $tpl->load('menu/bottom', [$items, 'html-id' => 'menu-regatta', 'title' => 'Regatta-Details', 'height' => 320]);
-
+
$sp['scripts'] .= $scripts->load('onRegattaClicked');
$sp['scripts'] .= $scripts->load('index');
-
-?>
\ No newline at end of file
+
+?>
diff --git a/server/scripts/index.js b/server/scripts/index.js
index cc6d154..a30f36e 100644
--- a/server/scripts/index.js
+++ b/server/scripts/index.js
@@ -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();