diff --git a/client/scripts/regatten.js.php b/client/scripts/regatten.js.php
index d85764a..e09be45 100644
--- a/client/scripts/regatten.js.php
+++ b/client/scripts/regatten.js.php
@@ -131,6 +131,47 @@ function findGetParameter(parameterName) {
return result;
}
+var signup = function() {
+ var username = $('#input-signup-username').val();
+ var email = $('#input-signup-email').val();
+ var password = $('#input-signup-password').val();
+ if (username == '') { $('#input-signup-username').focus(); return; }
+ if (email == '') { $('#input-signup-email').focus(); return; }
+ if (password == '') { $('#input-signup-password').focus(); return; }
+ showLoader();
+ $('#input-signup-username').val('').trigger('focusin').trigger('focusout');
+ $('#input-signup-email').val('').trigger('focusin').trigger('focusout');
+ $('#input-signup-password').val('').trigger('focusin').trigger('focusout');
+ $.ajax({
+ url: QUERY_URL + 'signup',
+ method: 'POST',
+ data: {
+ username: username,
+ email: email,
+ password: password
+ },
+ error: function (xhr, status, error) {
+ if (xhr.status == 409) {
+ toastError('Benutzername bereits vergeben');
+ $('#input-signup-email').val(email).trigger('focusin').trigger('focusout');
+ } else if (xhr.status == 0) {
+ toastError('Du bist momentan offline.
Stelle eine Internetverbindung her, um Dich anzumelden');
+ $('#menu-signup').hideMenu();
+ } else {
+ log('[app] Signup: unbekannter Fehler', status, error);
+ log(xhr);
+ toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
+ }
+ hideLoader();
+ },
+ success: function (data, status, xhr) {
+ $('#input-login-username').val(username);
+ $('#input-login-password').val(password);
+ login();
+ }
+ });
+}
+
var login = function() {
showLoader();
var username = $('#input-login-username').val();
@@ -406,6 +447,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..acd380f 100644
--- a/server/content/index.php
+++ b/server/content/index.php
@@ -1,61 +1,72 @@
$_CLASS[name]";
$content .= "
$_CLASS[desc]
";
-
+
$sp['output'] .= $tpl->load('card', [$content]);
-
+
// Favorites
$content = 'Deine Favoriten
';
- $thead = '| Segler | Rangliste |
';
- $content .= $tpl->load('table', [$thead, 'html-id' => 'table-favorites', 'css-class' => 'mb-0 mt-3']);
+ $content .= '';
$content .= '';
$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 +76,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 +89,12 @@
$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]);
-
+
+ // Favorites Menu
+ $items = $tpl->load('menu/item-icon', ['Nicht mehr folgen', '#', 'html-id' => 'menu-item-unfollow', 'icon' => 'fa-heart', 'css-class' => ' border-0']);
+ $sp['menus'] .= $tpl->load('menu/bottom', [$items, 'html-id' => 'menu-favorite', 'title' => 'Favorit', 'height' => 200]);
+
$sp['scripts'] .= $scripts->load('onRegattaClicked');
$sp['scripts'] .= $scripts->load('index');
-
-?>
\ No newline at end of file
+
+?>
diff --git a/server/content/sailors.php b/server/content/sailors.php
index 29e65f6..42858e7 100644
--- a/server/content/sailors.php
+++ b/server/content/sailors.php
@@ -1,14 +1,14 @@
Segler";
-
+
$sp['output'] .= $tpl->load('card', [$content]);
-
+
// Info Years
$content = 'Jahrgänge
';
$content .= '';
@@ -17,30 +17,32 @@
$content .= 'Klicke dazu einfach auf den entsprechenden Segler und wähle Jahrgang bearbeiten aus.
';
$content .= 'Vielen Dank für Deine Unterstützung!';
$content .= '
';
-
+
$sp['output'] .= $tpl->load('card', [$content]);
-
+
// List
$content = '';
$content .= $tpl->load('input', ['html-id' => 'input-search', 'placeholder' => 'Suche', 'type' => 'text', 'css-class' => 'mt-2']);
$content .= '';
-
+
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-list']);
-
+
// Pagination
$sp['output'] .= $tpl->load('pagination', ['html-id' => 'pagination']);
-
+
// Menu
- $items = $tpl->load('menu/item-icon', ['', '#', 'html-id' => 'menu-item-year', 'icon' => 'fa-edit']);
+ $items = $tpl->load('menu/item-switch', ['Favorit', 'html-id' => 'menu-item-follow', 'icon' => 'fa-heart']);
+ $items .= $tpl->load('menu/item-icon-badge', ['Favorit', '#', 'html-id' => 'menu-item-follow-disabled', 'icon' => 'fa-heart', 'badge-value' => 'MAX REACHED']);
+ $items .= $tpl->load('menu/item-icon', ['', '#', 'html-id' => 'menu-item-year', 'icon' => 'fa-edit']);
$items .= $tpl->load('menu/item-icon', ['Vereins-Website', '', 'html-id' => 'menu-item-clubwebsite', 'icon' => 'fa-globe', 'css-class' => 'border-0']);
- $sp['menus'] .= $tpl->load('menu/bottom', [$items, 'html-id' => 'menu-sailor', 'title' => 'Segler-Details', 'height' => 200]);
-
+ $sp['menus'] .= $tpl->load('menu/bottom', [$items, 'html-id' => 'menu-sailor', 'title' => 'Segler-Details', 'height' => 260]);
+
$items = 'Bitte trage hier den Jahrgang ein:
';
$items .= $tpl->load('input', ['html-id' => 'input-edityear', 'placeholder' => 'Jahrgang', 'type' => 'number']);
$items .= $tpl->load('button', ['Speichern', '#', 'html-id' => 'button-edityear']);
$sp['menus'] .= $tpl->load('menu/bottom', [$items, 'html-id' => 'menu-edityear', 'height' => 240]);
-
+
$sp['scripts'] .= $scripts->load('pagination', ['pageChange', 'page', 'pageCount', 'pagination']);
$sp['scripts'] .= $scripts->load('sailors');
-
-?>
\ No newline at end of file
+
+?>
diff --git a/server/page/menus.php b/server/page/menus.php
index 30917c2..0b1374e 100644
--- a/server/page/menus.php
+++ b/server/page/menus.php
@@ -245,7 +245,7 @@
-';
}
- $('#table-favorites').find('tbody').html(tbody);
+ $('#div-favorites').html(list);
$('#p-favorites').hide();
- $('#table-favorites').show();
+ $('#div-favorites').show();
} else {
- $('#table-favorites').hide();
+ $('#div-favorites').hide();
$('#p-favorites').show();
}
$('#card-favorites').show();
diff --git a/server/scripts/sailors.js b/server/scripts/sailors.js
index d3da25b..3f088ea 100644
--- a/server/scripts/sailors.js
+++ b/server/scripts/sailors.js
@@ -4,6 +4,40 @@ var displayed = [];
var page = 1;
var pageCount = 0;
const showCount = 25;
+var followedSailors = [];
+
+async function onFollowChange() {
+ var id = $('#menu-item-follow').attr('data-sailor-id');
+ showLoader();
+ $('#menu-sailor').hideMenu();
+ var auth = {
+ id: localStorage.getItem('auth_id'),
+ hash: localStorage.getItem('auth_hash')
+ }
+ $.ajax({
+ url: QUERY_URL + ($('#menu-item-follow').prop('checked') ? 'sailor_follow' : 'sailor_unfollow'),
+ method: 'POST',
+ data: {
+ auth: auth,
+ sailor: id
+ },
+ error: function (xhr, status, error) {
+ if (xhr.status == 0) {
+ toastError('Du bist momentan offline.
Stelle eine Internetverbindung her, um Deine Favoriten zu bearbeiten.');
+ } else {
+ log('Un/Follow: unbekannter Fehler', status, error);
+ log(xhr);
+ toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
+ }
+ hideLoader();
+ },
+ success: async function (data, status, xhr) {
+ await sync();
+ toastOk('Erfolgreich');
+ hideLoader();
+ }
+ });
+}
async function onEditYearClick() {
var id = $('#button-edityear').attr('data-sailor-id');
@@ -50,6 +84,26 @@ async function onListClicked(id) {
$('#menu-sailor').find('.menu-title').find('p').text(sailor.name);
+ // Follow
+ if (isLoggedIn()) {
+ var found = false;
+ for (var i in followedSailors) {
+ if (followedSailors[i].id == sailor.id) found = true;
+ }
+ if (found || (followedSailors.length < 5)) {
+ $('#menu-item-follow').attr('data-sailor-id', sailor.id);
+ $('#menu-item-follow').prop('checked', found);
+ $('#menu-item-follow').parent().parent().show();
+ $('#menu-item-follow-disabled').hide();
+ } else {
+ $('#menu-item-follow').parent().parent().hide();
+ $('#menu-item-follow-disabled').show();
+ }
+ } else {
+ $('#menu-item-follow').parent().parent().hide();
+ $('#menu-item-follow-disabled').hide();
+ }
+
// Edit Year
$('#button-edityear').attr('data-sailor-id', sailor.id);
$('#menu-edityear').find('.menu-title').find('p').text(sailor.name);
@@ -134,6 +188,19 @@ var siteScript = async function() {
$('#input-search').on('input', reSearch);
$('#menu-item-year').click(function(){ $('#menu-sailor').hideMenu(); $('#menu-edityear').showMenu(); });
$('#button-edityear').click(onEditYearClick);
+ $('#menu-item-follow').parent().parent().click(onFollowChange);
+ $('#menu-item-follow-disabled').click(function(){ $('#menu-sailor').hideMenu(); toastInfo('Du kannst maximal 5 Seglern folgen. Entferne erst einen Segler aus Deinen Favoriten, bevor Du andere aufnimmst.', 5000); });
+ }
+
+ if (isLoggedIn()) {
+ var user = await dbGetData('users', USER_ID);
+ followedSailors = [];
+ for (var i = 1; i <= 5; i ++) {
+ sailor_id = user['sailor' + i];
+ if (sailor_id != null) {
+ followedSailors.push(await dbGetData('sailors', sailor_id));
+ }
+ }
}
var results = await dbGetData('sailors');
diff --git a/server/version.php b/server/version.php
index 0088a87..1e590fc 100644
--- a/server/version.php
+++ b/server/version.php
@@ -1,5 +1,5 @@