Compare commits
113 Commits
v_1.5
...
remote_log
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fa4770e12a | ||
|
|
a6f2568753 | ||
|
|
6d0fdea0e8 | ||
|
|
1252c02d7c | ||
|
|
f617fa7923 | ||
|
|
c66dc96598 | ||
|
|
f5d059202e | ||
|
|
5962e1cc90 | ||
|
|
9f3019b4c5 | ||
|
|
326ba4a6bd | ||
|
|
4228ec739d | ||
|
|
a38c48dab4 | ||
|
|
da48e79a36 | ||
|
|
de5abcdfaf | ||
|
|
6b1e35cc14 | ||
|
|
89e24f69b7 | ||
|
|
554b810e85 | ||
|
|
fbd1eaaae8 | ||
|
|
ce42f87227 | ||
|
|
e66f95ff50 | ||
|
|
fcd791ed65 | ||
|
|
439679bbbe | ||
|
|
9a8d6892f2 | ||
|
|
3b71f3d707 | ||
|
|
94c6a42106 | ||
|
|
0c9eb9c013 | ||
|
|
2034e8b659 | ||
|
|
e57bf4a426 | ||
|
|
3c8289d11c | ||
|
|
63de725ebd | ||
|
|
69efb93646 | ||
|
|
6f302d6527 | ||
|
|
bfc2f84f0f | ||
|
|
0660b2b6b3 | ||
|
|
3ee722f6c2 | ||
|
|
0ce58aeacc | ||
|
|
28ba380cca | ||
|
|
357449c1c6 | ||
|
|
e84eaa2562 | ||
|
|
de70522850 | ||
|
|
cf5f71d14e | ||
|
|
775a7bd27a | ||
|
|
34b47e40ab | ||
|
|
32ea581437 | ||
|
|
4106a177f8 | ||
|
|
16ccbca2af | ||
|
|
3fd9beae1e | ||
|
|
01d0ae96f9 | ||
|
|
c211817f78 | ||
|
|
9ff0b96837 | ||
|
|
7a3413b339 | ||
|
|
72ff731694 | ||
|
|
3959b208b5 | ||
|
|
7b500bf67d | ||
|
|
5c8c9db1de | ||
|
|
fa526b11a8 | ||
|
|
2dc2225263 | ||
|
|
fcf9dc9a20 | ||
|
|
203c2534eb | ||
|
|
730dd9112f | ||
|
|
13ceef37d9 | ||
|
|
54852f4383 | ||
|
|
8808d12bf1 | ||
|
|
c6d5450b0e | ||
|
|
15cbe15651 | ||
|
|
cb8a1817ae | ||
|
|
acf51ea71c | ||
|
|
be98511957 | ||
|
|
65608cdd5a | ||
|
|
d0996fa0c3 | ||
|
|
c9a90eb77c | ||
|
|
754cb6f77d | ||
|
|
5e926f3e75 | ||
|
|
138071769c | ||
|
|
26d9d83ba2 | ||
|
|
eaa08ba301 | ||
|
|
760c05286e | ||
|
|
3f676141d7 | ||
|
|
ae9bf02c49 | ||
|
|
c2a482bba1 | ||
|
|
06266b788d | ||
|
|
3db5ae1723 | ||
|
|
a45af73c25 | ||
|
|
b784733b69 | ||
|
|
f30eac8aa5 | ||
|
|
99b624ff92 | ||
|
|
e74ffa9a70 | ||
|
|
cbb398988d | ||
|
|
856f6c1d66 | ||
|
|
2ea26408be | ||
|
|
fb1ca6d28e | ||
|
|
6a5d06325d | ||
|
|
72ac8df460 | ||
|
|
246231fd0e | ||
|
|
3e533f65fc | ||
|
|
2533c3d66a | ||
|
|
cacee5a54a | ||
|
|
274aa85cf7 | ||
|
|
4317e4fe87 | ||
|
|
b7dec825ca | ||
|
|
6ca6a79dc3 | ||
|
|
d1e5d753b4 | ||
|
|
7afacc3fff | ||
|
|
77ea57d643 | ||
|
|
a72c462483 | ||
|
|
b739e6cc4e | ||
|
|
eb47cdf016 | ||
|
|
12c1a614bb | ||
|
|
0fb1bb0462 | ||
|
|
1b1176b952 | ||
|
|
00c1c93b80 | ||
|
|
876776eb5b | ||
|
|
a92dc45bb7 |
20
.github/ISSUE_TEMPLATE/-de--feature-anfrage.md
vendored
Normal file
20
.github/ISSUE_TEMPLATE/-de--feature-anfrage.md
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
name: "[DE] Feature-Anfrage"
|
||||||
|
about: Schlage eine Idee für dieses Projekt vor
|
||||||
|
title: ''
|
||||||
|
labels: enhancement
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Bezieht sich Deine Feature-Anfrage auf ein Problem? Bitte beschreiben.**
|
||||||
|
Eine klare und präzise Beschreibung des Problems. Z.B. Ich bin immer frustriert, wenn [...]
|
||||||
|
|
||||||
|
**Beschreibe die gewünschte Lösung**
|
||||||
|
Eine klare und präzise Beschreibung dessen, was passieren soll.
|
||||||
|
|
||||||
|
**Beschreibe Alternativen, die Du in Betracht gezogen hast**
|
||||||
|
Eine klare und präzise Beschreibung aller alternativen Lösungen oder Funktionen, die Du in Betracht gezogen hast.
|
||||||
|
|
||||||
|
**Zusätzlicher Kontext**
|
||||||
|
Füge hier weitere Kontexte oder Screenshots zur Feature-Anfrage hinzu.
|
||||||
38
.github/ISSUE_TEMPLATE/-de--fehlerbericht.md
vendored
Normal file
38
.github/ISSUE_TEMPLATE/-de--fehlerbericht.md
vendored
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
---
|
||||||
|
name: "[DE] Fehlerbericht"
|
||||||
|
about: Erstelle einen Bericht, um uns zu helfen, die App zu verbessern
|
||||||
|
title: ''
|
||||||
|
labels: bug
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Beschreibe den Fehler**
|
||||||
|
Eine klare und präzise Beschreibung des Fehlers.
|
||||||
|
|
||||||
|
**Reproduzierung**
|
||||||
|
Schritte zum Reproduzieren des Fehlers:
|
||||||
|
1. Gehe zu '...'
|
||||||
|
2. Klicke auf '....'
|
||||||
|
3. Scrolle nach unten zu '....'
|
||||||
|
4. Sieh den Fehler
|
||||||
|
|
||||||
|
**Erwartetes Verhalten**
|
||||||
|
Eine klare und präzise Beschreibung dessen, was Du erwartet hattest.
|
||||||
|
|
||||||
|
**Screenshots**
|
||||||
|
Füge gegebenenfalls Screenshots hinzu, um Dein Problem zu erklären.
|
||||||
|
|
||||||
|
**Desktop (bitte verfolständige die folgenden Informationen):**
|
||||||
|
- Betriebssystem: [z.B. Windows 10]
|
||||||
|
- Browser [z.B. chrome, safari]
|
||||||
|
- Version [z.B. 2.14]
|
||||||
|
|
||||||
|
**Smartphone (bitte verfolständige die folgenden Informationen):**
|
||||||
|
- Gerät: [z.B. iPhone 6]
|
||||||
|
- Betriebssystem: [z.B. iOS 8.1]
|
||||||
|
- Browser [z.B. stock browser, safari]
|
||||||
|
- Version [z.B. 2.14]
|
||||||
|
|
||||||
|
**Zusätzlicher Kontext**
|
||||||
|
Füge hier einen anderen Kontext zum Problem hinzu.
|
||||||
38
.github/ISSUE_TEMPLATE/-en--bug-report.md
vendored
Normal file
38
.github/ISSUE_TEMPLATE/-en--bug-report.md
vendored
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
---
|
||||||
|
name: "[EN] Bug report"
|
||||||
|
about: Create a report to help us improve
|
||||||
|
title: ''
|
||||||
|
labels: bug
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Describe the bug**
|
||||||
|
A clear and concise description of what the bug is.
|
||||||
|
|
||||||
|
**To Reproduce**
|
||||||
|
Steps to reproduce the behavior:
|
||||||
|
1. Go to '...'
|
||||||
|
2. Click on '....'
|
||||||
|
3. Scroll down to '....'
|
||||||
|
4. See error
|
||||||
|
|
||||||
|
**Expected behavior**
|
||||||
|
A clear and concise description of what you expected to happen.
|
||||||
|
|
||||||
|
**Screenshots**
|
||||||
|
If applicable, add screenshots to help explain your problem.
|
||||||
|
|
||||||
|
**Desktop (please complete the following information):**
|
||||||
|
- OS: [e.g. Windows 10]
|
||||||
|
- Browser [e.g. chrome, safari]
|
||||||
|
- Version [e.g. 2.14]
|
||||||
|
|
||||||
|
**Smartphone (please complete the following information):**
|
||||||
|
- Device: [e.g. iPhone 6]
|
||||||
|
- OS: [e.g. iOS 8.1]
|
||||||
|
- Browser [e.g. stock browser, safari]
|
||||||
|
- Version [e.g. 2.14]
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context about the problem here.
|
||||||
20
.github/ISSUE_TEMPLATE/-en--feature-request.md
vendored
Normal file
20
.github/ISSUE_TEMPLATE/-en--feature-request.md
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
name: "[EN] Feature request"
|
||||||
|
about: Suggest an idea for this project
|
||||||
|
title: ''
|
||||||
|
labels: enhancement
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Is your feature request related to a problem? Please describe.**
|
||||||
|
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||||
|
|
||||||
|
**Describe the solution you'd like**
|
||||||
|
A clear and concise description of what you want to happen.
|
||||||
|
|
||||||
|
**Describe alternatives you've considered**
|
||||||
|
A clear and concise description of any alternative solutions or features you've considered.
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context or screenshots about the feature request here.
|
||||||
11
README.md
Normal file
11
README.md
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# Regatten.net App
|
||||||
|
|
||||||
|
Willkommen im GitHub-Repository unserer neuen Regatten.net App.
|
||||||
|
|
||||||
|
Falls sich jemand dafür interessiert, ist hier der gesamte Quellcode unserer neuen App zu finden.
|
||||||
|
Bitte beachtet, dass diese App einschließlich dem gesamten Quellcode exklusivem Urheberrecht unterliegt. Sie darf also nicht kopiert, verteilt oder verändert werden.
|
||||||
|
Sollte Interesse an einer Anbindung an unser System bestehen, kontaktiere uns bitte einfach (https://regatten.net/contact)
|
||||||
|
|
||||||
|
Der Hauptzweck dieses Repository besteht jedoch darin, Feedback von Euch zu unserer neuen App zu bekommen.
|
||||||
|
Selbstverständlich könnt Ihr uns auch weiterhin auf anderen Kanälen erreichen, doch für Problem-Meldungen und Verbesserungsvorschläge ist GitHub am besten geeignet.
|
||||||
|
Wie Du Teil unseres BETA-Programmes wirst, die App installierst und Feedback gibst, erfährst Du in unserem [Wiki](https://github.com/ostertun/RegattenApp/wiki).
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
|||||||
const DB_VERSION = 4;
|
const DB_VERSION = 6;
|
||||||
|
|
||||||
const USER_ID = localStorage.getItem('auth_user');
|
const USER_ID = localStorage.getItem('auth_user');
|
||||||
const USER_NAME = localStorage.getItem('auth_username');
|
const USER_NAME = localStorage.getItem('auth_username');
|
||||||
@@ -20,11 +20,11 @@ var getJSON = function(url, callback) {
|
|||||||
callback(xhr.status, xhr.response);
|
callback(xhr.status, xhr.response);
|
||||||
};
|
};
|
||||||
xhr.ontimeout = function () {
|
xhr.ontimeout = function () {
|
||||||
console.log("getJSON: timeout");
|
log("[db] getJSON: timeout");
|
||||||
callback(0, null);
|
callback(0, null);
|
||||||
}
|
}
|
||||||
xhr.onerror = function () {
|
xhr.onerror = function () {
|
||||||
console.log("getJSON: error");
|
log("[db] getJSON: error");
|
||||||
callback(0, null);
|
callback(0, null);
|
||||||
}
|
}
|
||||||
if (USER_ID != null) {
|
if (USER_ID != null) {
|
||||||
@@ -76,7 +76,7 @@ function dbGetData(table, id = null) {
|
|||||||
if (code == 200) {
|
if (code == 200) {
|
||||||
resolve(data.data);
|
resolve(data.data);
|
||||||
} else {
|
} else {
|
||||||
console.log("Something went wrong (HTTP " + code + ")");
|
log("[db] Something went wrong (HTTP " + code + ")");
|
||||||
fail(strings.error_network, 5000);
|
fail(strings.error_network, 5000);
|
||||||
resolve([]);
|
resolve([]);
|
||||||
}
|
}
|
||||||
@@ -86,7 +86,7 @@ function dbGetData(table, id = null) {
|
|||||||
if (code == 200) {
|
if (code == 200) {
|
||||||
resolve(data.data);
|
resolve(data.data);
|
||||||
} else {
|
} else {
|
||||||
console.log("Something went wrong (HTTP " + code + ")");
|
log("[db] Something went wrong (HTTP " + code + ")");
|
||||||
fail(strings.error_network, 5000);
|
fail(strings.error_network, 5000);
|
||||||
resolve(null);
|
resolve(null);
|
||||||
}
|
}
|
||||||
@@ -108,7 +108,7 @@ function dbGetDataIndex(table, indexName, value) {
|
|||||||
if (code == 200) {
|
if (code == 200) {
|
||||||
resolve(data.data);
|
resolve(data.data);
|
||||||
} else {
|
} else {
|
||||||
console.log("Something went wrong (HTTP " + code + ")");
|
log("[db] Something went wrong (HTTP " + code + ")");
|
||||||
fail(strings.error_network, 5000);
|
fail(strings.error_network, 5000);
|
||||||
resolve([]);
|
resolve([]);
|
||||||
}
|
}
|
||||||
@@ -397,32 +397,55 @@ function dbGetRanking(minDate, maxDate, jugend, jugstrict) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function updateSyncStatus() { // TODO
|
function dbSettingsGet(key) {
|
||||||
// var syncStatus = document.getElementById('syncstatus');
|
return new Promise(function(resolve) {
|
||||||
// var lastSync = await dbGetData('update_times', 'last_sync');
|
if (canUseLocalDB) {
|
||||||
// lastSync = new Date(lastSync.time * 1000);
|
var request = db.transaction('settings').objectStore('settings').get(key);
|
||||||
// var now = new Date();
|
request.onsuccess = function (event) {
|
||||||
// var diff = Math.round((now - lastSync) / 1000);
|
resolve(typeof request.result != 'undefined' ? request.result.value : null);
|
||||||
// var txt = '';
|
}
|
||||||
//
|
} else {
|
||||||
// if (diff < 30) { // 30 sec
|
resolve(null);
|
||||||
// txt = 'jetzt';
|
}
|
||||||
// } else if (diff < 3600) { // 60 min
|
});
|
||||||
// diff = Math.round(diff / 60);
|
}
|
||||||
// txt = 'vor ' + diff + ' ' + (diff == 1 ? 'Minute' : 'Minuten');
|
|
||||||
// } else if (diff < 86400) { // 24 std
|
function dbSettingsSet(key, value) {
|
||||||
// diff = Math.round(diff / 3600);
|
if (canUseLocalDB) {
|
||||||
// txt = 'vor ' + diff + ' ' + (diff == 1 ? 'Stunde' : 'Stunden');
|
var os = db.transaction('settings', 'readwrite').objectStore('settings');
|
||||||
// } else {
|
os.put({ key: key, value: value});
|
||||||
// diff = Math.round(diff / 86400);
|
}
|
||||||
// txt = 'vor ' + diff + ' ' + (diff == 1 ? 'Tag' : 'Tagen');
|
}
|
||||||
// }
|
|
||||||
//
|
async function updateSyncStatus() {
|
||||||
// var btn = '<a href="#" onclick="setLoading(true); sync(); return false;"><i class="fas fa-sync"></i> Sync</a>';
|
var lastSync = await dbGetData('update_times', 'last_sync');
|
||||||
// syncStatus.innerHTML = 'Zuletzt aktualisiert: ' + txt + btn;
|
lastSync = new Date(lastSync.time * 1000);
|
||||||
|
if (lastSync > 0) {
|
||||||
|
var now = new Date();
|
||||||
|
var diff = Math.round((now - lastSync) / 1000);
|
||||||
|
var txt = '';
|
||||||
|
|
||||||
|
if (diff < 30) { // 30 sec
|
||||||
|
txt = 'jetzt';
|
||||||
|
} else if (diff < 3600) { // 60 min
|
||||||
|
diff = Math.round(diff / 60);
|
||||||
|
txt = 'vor ' + diff + ' ' + (diff == 1 ? 'Minute' : 'Minuten');
|
||||||
|
} else if (diff < 86400) { // 24 std
|
||||||
|
diff = Math.round(diff / 3600);
|
||||||
|
txt = 'vor ' + diff + ' ' + (diff == 1 ? 'Stunde' : 'Stunden');
|
||||||
|
} else {
|
||||||
|
diff = Math.round(diff / 86400);
|
||||||
|
txt = 'vor ' + diff + ' ' + (diff == 1 ? 'Tag' : 'Tagen');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var txt = 'nie';
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#syncstatus').html('Zuletzt aktualisiert: ' + txt);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function runPageScript() {
|
async function runPageScript() {
|
||||||
|
log('[db] running page script...')
|
||||||
if (canUseLocalDB) {
|
if (canUseLocalDB) {
|
||||||
var osUpdateTimes = db.transaction('update_times').objectStore('update_times');
|
var osUpdateTimes = db.transaction('update_times').objectStore('update_times');
|
||||||
osUpdateTimes.get('loggedin').onsuccess = function (event) {
|
osUpdateTimes.get('loggedin').onsuccess = function (event) {
|
||||||
@@ -433,22 +456,28 @@ async function runPageScript() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
updateSyncStatus();
|
updateSyncStatus();
|
||||||
|
|
||||||
|
if (isLoggedIn()) {
|
||||||
|
var plannings = await dbGetDataIndex('plannings', 'user', USER_ID);
|
||||||
|
plannings = plannings.map(function (e) { return e.regatta; });
|
||||||
|
dbSettingsSet('myregattas_' + BOATCLASS, plannings);
|
||||||
}
|
}
|
||||||
if (typeof updateSyncStatusTimer == 'undefined') { // TODO
|
}
|
||||||
// var syncStatus = document.getElementById('syncstatus');
|
if (typeof updateSyncStatusTimer == 'undefined') {
|
||||||
if (canUseLocalDB) {
|
if (canUseLocalDB) {
|
||||||
updateSyncStatusTimer = window.setInterval(updateSyncStatus, 10000);
|
updateSyncStatusTimer = window.setInterval(updateSyncStatus, 10000);
|
||||||
} else {
|
} else {
|
||||||
// syncStatus.innerHTML = 'Keine Offline-Nutzung möglich.';
|
$('#syncstatus').html('Keine Offline-Nutzung möglich.');
|
||||||
$('#i-sync').parent().hide();
|
$('#i-sync').parent().hide();
|
||||||
updateSyncStatusTimer = null;
|
updateSyncStatusTimer = null;
|
||||||
}
|
}
|
||||||
// syncStatus.style.display = 'block';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof siteScript === 'function') {
|
if (typeof siteScript === 'function') {
|
||||||
|
log('[db] loading site script');
|
||||||
siteScript();
|
siteScript();
|
||||||
} else {
|
} else {
|
||||||
|
log('[db] no site script');
|
||||||
hideLoader();
|
hideLoader();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -457,6 +486,7 @@ function sync() {
|
|||||||
if (!canUseLocalDB) return false;
|
if (!canUseLocalDB) return false;
|
||||||
if (syncInProgress > 0) return false;
|
if (syncInProgress > 0) return false;
|
||||||
|
|
||||||
|
return new Promise(function(resolve) {
|
||||||
var now = Math.floor(Date.now() / 1000);
|
var now = Math.floor(Date.now() / 1000);
|
||||||
|
|
||||||
db.transaction('update_times').objectStore('update_times').getAll().onsuccess = function (event) {
|
db.transaction('update_times').objectStore('update_times').getAll().onsuccess = function (event) {
|
||||||
@@ -465,9 +495,9 @@ function sync() {
|
|||||||
localTimes[entry['table']] = entry['time'];
|
localTimes[entry['table']] = entry['time'];
|
||||||
});
|
});
|
||||||
|
|
||||||
syncInProgress = 10;
|
syncInProgress = 11;
|
||||||
var syncOkay = true;
|
var syncOkay = true;
|
||||||
console.log("Sync Start");
|
log("[db] Sync Start");
|
||||||
$('#i-sync').addClass('fa-spin');
|
$('#i-sync').addClass('fa-spin');
|
||||||
|
|
||||||
var interval = window.setInterval(function () {
|
var interval = window.setInterval(function () {
|
||||||
@@ -477,12 +507,18 @@ function sync() {
|
|||||||
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
||||||
osUpdateTimes.put({ table: 'last_sync', time: now });
|
osUpdateTimes.put({ table: 'last_sync', time: now });
|
||||||
}
|
}
|
||||||
console.log("Sync Stop");
|
log("[db] Sync Stop");
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
$('#i-sync').removeClass('fa-spin');
|
$('#i-sync').removeClass('fa-spin');
|
||||||
}, 500);
|
}, 500);
|
||||||
|
|
||||||
|
if (typeof onAfterSync === 'function') {
|
||||||
|
onAfterSync();
|
||||||
|
}
|
||||||
|
removeSyncInfoToPreloader();
|
||||||
|
showLoader();
|
||||||
runPageScript();
|
runPageScript();
|
||||||
|
resolve();
|
||||||
}
|
}
|
||||||
}, 100);
|
}, 100);
|
||||||
|
|
||||||
@@ -494,7 +530,6 @@ function sync() {
|
|||||||
getJSON(QUERY_URL + 'get_clubs?changed-after=' + localTimes['clubs'], function (code, data) {
|
getJSON(QUERY_URL + 'get_clubs?changed-after=' + localTimes['clubs'], function (code, data) {
|
||||||
if (code == 200) {
|
if (code == 200) {
|
||||||
var os = db.transaction('clubs', 'readwrite').objectStore('clubs');
|
var os = db.transaction('clubs', 'readwrite').objectStore('clubs');
|
||||||
console.log(data);
|
|
||||||
data.data.forEach(function (entry) {
|
data.data.forEach(function (entry) {
|
||||||
os.put(entry);
|
os.put(entry);
|
||||||
});
|
});
|
||||||
@@ -509,12 +544,14 @@ function sync() {
|
|||||||
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
||||||
osUpdateTimes.put({ table: 'clubs', time: serverTimes['clubs'] });
|
osUpdateTimes.put({ table: 'clubs', time: serverTimes['clubs'] });
|
||||||
syncInProgress --;
|
syncInProgress --;
|
||||||
|
log('[db] clubs synced, remaining:', syncInProgress);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
console.log("Something went wrong (HTTP " + code + ")");
|
log("[db] clubs: Something went wrong (HTTP " + code + ")");
|
||||||
syncOkay = false;
|
syncOkay = false;
|
||||||
syncInProgress --;
|
syncInProgress --;
|
||||||
|
log('[db] clubs failed, remaining:', syncInProgress);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -526,7 +563,6 @@ function sync() {
|
|||||||
getJSON(QUERY_URL + 'get_boats?changed-after=' + localTimes['boats'], function (code, data) {
|
getJSON(QUERY_URL + 'get_boats?changed-after=' + localTimes['boats'], function (code, data) {
|
||||||
if (code == 200) {
|
if (code == 200) {
|
||||||
var os = db.transaction('boats', 'readwrite').objectStore('boats');
|
var os = db.transaction('boats', 'readwrite').objectStore('boats');
|
||||||
console.log(data);
|
|
||||||
data.data.forEach(function (entry) {
|
data.data.forEach(function (entry) {
|
||||||
os.put(entry);
|
os.put(entry);
|
||||||
});
|
});
|
||||||
@@ -541,12 +577,14 @@ function sync() {
|
|||||||
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
||||||
osUpdateTimes.put({ table: 'boats', time: serverTimes['boats'] });
|
osUpdateTimes.put({ table: 'boats', time: serverTimes['boats'] });
|
||||||
syncInProgress --;
|
syncInProgress --;
|
||||||
|
log('[db] boats synced, remaining:', syncInProgress);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
console.log("Something went wrong (HTTP " + code + ")");
|
log("[db] boats: Something went wrong (HTTP " + code + ")");
|
||||||
syncOkay = false;
|
syncOkay = false;
|
||||||
syncInProgress --;
|
syncInProgress --;
|
||||||
|
log('[db] boats failed, remaining:', syncInProgress);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -558,7 +596,6 @@ function sync() {
|
|||||||
getJSON(QUERY_URL + 'get_sailors?changed-after=' + localTimes['sailors'], function (code, data) {
|
getJSON(QUERY_URL + 'get_sailors?changed-after=' + localTimes['sailors'], function (code, data) {
|
||||||
if (code == 200) {
|
if (code == 200) {
|
||||||
var os = db.transaction('sailors', 'readwrite').objectStore('sailors');
|
var os = db.transaction('sailors', 'readwrite').objectStore('sailors');
|
||||||
console.log(data);
|
|
||||||
data.data.forEach(function (entry) {
|
data.data.forEach(function (entry) {
|
||||||
os.put(entry);
|
os.put(entry);
|
||||||
});
|
});
|
||||||
@@ -573,12 +610,14 @@ function sync() {
|
|||||||
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
||||||
osUpdateTimes.put({ table: 'sailors', time: serverTimes['sailors'] });
|
osUpdateTimes.put({ table: 'sailors', time: serverTimes['sailors'] });
|
||||||
syncInProgress --;
|
syncInProgress --;
|
||||||
|
log('[db] sailors synced, remaining:', syncInProgress);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
console.log("Something went wrong (HTTP " + code + ")");
|
log("[db] sailors: Something went wrong (HTTP " + code + ")");
|
||||||
syncOkay = false;
|
syncOkay = false;
|
||||||
syncInProgress --;
|
syncInProgress --;
|
||||||
|
log('[db] sailors failed, remaining:', syncInProgress);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -590,7 +629,6 @@ function sync() {
|
|||||||
getJSON(QUERY_URL + 'get_regattas?changed-after=' + localTimes['regattas'], function (code, data) {
|
getJSON(QUERY_URL + 'get_regattas?changed-after=' + localTimes['regattas'], function (code, data) {
|
||||||
if (code == 200) {
|
if (code == 200) {
|
||||||
var os = db.transaction('regattas', 'readwrite').objectStore('regattas');
|
var os = db.transaction('regattas', 'readwrite').objectStore('regattas');
|
||||||
console.log(data);
|
|
||||||
data.data.forEach(function (entry) {
|
data.data.forEach(function (entry) {
|
||||||
os.put(entry);
|
os.put(entry);
|
||||||
});
|
});
|
||||||
@@ -621,12 +659,14 @@ function sync() {
|
|||||||
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
||||||
osUpdateTimes.put({ table: 'regattas', time: serverTimes['regattas'] });
|
osUpdateTimes.put({ table: 'regattas', time: serverTimes['regattas'] });
|
||||||
syncInProgress --;
|
syncInProgress --;
|
||||||
|
log('[db] regattas synced, remaining:', syncInProgress);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
console.log("Something went wrong (HTTP " + code + ")");
|
log("[db] regattas: Something went wrong (HTTP " + code + ")");
|
||||||
syncOkay = false;
|
syncOkay = false;
|
||||||
syncInProgress --;
|
syncInProgress --;
|
||||||
|
log('[db] regattas failed, remaining:', syncInProgress);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -638,7 +678,6 @@ function sync() {
|
|||||||
getJSON(QUERY_URL + 'get_results?changed-after=' + localTimes['results'], function (code, data) {
|
getJSON(QUERY_URL + 'get_results?changed-after=' + localTimes['results'], function (code, data) {
|
||||||
if (code == 200) {
|
if (code == 200) {
|
||||||
var os = db.transaction('results', 'readwrite').objectStore('results');
|
var os = db.transaction('results', 'readwrite').objectStore('results');
|
||||||
console.log(data);
|
|
||||||
data.data.forEach(function (entry) {
|
data.data.forEach(function (entry) {
|
||||||
os.put(entry);
|
os.put(entry);
|
||||||
});
|
});
|
||||||
@@ -653,12 +692,14 @@ function sync() {
|
|||||||
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
||||||
osUpdateTimes.put({ table: 'results', time: serverTimes['results'] });
|
osUpdateTimes.put({ table: 'results', time: serverTimes['results'] });
|
||||||
syncInProgress --;
|
syncInProgress --;
|
||||||
|
log('[db] results synced, remaining:', syncInProgress);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
console.log("Something went wrong (HTTP " + code + ")");
|
log("[db] results: Something went wrong (HTTP " + code + ")");
|
||||||
syncOkay = false;
|
syncOkay = false;
|
||||||
syncInProgress --;
|
syncInProgress --;
|
||||||
|
log('[db] results failed, remaining:', syncInProgress);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -670,7 +711,6 @@ function sync() {
|
|||||||
getJSON(QUERY_URL + 'get_plannings?changed-after=' + localTimes['plannings'], function (code, data) {
|
getJSON(QUERY_URL + 'get_plannings?changed-after=' + localTimes['plannings'], function (code, data) {
|
||||||
if (code == 200) {
|
if (code == 200) {
|
||||||
var os = db.transaction('plannings', 'readwrite').objectStore('plannings');
|
var os = db.transaction('plannings', 'readwrite').objectStore('plannings');
|
||||||
console.log(data);
|
|
||||||
data.data.forEach(function (entry) {
|
data.data.forEach(function (entry) {
|
||||||
os.put(entry);
|
os.put(entry);
|
||||||
});
|
});
|
||||||
@@ -685,12 +725,14 @@ function sync() {
|
|||||||
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
||||||
osUpdateTimes.put({ table: 'plannings', time: serverTimes['plannings'] });
|
osUpdateTimes.put({ table: 'plannings', time: serverTimes['plannings'] });
|
||||||
syncInProgress --;
|
syncInProgress --;
|
||||||
|
log('[db] plannings synced, remaining:', syncInProgress);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
console.log("Something went wrong (HTTP " + code + ")");
|
log("[db] plannings: Something went wrong (HTTP " + code + ")");
|
||||||
syncOkay = false;
|
syncOkay = false;
|
||||||
syncInProgress --;
|
syncInProgress --;
|
||||||
|
log('[db] plannings failed, remaining:', syncInProgress);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -703,7 +745,6 @@ function sync() {
|
|||||||
getJSON(QUERY_URL + 'get_trim_boats?changed-after=' + localTimes['trim_boats'], function (code, data) {
|
getJSON(QUERY_URL + 'get_trim_boats?changed-after=' + localTimes['trim_boats'], function (code, data) {
|
||||||
if (code == 200) {
|
if (code == 200) {
|
||||||
var os = db.transaction('trim_boats', 'readwrite').objectStore('trim_boats');
|
var os = db.transaction('trim_boats', 'readwrite').objectStore('trim_boats');
|
||||||
console.log(data);
|
|
||||||
data.data.forEach(function (entry) {
|
data.data.forEach(function (entry) {
|
||||||
os.put(entry);
|
os.put(entry);
|
||||||
});
|
});
|
||||||
@@ -718,12 +759,14 @@ function sync() {
|
|||||||
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
||||||
osUpdateTimes.put({ table: 'trim_boats', time: serverTimes['trim_boats'] });
|
osUpdateTimes.put({ table: 'trim_boats', time: serverTimes['trim_boats'] });
|
||||||
syncInProgress --;
|
syncInProgress --;
|
||||||
|
log('[db] trim_boats synced, remaining:', syncInProgress);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
console.log("Something went wrong (HTTP " + code + ")");
|
log("[db] trim_boats: Something went wrong (HTTP " + code + ")");
|
||||||
syncOkay = false;
|
syncOkay = false;
|
||||||
syncInProgress --;
|
syncInProgress --;
|
||||||
|
log('[db] trim_boats failed, remaining:', syncInProgress);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -735,7 +778,6 @@ function sync() {
|
|||||||
getJSON(QUERY_URL + 'get_trim_users?changed-after=' + localTimes['trim_users'], function (code, data) {
|
getJSON(QUERY_URL + 'get_trim_users?changed-after=' + localTimes['trim_users'], function (code, data) {
|
||||||
if (code == 200) {
|
if (code == 200) {
|
||||||
var os = db.transaction('trim_users', 'readwrite').objectStore('trim_users');
|
var os = db.transaction('trim_users', 'readwrite').objectStore('trim_users');
|
||||||
console.log(data);
|
|
||||||
data.data.forEach(function (entry) {
|
data.data.forEach(function (entry) {
|
||||||
os.put(entry);
|
os.put(entry);
|
||||||
});
|
});
|
||||||
@@ -750,12 +792,14 @@ function sync() {
|
|||||||
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
||||||
osUpdateTimes.put({ table: 'trim_users', time: serverTimes['trim_users'] });
|
osUpdateTimes.put({ table: 'trim_users', time: serverTimes['trim_users'] });
|
||||||
syncInProgress --;
|
syncInProgress --;
|
||||||
|
log('[db] trim_users synced, remaining:', syncInProgress);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
console.log("Something went wrong (HTTP " + code + ")");
|
log("[db] trim_users: Something went wrong (HTTP " + code + ")");
|
||||||
syncOkay = false;
|
syncOkay = false;
|
||||||
syncInProgress --;
|
syncInProgress --;
|
||||||
|
log('[db] trim_users failed, remaining:', syncInProgress);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -767,7 +811,6 @@ function sync() {
|
|||||||
getJSON(QUERY_URL + 'get_trim_trims?changed-after=' + localTimes['trim_trims'], function (code, data) {
|
getJSON(QUERY_URL + 'get_trim_trims?changed-after=' + localTimes['trim_trims'], function (code, data) {
|
||||||
if (code == 200) {
|
if (code == 200) {
|
||||||
var os = db.transaction('trim_trims', 'readwrite').objectStore('trim_trims');
|
var os = db.transaction('trim_trims', 'readwrite').objectStore('trim_trims');
|
||||||
console.log(data);
|
|
||||||
data.data.forEach(function (entry) {
|
data.data.forEach(function (entry) {
|
||||||
os.put(entry);
|
os.put(entry);
|
||||||
});
|
});
|
||||||
@@ -782,12 +825,14 @@ function sync() {
|
|||||||
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
||||||
osUpdateTimes.put({ table: 'trim_trims', time: serverTimes['trim_trims'] });
|
osUpdateTimes.put({ table: 'trim_trims', time: serverTimes['trim_trims'] });
|
||||||
syncInProgress --;
|
syncInProgress --;
|
||||||
|
log('[db] trim_trims synced, remaining:', syncInProgress);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
console.log("Something went wrong (HTTP " + code + ")");
|
log("[db] trim_trims: Something went wrong (HTTP " + code + ")");
|
||||||
syncOkay = false;
|
syncOkay = false;
|
||||||
syncInProgress --;
|
syncInProgress --;
|
||||||
|
log('[db] trim_trims failed, remaining:', syncInProgress);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -798,12 +843,44 @@ function sync() {
|
|||||||
syncInProgress -= 3;
|
syncInProgress -= 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NEWS
|
||||||
|
if (localTimes['news'] < serverTimes['news']) {
|
||||||
|
getJSON(QUERY_URL + 'get_news?changed-after=' + localTimes['news'], function (code, data) {
|
||||||
|
if (code == 200) {
|
||||||
|
var os = db.transaction('news', 'readwrite').objectStore('news');
|
||||||
|
data.data.forEach(function (entry) {
|
||||||
|
os.put(entry);
|
||||||
|
});
|
||||||
|
os.openCursor().onsuccess = function (event) {
|
||||||
|
var cursor = event.target.result;
|
||||||
|
if (cursor) {
|
||||||
|
if (!data.keys.includes(parseInt(cursor.key))) {
|
||||||
|
os.delete(cursor.key);
|
||||||
|
}
|
||||||
|
cursor.continue();
|
||||||
|
} else {
|
||||||
|
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
||||||
|
osUpdateTimes.put({ table: 'news', time: serverTimes['news'] });
|
||||||
|
syncInProgress --;
|
||||||
|
log('[db] news synced, remaining:', syncInProgress);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
log("[db] news: Something went wrong (HTTP " + code + ")");
|
||||||
|
syncOkay = false;
|
||||||
|
syncInProgress --;
|
||||||
|
log('[db] news failed, remaining:', syncInProgress);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
syncInProgress --;
|
||||||
|
}
|
||||||
|
|
||||||
// USERS
|
// USERS
|
||||||
if (localTimes['users'] < serverTimes['users']) {
|
if (localTimes['users'] < serverTimes['users']) {
|
||||||
getJSON(QUERY_URL + 'get_users?changed-after=' + localTimes['users'], function (code, data) {
|
getJSON(QUERY_URL + 'get_users?changed-after=' + localTimes['users'], function (code, data) {
|
||||||
if (code == 200) {
|
if (code == 200) {
|
||||||
var os = db.transaction('users', 'readwrite').objectStore('users');
|
var os = db.transaction('users', 'readwrite').objectStore('users');
|
||||||
console.log(data);
|
|
||||||
data.data.forEach(function (entry) {
|
data.data.forEach(function (entry) {
|
||||||
os.put(entry);
|
os.put(entry);
|
||||||
});
|
});
|
||||||
@@ -818,12 +895,14 @@ function sync() {
|
|||||||
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
||||||
osUpdateTimes.put({ table: 'users', time: serverTimes['users'] });
|
osUpdateTimes.put({ table: 'users', time: serverTimes['users'] });
|
||||||
syncInProgress --;
|
syncInProgress --;
|
||||||
|
log('[db] users synced, remaining:', syncInProgress);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
console.log("Something went wrong (HTTP " + code + ")");
|
log("[db] users: Something went wrong (HTTP " + code + ")");
|
||||||
syncOkay = false;
|
syncOkay = false;
|
||||||
syncInProgress --;
|
syncInProgress --;
|
||||||
|
log('[db] users failed, remaining:', syncInProgress);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -831,12 +910,18 @@ function sync() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
console.log("Something went wrong (HTTP " + code + ")");
|
if (code == 401) {
|
||||||
|
log("[db] Auth invalid. Logout initiated");
|
||||||
|
logoutClearStorage();
|
||||||
|
} else {
|
||||||
|
log("[db] Something went wrong (HTTP " + code + ")");
|
||||||
|
}
|
||||||
syncOkay = false;
|
syncOkay = false;
|
||||||
syncInProgress = 0;
|
syncInProgress = 0;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkSync() {
|
function checkSync() {
|
||||||
@@ -852,15 +937,18 @@ function checkSync() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function initDatabase() {
|
function initDatabase() {
|
||||||
|
log('[db] Initializing DB...');
|
||||||
if (window.indexedDB) {
|
if (window.indexedDB) {
|
||||||
var request = window.indexedDB.open('regatten_app_db_' + BOATCLASS, DB_VERSION);
|
var request = window.indexedDB.open('regatten_app_db_' + BOATCLASS, DB_VERSION);
|
||||||
request.onerror = function (event) {
|
request.onerror = function (event) {
|
||||||
console.log("Cannot open DB: " + event.target.errorCode);
|
log("[db] Cannot open DB: " + event.target);
|
||||||
|
|
||||||
|
if (typeof onDatabaseLoaded == 'function') onDatabaseLoaded();
|
||||||
|
|
||||||
runPageScript();
|
runPageScript();
|
||||||
};
|
};
|
||||||
request.onsuccess = function (event) {
|
request.onsuccess = function (event) {
|
||||||
console.log("Database loaded");
|
log("[db] Database loaded");
|
||||||
db = event.target.result;
|
db = event.target.result;
|
||||||
|
|
||||||
db.onversionchange = function (event) {
|
db.onversionchange = function (event) {
|
||||||
@@ -873,17 +961,21 @@ function initDatabase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
db.onerror = function (event) {
|
db.onerror = function (event) {
|
||||||
console.log("DB Error: " + event.target.errorCode);
|
log("[db] DB Error: " + event.target);
|
||||||
};
|
};
|
||||||
|
|
||||||
canUseLocalDB = true;
|
canUseLocalDB = true;
|
||||||
|
|
||||||
|
if (typeof onDatabaseLoaded == 'function') onDatabaseLoaded();
|
||||||
|
|
||||||
db.transaction('update_times').objectStore('update_times').get('last_sync').onsuccess = function (event) {
|
db.transaction('update_times').objectStore('update_times').get('last_sync').onsuccess = function (event) {
|
||||||
var lastSync = event.target.result.time;
|
var lastSync = event.target.result.time;
|
||||||
if (lastSync > 0) {
|
if (lastSync > 1) {
|
||||||
runPageScript();
|
runPageScript();
|
||||||
} else {
|
} else {
|
||||||
|
if (lastSync < 1) addSyncInfoToPreloader();
|
||||||
db.transaction('update_times', 'readwrite').objectStore('update_times').put({ table: 'loggedin', status: isLoggedIn() });
|
db.transaction('update_times', 'readwrite').objectStore('update_times').put({ table: 'loggedin', status: isLoggedIn() });
|
||||||
|
loaderCount --;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -901,10 +993,10 @@ function initDatabase() {
|
|||||||
var oldVersion = event.oldVersion;
|
var oldVersion = event.oldVersion;
|
||||||
var newVersion = event.newVersion;
|
var newVersion = event.newVersion;
|
||||||
|
|
||||||
console.log("Datenbank Version Upgrade von " + oldVersion + " auf " + newVersion);
|
log("[db] DB Version Upgrade from " + oldVersion + " to " + newVersion);
|
||||||
|
|
||||||
if ((oldVersion < 1) && (newVersion >= 1)) {
|
if ((oldVersion < 1) && (newVersion >= 1)) {
|
||||||
console.log('to version 1');
|
log('[db] to version 1');
|
||||||
var osClubs = db.createObjectStore('clubs', { keyPath: 'id' });
|
var osClubs = db.createObjectStore('clubs', { keyPath: 'id' });
|
||||||
var osBoats = db.createObjectStore('boats', { keyPath: 'id' });
|
var osBoats = db.createObjectStore('boats', { keyPath: 'id' });
|
||||||
var osSailors = db.createObjectStore('sailors', { keyPath: 'id' });
|
var osSailors = db.createObjectStore('sailors', { keyPath: 'id' });
|
||||||
@@ -933,7 +1025,7 @@ function initDatabase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((oldVersion < 2) && (newVersion >= 2)) {
|
if ((oldVersion < 2) && (newVersion >= 2)) {
|
||||||
console.log('to version 2');
|
log('[db] to version 2');
|
||||||
var osUsers = db.createObjectStore('users', { keyPath: 'id' });
|
var osUsers = db.createObjectStore('users', { keyPath: 'id' });
|
||||||
osUsers.createIndex('username', 'username', { unique: true });
|
osUsers.createIndex('username', 'username', { unique: true });
|
||||||
var osUpdateTimes = upgradeTransaction.objectStore('update_times');
|
var osUpdateTimes = upgradeTransaction.objectStore('update_times');
|
||||||
@@ -941,32 +1033,48 @@ function initDatabase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((oldVersion < 3) && (newVersion >= 3)) {
|
if ((oldVersion < 3) && (newVersion >= 3)) {
|
||||||
console.log('to version 3');
|
log('[db] to version 3');
|
||||||
var osYears = db.createObjectStore('years', { keyPath: 'year' });
|
var osYears = db.createObjectStore('years', { keyPath: 'year' });
|
||||||
var osUpdateTimes = upgradeTransaction.objectStore('update_times');
|
var osUpdateTimes = upgradeTransaction.objectStore('update_times');
|
||||||
osUpdateTimes.put({ table: 'regattas', time: 0 });
|
osUpdateTimes.put({ table: 'regattas', time: 0 });
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((oldVersion < 4) && (newVersion >= 4)) {
|
if ((oldVersion < 4) && (newVersion >= 4)) {
|
||||||
console.log('to version 4');
|
log('[db] to version 4');
|
||||||
var osUpdateTimes = upgradeTransaction.objectStore('update_times');
|
var osUpdateTimes = upgradeTransaction.objectStore('update_times');
|
||||||
osUpdateTimes.add({ table: 'loggedin', status: isLoggedIn() });
|
osUpdateTimes.add({ table: 'loggedin', status: isLoggedIn() });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((oldVersion < 5) && (newVersion >= 5)) {
|
||||||
|
log('[db] to version 5');
|
||||||
|
var osPushes = db.createObjectStore('settings', { keyPath: 'key' });
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((oldVersion < 6) && (newVersion >= 6)) {
|
||||||
|
log('[db] to version 6');
|
||||||
|
var osNews = db.createObjectStore('news', { keyPath: 'id' });
|
||||||
var osUpdateTimes = upgradeTransaction.objectStore('update_times');
|
var osUpdateTimes = upgradeTransaction.objectStore('update_times');
|
||||||
osUpdateTimes.put({ table: 'last_sync', time: 0 });
|
osUpdateTimes.add({ table: 'news', time: 0 });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Force resync after db update
|
||||||
|
if (oldVersion >= 1) {
|
||||||
|
var osUpdateTimes = upgradeTransaction.objectStore('update_times');
|
||||||
|
osUpdateTimes.put({ table: 'last_sync', time: 1 });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (typeof onDatabaseLoaded == 'function') onDatabaseLoaded();
|
||||||
|
|
||||||
runPageScript();
|
runPageScript();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetDb(silent = true) {
|
function resetDb() {
|
||||||
$('#menu-developer').hideMenu();
|
|
||||||
if (canUseLocalDB) {
|
if (canUseLocalDB) {
|
||||||
showLoader();
|
showLoader();
|
||||||
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
||||||
osUpdateTimes.put({ table: 'last_sync', time: 0 });
|
osUpdateTimes.put({ table: 'last_sync', time: 1 });
|
||||||
osUpdateTimes.put({ table: 'clubs', time: 0 });
|
osUpdateTimes.put({ table: 'clubs', time: 0 });
|
||||||
osUpdateTimes.put({ table: 'boats', time: 0 });
|
osUpdateTimes.put({ table: 'boats', time: 0 });
|
||||||
osUpdateTimes.put({ table: 'sailors', time: 0 });
|
osUpdateTimes.put({ table: 'sailors', time: 0 });
|
||||||
@@ -976,13 +1084,26 @@ function resetDb(silent = true) {
|
|||||||
osUpdateTimes.put({ table: 'trim_boats', time: 0 });
|
osUpdateTimes.put({ table: 'trim_boats', time: 0 });
|
||||||
osUpdateTimes.put({ table: 'trim_users', time: 0 });
|
osUpdateTimes.put({ table: 'trim_users', time: 0 });
|
||||||
osUpdateTimes.put({ table: 'trim_trims', time: 0 });
|
osUpdateTimes.put({ table: 'trim_trims', time: 0 });
|
||||||
|
osUpdateTimes.put({ table: 'news', time: 0 });
|
||||||
osUpdateTimes.put({ table: 'users', time: 0 });
|
osUpdateTimes.put({ table: 'users', time: 0 });
|
||||||
console.log('DB update times reset');
|
log('[db] DB update times reset');
|
||||||
if (!silent)
|
|
||||||
toastInfo('The database was reset. Please reload or close this tab.<br>At the next visit, a full sync will be performed.');
|
|
||||||
hideLoader();
|
hideLoader();
|
||||||
} else {
|
|
||||||
if (!silent)
|
|
||||||
toastWarn('Your device does not support storing data locally. All data is fetched directly from our server.<br>As a result, you can not reset your database.');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addSyncInfoToPreloader() {
|
||||||
|
var preloader = document.getElementById('preloader');
|
||||||
|
var div = document.createElement('div');
|
||||||
|
div.id = 'preloader-sync-info';
|
||||||
|
div.classList = 'rounded-s shadow-m bg-highlight m-3 p-3';
|
||||||
|
div.style.position = 'fixed';
|
||||||
|
div.style.top = 0;
|
||||||
|
div.style.left = 0;
|
||||||
|
div.style.right = 0;
|
||||||
|
div.innerHTML = '<h2 class="color-white">Datenbank SYNC</h2><p class="mb-0 color-white">Um Dir alle nötigen Informationen anzeigen zu können, müssen wir die Datenbank synchronisieren.<br>Dies kann einen Moment dauern. Bitte habe etwas Geduld. Beim nächsten Öffnen geht es schneller.</p>';
|
||||||
|
preloader.appendChild(div);
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeSyncInfoToPreloader() {
|
||||||
|
$('#preloader-sync-info').remove();
|
||||||
|
}
|
||||||
|
|||||||
1518
client/scripts/mobileconsole.js
Normal file
1518
client/scripts/mobileconsole.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -7,9 +7,11 @@
|
|||||||
|
|
||||||
?>
|
?>
|
||||||
//Loading the Service Worker
|
//Loading the Service Worker
|
||||||
|
var swRegistration = null;
|
||||||
if ('serviceWorker' in navigator) {
|
if ('serviceWorker' in navigator) {
|
||||||
window.addEventListener('load', function() {
|
window.addEventListener('load', async function() {
|
||||||
navigator.serviceWorker.register('<?php echo SERVER_ADDR; ?>/service-worker.js.php');
|
swRegistration = await navigator.serviceWorker.register('<?php echo SERVER_ADDR; ?>/service-worker.js.php');
|
||||||
|
if (typeof onServiceWorkerLoaded === 'function') onServiceWorkerLoaded();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -18,8 +20,6 @@ $(document).ready(function(){
|
|||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
var pwaVersion = '<?php echo PWA_VERSION; ?>'; //must be identical to _manifest.json version. If not it will create update window loop
|
var pwaVersion = '<?php echo PWA_VERSION; ?>'; //must be identical to _manifest.json version. If not it will create update window loop
|
||||||
var pwaCookie = true; // if set to false, the PWA prompt will appear even if the user selects "maybe later"
|
|
||||||
var pwaNoCache = false; // always keep the cache clear to serve the freshest possible content
|
|
||||||
|
|
||||||
|
|
||||||
$('[data-pwa-version]').data('pwa-version', pwaVersion);
|
$('[data-pwa-version]').data('pwa-version', pwaVersion);
|
||||||
@@ -33,7 +33,7 @@ $(document).ready(function(){
|
|||||||
//Enabling dismiss button
|
//Enabling dismiss button
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
$('.pwa-dismiss').on('click',function(){
|
$('.pwa-dismiss').on('click',function(){
|
||||||
console.log('User Closed Add to Home / PWA Prompt')
|
log('[pwa] User Closed Add to Home / PWA Prompt')
|
||||||
createCookie('Sticky_pwa_rejected_install', true, 1);
|
createCookie('Sticky_pwa_rejected_install', true, 1);
|
||||||
$('body').find('#menu-install-pwa-android, #menu-install-pwa-ios, .menu-hider').removeClass('menu-active');
|
$('body').find('#menu-install-pwa-android, #menu-install-pwa-ios, .menu-hider').removeClass('menu-active');
|
||||||
});
|
});
|
||||||
@@ -50,34 +50,37 @@ $(document).ready(function(){
|
|||||||
|
|
||||||
//Firing PWA prompts for specific versions and when not on home screen.
|
//Firing PWA prompts for specific versions and when not on home screen.
|
||||||
if (isMobile.Android()) {
|
if (isMobile.Android()) {
|
||||||
console.log('Android Detected');
|
log('[pwa] Android Detected');
|
||||||
function showInstallPromotion(){
|
function showInstallPromotion(){
|
||||||
if($('#menu-install-pwa-android, .add-to-home').length){
|
if($('#menu-install-pwa-android, .add-to-home').length){
|
||||||
console.log('Triggering PWA Menu for Android');
|
log('[pwa] Triggering PWA Menu for Android');
|
||||||
if (!readCookie('Sticky_pwa_rejected_install')) {
|
if (!readCookie('Sticky_pwa_rejected_install')) {
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
$('.add-to-home').addClass('add-to-home-visible add-to-home-android');
|
$('.add-to-home').addClass('add-to-home-visible add-to-home-android');
|
||||||
$('#menu-install-pwa-android, .menu-hider').addClass('menu-active')
|
$('#menu-install-pwa-android, .menu-hider').addClass('menu-active')
|
||||||
},4500);
|
},3000);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
console.log('The div #menu-install-pwa-android was not found. Please add this div to show the install window')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let deferredPrompt;
|
let deferredPrompt;
|
||||||
window.addEventListener('beforeinstallprompt', (e) => {
|
window.addEventListener('beforeinstallprompt', (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
deferredPrompt = e;
|
deferredPrompt = e;
|
||||||
|
var welcomActive = $('#menu-welcome').hasClass('menu-active');
|
||||||
|
if (welcomActive) {
|
||||||
|
$('#menu-welcome-a-okay').click(showInstallPromotion);
|
||||||
|
} else {
|
||||||
showInstallPromotion();
|
showInstallPromotion();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
$('.pwa-install').on('click',function(e){
|
$('.pwa-install').on('click',function(e){
|
||||||
deferredPrompt.prompt();
|
deferredPrompt.prompt();
|
||||||
deferredPrompt.userChoice
|
deferredPrompt.userChoice
|
||||||
.then((choiceResult) => {
|
.then((choiceResult) => {
|
||||||
if (choiceResult.outcome === 'accepted') {
|
if (choiceResult.outcome === 'accepted') {
|
||||||
console.log('User accepted the A2HS prompt');
|
log('[pwa] User accepted the A2HS prompt');
|
||||||
} else {
|
} else {
|
||||||
console.log('User dismissed the A2HS prompt');
|
log('[pwa] User dismissed the A2HS prompt');
|
||||||
}
|
}
|
||||||
deferredPrompt = null;
|
deferredPrompt = null;
|
||||||
});
|
});
|
||||||
@@ -89,98 +92,25 @@ $(document).ready(function(){
|
|||||||
|
|
||||||
if (isMobile.iOS()) {
|
if (isMobile.iOS()) {
|
||||||
if(!isInWebAppiOS){
|
if(!isInWebAppiOS){
|
||||||
console.log('iOS Detected');
|
log('[pwa] iOS Detected');
|
||||||
if($('#menu-install-pwa-ios, .add-to-home').length){
|
if($('#menu-install-pwa-ios, .add-to-home').length){
|
||||||
if (!readCookie('Sticky_pwa_rejected_install')) {
|
if (!readCookie('Sticky_pwa_rejected_install')) {
|
||||||
console.log('Triggering PWA / Add to Home Screen Menu for iOS');
|
function triggerPwaInstallIos() {
|
||||||
|
log('[pwa] Triggering PWA / Add to Home Screen Menu for iOS');
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
$('.add-to-home').addClass('add-to-home-visible add-to-home-ios');
|
$('.add-to-home').addClass('add-to-home-visible add-to-home-ios');
|
||||||
$('#menu-install-pwa-ios, .menu-hider').addClass('menu-active');
|
$('#menu-install-pwa-ios, .menu-hider').addClass('menu-active');
|
||||||
},4500);
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
console.log('The div #menu-install-pwa-ios was not found. Please add this div to show the install window')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//Creating Update Modal
|
|
||||||
function updateModal(){
|
|
||||||
var body = $('body');
|
|
||||||
var updateModal = $('#menu-update');
|
|
||||||
var mt = new Date();
|
|
||||||
var menuUpdate = mt.getHours() + ":" + mt.getMinutes() + ":" + mt.getSeconds();
|
|
||||||
if(!updateModal.length){
|
|
||||||
body.append('<div id="menu-update"></div>');
|
|
||||||
setTimeout(function(){
|
|
||||||
body.find('#menu-update').load('menu-update.html?ver='+menuUpdate);
|
|
||||||
},250);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
//Update Version in 5 Seconds After New Version Detected
|
|
||||||
function updateButton(){
|
|
||||||
var counter = 3;
|
|
||||||
var interval = setInterval(function() {
|
|
||||||
counter--;
|
|
||||||
console.log(counter);
|
|
||||||
$('.page-update').html('Aktuallisierung in ... '+ counter + ' Sekunden');
|
|
||||||
if (counter == 0) {
|
|
||||||
clearInterval(interval);
|
|
||||||
window.location.reload(true)
|
|
||||||
}
|
|
||||||
}, 1000);
|
|
||||||
caches.delete('workbox-runtime').then(function() {
|
|
||||||
console.log('Content Updated - Cache Removed!');
|
|
||||||
});
|
|
||||||
//localStorage.clear();
|
|
||||||
sessionStorage.clear()
|
|
||||||
caches.keys().then(cacheNames => {
|
|
||||||
cacheNames.forEach(cacheName => {
|
|
||||||
caches.delete(cacheName);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
//Check Version
|
|
||||||
function check_version(){
|
|
||||||
if($('link[data-pwa-version]').length){
|
|
||||||
function versionCheck(){
|
|
||||||
var dt = new Date();
|
|
||||||
var maniTimeVersion = dt.getHours() + ":" + dt.getMinutes() + ":" + dt.getSeconds();
|
|
||||||
var localVersionNumber = $('link[rel="manifest"]').data('pwa-version');
|
|
||||||
var onlineVersionJSON = "<?php echo SERVER_ADDR; ?>/manifest.json.php?ver=" + maniTimeVersion;
|
|
||||||
var onlineVersionNumber = "Connection Offline. Waiting to Reconect";
|
|
||||||
$.getJSON(onlineVersionJSON, function(onlineData) {onlineVersionNumber = onlineData.version;});
|
|
||||||
setTimeout(function(){
|
|
||||||
//console.log(' Checking PWA Content for updates...\n PWA Server Version: ' + onlineVersionNumber + '\n' + ' PWA Cached Version: ' + localVersionNumber);
|
|
||||||
if(onlineVersionNumber != localVersionNumber && onlineVersionNumber != "Connection Offline. Waiting to Reconect"){
|
|
||||||
updateModal();
|
|
||||||
console.log('New Version of Content Available. Refreshing. On Desktop Browsers a manual refresh maybe required.')
|
|
||||||
setTimeout(function(){
|
|
||||||
$('body').find('#menu-update').addClass('menu-active');
|
|
||||||
$('.menu-hider').addClass('menu-active-no-click');
|
|
||||||
updateButton();
|
|
||||||
},500);
|
|
||||||
}
|
|
||||||
if(onlineVersionNumber == localVersionNumber){/*No update required. Versions Identical*/}
|
|
||||||
if(onlineVersionNumber === "undefined"){/*Error Checking for Updates*/}
|
|
||||||
if(onlineVersionNumber === "Finding Online Version..."){
|
|
||||||
$('.reloadme').addClass('disabled');
|
|
||||||
$('body').find('#menu-update').removeClass('menu-active');
|
|
||||||
$('.menu-hider').removeClass('menu-active-no-click');
|
|
||||||
}
|
|
||||||
},3000);
|
},3000);
|
||||||
}
|
}
|
||||||
//Checking for new version every 60 seconds
|
var welcomActive = $('#menu-welcome').hasClass('menu-active');
|
||||||
setInterval(function(){versionCheck()}, 50000);
|
if (welcomActive) {
|
||||||
//Initial Load Version Check in 10 Second After Load
|
$('#menu-welcome-a-okay').click(triggerPwaInstallIos);
|
||||||
setTimeout(function(){versionCheck();}, 10000);
|
} else {
|
||||||
|
triggerPwaInstallIos();
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pwaCookie == false){
|
|
||||||
eraseCookie('Sticky_pwa_rejected_install');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Reload To Clear Button
|
//Reload To Clear Button
|
||||||
@@ -188,9 +118,6 @@ $(document).ready(function(){
|
|||||||
location.reload();
|
location.reload();
|
||||||
});
|
});
|
||||||
|
|
||||||
//Check for Version Change if Online If not Kill the Function
|
|
||||||
if (navigator.onLine) {check_version();} else {function check_version(){}}
|
|
||||||
|
|
||||||
//Adding Offline Alerts
|
//Adding Offline Alerts
|
||||||
var offlineAlerts = $('.offline-message');
|
var offlineAlerts = $('.offline-message');
|
||||||
|
|
||||||
@@ -213,47 +140,19 @@ $(document).ready(function(){
|
|||||||
setTimeout(function(){$('.online-message').removeClass('online-message-active');},2000);
|
setTimeout(function(){$('.online-message').removeClass('online-message-active');},2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
$('.simulate-offline').on('click',function(){isOffline();})
|
|
||||||
$('.simulate-online').on('click',function(){isOnline();})
|
|
||||||
|
|
||||||
//Disable links to other pages if offline.
|
|
||||||
//Warning! Enabling offline for iOS can cause issues
|
|
||||||
//To allow offline functionality delete the next 7 lines
|
|
||||||
function returnFalse(){
|
|
||||||
var detectHREF = $(this).attr('href');
|
|
||||||
if(detectHREF.match(/.html/)){
|
|
||||||
isOffline();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Check if Online / Offline
|
//Check if Online / Offline
|
||||||
function updateOnlineStatus(event) {
|
function updateOnlineStatus(event) {
|
||||||
var condition = navigator.onLine ? "online" : "offline";
|
var condition = navigator.onLine ? "online" : "offline";
|
||||||
isOnline();
|
isOnline();
|
||||||
console.log( 'Connection: Online');
|
log('[pwa] Connection: Online');
|
||||||
$("a").off( "click", returnFalse );
|
|
||||||
}
|
}
|
||||||
function updateOfflineStatus(event) {
|
function updateOfflineStatus(event) {
|
||||||
isOffline();
|
isOffline();
|
||||||
$("a").on( "click", returnFalse );
|
log('[pwa] Connection: Offline');
|
||||||
console.log( 'Connection: Offline');
|
|
||||||
}
|
}
|
||||||
window.addEventListener('online', updateOnlineStatus);
|
window.addEventListener('online', updateOnlineStatus);
|
||||||
window.addEventListener('offline', updateOfflineStatus);
|
window.addEventListener('offline', updateOfflineStatus);
|
||||||
|
|
||||||
|
|
||||||
if(pwaNoCache == true){
|
|
||||||
caches.delete('workbox-runtime').then(function() {
|
|
||||||
});
|
|
||||||
localStorage.clear();
|
|
||||||
sessionStorage.clear()
|
|
||||||
caches.keys().then(cacheNames => {
|
|
||||||
cacheNames.forEach(cacheName => {
|
|
||||||
caches.delete(cacheName);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -11,6 +11,20 @@ const BOATCLASS = '<?php echo BOATCLASS; ?>';
|
|||||||
const LINK_PRE = '<?php echo SERVER_ADDR; ?>/';
|
const LINK_PRE = '<?php echo SERVER_ADDR; ?>/';
|
||||||
const YOUTH_AGE = '<?php echo $_CLASS['youth-age']; ?>';
|
const YOUTH_AGE = '<?php echo $_CLASS['youth-age']; ?>';
|
||||||
const YOUTH_GERMAN_NAME = '<?php echo $_CLASS['youth-german-name']; ?>';
|
const YOUTH_GERMAN_NAME = '<?php echo $_CLASS['youth-german-name']; ?>';
|
||||||
|
const PUSH_SERVER_KEY = '<?php echo PUSH_SERVER_KEY; ?>';
|
||||||
|
|
||||||
|
function log() {
|
||||||
|
var now = new Date();
|
||||||
|
var hour = now.getHours().toString();
|
||||||
|
var min = now.getMinutes().toString();
|
||||||
|
var sec = now.getSeconds().toString();
|
||||||
|
var millis = now.getMilliseconds().toString();
|
||||||
|
hour = (hour.length < 2 ? '0' + hour : hour);
|
||||||
|
min = (min.length < 2 ? '0' + min : min);
|
||||||
|
sec = (sec.length < 2 ? '0' + sec : sec);
|
||||||
|
while (millis.length < 3) millis = '0' + millis;
|
||||||
|
console.log('[' + hour + ':' + min + ':' + sec + '.' + millis + ']', ...arguments);
|
||||||
|
}
|
||||||
|
|
||||||
var randomId = function() { return '_' + Math.random().toString(36).substr(2, 9); }
|
var randomId = function() { return '_' + Math.random().toString(36).substr(2, 9); }
|
||||||
|
|
||||||
@@ -117,12 +131,53 @@ function findGetParameter(parameterName) {
|
|||||||
return result;
|
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.<br>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() {
|
var login = function() {
|
||||||
showLoader();
|
showLoader();
|
||||||
var username = $('#input-login-username').val();
|
var username = $('#input-login-username').val();
|
||||||
var password = $('#input-login-password').val();
|
var password = $('#input-login-password').val();
|
||||||
$('#input-login-username').val('');
|
$('#input-login-username').val('').trigger('focusin').trigger('focusout');
|
||||||
$('#input-login-password').val('');
|
$('#input-login-password').val('').trigger('focusin').trigger('focusout');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: QUERY_URL + 'login',
|
url: QUERY_URL + 'login',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -134,13 +189,13 @@ var login = function() {
|
|||||||
error: function (xhr, status, error) {
|
error: function (xhr, status, error) {
|
||||||
if (xhr.status == 401) {
|
if (xhr.status == 401) {
|
||||||
toastError('Benutzername oder Passwort falsch');
|
toastError('Benutzername oder Passwort falsch');
|
||||||
$('#input-login-username').val(username);
|
$('#input-login-username').val(username).trigger('focusin').trigger('focusout');
|
||||||
} else if (xhr.status == 0) {
|
} else if (xhr.status == 0) {
|
||||||
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um Dich anzumelden');
|
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um Dich anzumelden');
|
||||||
$('#menu-login').hideMenu();
|
$('#menu-login').hideMenu();
|
||||||
} else {
|
} else {
|
||||||
console.log('Login: unbekannter Fehler', status, error);
|
log('[app] Login: unbekannter Fehler', status, error);
|
||||||
console.log(xhr);
|
log(xhr);
|
||||||
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
|
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
|
||||||
}
|
}
|
||||||
hideLoader();
|
hideLoader();
|
||||||
@@ -172,7 +227,7 @@ var logout = function() {
|
|||||||
hash: localStorage.getItem('auth_hash')
|
hash: localStorage.getItem('auth_hash')
|
||||||
}
|
}
|
||||||
if ((auth.id === null) || (auth.hash === null)) {
|
if ((auth.id === null) || (auth.hash === null)) {
|
||||||
console.log('Not logged in');
|
log('[app] Not logged in');
|
||||||
logoutClearStorage();
|
logoutClearStorage();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -184,14 +239,14 @@ var logout = function() {
|
|||||||
},
|
},
|
||||||
error: function (xhr, status, error) {
|
error: function (xhr, status, error) {
|
||||||
if (xhr.status == 401) {
|
if (xhr.status == 401) {
|
||||||
console.log('Not logged in');
|
log('[app] Not logged in');
|
||||||
logoutClearStorage();
|
logoutClearStorage();
|
||||||
} else if (xhr.status == 0) {
|
} else if (xhr.status == 0) {
|
||||||
console.log('Could not delete auth from server');
|
log('[app] Could not delete auth from server');
|
||||||
logoutClearStorage();
|
logoutClearStorage();
|
||||||
} else {
|
} else {
|
||||||
console.log('Logout: unbekannter Fehler', status, error);
|
log('[app] Logout: unbekannter Fehler', status, error);
|
||||||
console.log(xhr);
|
log(xhr);
|
||||||
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
|
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
|
||||||
hideLoader();
|
hideLoader();
|
||||||
}
|
}
|
||||||
@@ -202,28 +257,237 @@ var logout = function() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetCache() {
|
function deleteDb() {
|
||||||
|
$('#menu-developer').hideMenu();
|
||||||
|
if (canUseLocalDB) {
|
||||||
|
showLoader();
|
||||||
|
var request = window.indexedDB.deleteDatabase('regatten_app_db_' + BOATCLASS);
|
||||||
|
request.onerror = function (event) {
|
||||||
|
log('[app] Cannot delete DB: ', event.target.errorCode);
|
||||||
|
toastError('Beim Löschen der Datenbank ist ein Fehler aufgetreten.<br>Bitte melde diesen Fehler. (Dev-Menu => Problem melden)', 5000);
|
||||||
|
hideLoader();
|
||||||
|
}
|
||||||
|
request.onsuccess = function (event) {
|
||||||
|
log('[app] DB deleted');
|
||||||
|
toastInfo('Die Datenbank wurde gelöscht. Die Seite lädt in wenigen Sekunden neu und erstellt damit eine neue Datenbank.', 10000);
|
||||||
|
hideLoader();
|
||||||
|
setTimeout(function(){ location.reload(); }, 3000);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
toastWarn('Dein Gerät unterstützt kein lokales Speichern der Daten. Alle Daten werden direkt vom Server gezogen.<br>Entsprechend kannst Du die Datenbank auch nicht zurücksetzen.', 10000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteCache() {
|
||||||
$('#menu-developer').hideMenu();
|
$('#menu-developer').hideMenu();
|
||||||
navigator.serviceWorker.getRegistrations().then(function (registrations) {
|
navigator.serviceWorker.getRegistrations().then(function (registrations) {
|
||||||
for (let registration of registrations) {
|
for (let registration of registrations) {
|
||||||
console.log('Unregister sW:', registration);
|
log('[app] Unregister sW:', registration);
|
||||||
registration.unregister();
|
registration.unregister();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
caches.keys().then((keyList) => {
|
caches.keys().then((keyList) => {
|
||||||
return Promise.all(keyList.map((key) => {
|
return Promise.all(keyList.map((key) => {
|
||||||
console.log('Cache deleted:', key);
|
log('[app] Cache deleted:', key);
|
||||||
return caches.delete(key);
|
return caches.delete(key);
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
toastInfo('The serviceWorker and the cache were deleted. A new serviceWorker will be generated on the next refresh.');
|
toastInfo('Der serviceWorker und alle Caches wurden gelöscht. Die Seite lädt in wenigen Sekunden neu und erstellt damit neue Caches.', 10000);
|
||||||
|
setTimeout(function(){ location.reload(); }, 3000);
|
||||||
|
}
|
||||||
|
|
||||||
|
var pushesPossible = false;
|
||||||
|
|
||||||
|
function urlB64ToUint8Array(base64String) {
|
||||||
|
const padding = '='.repeat((4 - base64String.length % 4) % 4);
|
||||||
|
const base64 = (base64String + padding)
|
||||||
|
.replace(/\-/g, '+')
|
||||||
|
.replace(/_/g, '/');
|
||||||
|
|
||||||
|
const rawData = window.atob(base64);
|
||||||
|
const outputArray = new Uint8Array(rawData.length);
|
||||||
|
|
||||||
|
for (let i = 0; i < rawData.length; ++i) {
|
||||||
|
outputArray[i] = rawData.charCodeAt(i);
|
||||||
|
}
|
||||||
|
return outputArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
function pushesSubscribe() {
|
||||||
|
log('[app] Subscribing');
|
||||||
|
const applicationServerKey = urlB64ToUint8Array(PUSH_SERVER_KEY);
|
||||||
|
swRegistration.pushManager.subscribe({
|
||||||
|
userVisibleOnly: true,
|
||||||
|
applicationServerKey: applicationServerKey
|
||||||
|
})
|
||||||
|
.then(function(subscription) {
|
||||||
|
pushesUpdateServerSubscription(subscription, true);
|
||||||
|
updatePushSwitches();
|
||||||
|
updatePushBadge();
|
||||||
|
})
|
||||||
|
.catch(function(err) {
|
||||||
|
log('[app] Failed to subscribe the user: ', err);
|
||||||
|
toastError('Da ist leider etwas schief gelaufen. Bitte stelle sicher, dass Du mit dem Internet verbunden bist und versuche es erneut.', 5000);
|
||||||
|
pushesUnSubscribe(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function pushesUnSubscribe(silent = false) {
|
||||||
|
log('[app] Unsubscribing');
|
||||||
|
swRegistration.pushManager.getSubscription()
|
||||||
|
.then(function(subscription) {
|
||||||
|
if (subscription) {
|
||||||
|
pushesUpdateServerSubscription(subscription, false);
|
||||||
|
subscription.unsubscribe();
|
||||||
|
$('#menu-pushes').hideMenu();
|
||||||
|
updatePushBadge();
|
||||||
|
hideLoader();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(function(error) {
|
||||||
|
log('[app] Error unsubscribing', error);
|
||||||
|
$('#menu-pushes').hideMenu();
|
||||||
|
if (!silent) toastError('Da ist leider etwas schief gelaufen. Bitte versuche es erneut oder wende Dich an unseren Support.', 5000);
|
||||||
|
updatePushBadge();
|
||||||
|
hideLoader();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function pushesUpdateServerSubscription(subscription, enabled) {
|
||||||
|
log('[app] updateServer', enabled, subscription);
|
||||||
|
$.ajax({
|
||||||
|
url: QUERY_URL + (enabled ? 'add' : 'remove') + '_subscription',
|
||||||
|
type: 'POST',
|
||||||
|
data: { subscription: JSON.stringify(subscription) },
|
||||||
|
success: function (data, textStatus, jqXHR) {
|
||||||
|
if (!enabled) {
|
||||||
|
toastOk('Du erhältst ab sofort keine Benachrichtigungen mehr von uns.');
|
||||||
|
}
|
||||||
|
hideLoader();
|
||||||
|
},
|
||||||
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
|
throw 'Cannot update server subscription';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function initPushSettings() {
|
||||||
|
var items = [
|
||||||
|
['notify_channel_' + BOATCLASS + '_news', true],
|
||||||
|
['notify_channel_' + BOATCLASS + '_regatta_changed_my', true],
|
||||||
|
['notify_channel_' + BOATCLASS + '_regatta_changed_all', false],
|
||||||
|
['notify_channel_' + BOATCLASS + '_result_ready_my', true],
|
||||||
|
['notify_channel_' + BOATCLASS + '_result_ready_all', true],
|
||||||
|
['notify_channel_' + BOATCLASS + '_meldeschluss', true]
|
||||||
|
];
|
||||||
|
for (var i in items) {
|
||||||
|
var item = items[i];
|
||||||
|
if ((await dbSettingsGet(item[0])) == null) dbSettingsSet(item[0], item[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function updatePushSwitches() {
|
||||||
|
$('#switch-pushes-news').prop('checked', await dbSettingsGet('notify_channel_' + BOATCLASS + '_news'));
|
||||||
|
$('#switch-pushes-regatta-changed-my').prop('checked', await dbSettingsGet('notify_channel_' + BOATCLASS + '_regatta_changed_my'));
|
||||||
|
$('#switch-pushes-regatta-changed-all').prop('checked', await dbSettingsGet('notify_channel_' + BOATCLASS + '_regatta_changed_all'));
|
||||||
|
$('#switch-pushes-result-ready-my').prop('checked', await dbSettingsGet('notify_channel_' + BOATCLASS + '_result_ready_my'));
|
||||||
|
$('#switch-pushes-result-ready-all').prop('checked', await dbSettingsGet('notify_channel_' + BOATCLASS + '_result_ready_all'));
|
||||||
|
$('#switch-pushes-meldeschluss').prop('checked', await dbSettingsGet('notify_channel_' + BOATCLASS + '_meldeschluss'));
|
||||||
|
|
||||||
|
if ($('#switch-pushes').prop('checked')) {
|
||||||
|
$('#p-pushes-info').show();
|
||||||
|
$('.a-switch-pushes-channel-all').show();
|
||||||
|
$('.a-switch-pushes-channel-my').show();
|
||||||
|
if (!isLoggedIn()) {
|
||||||
|
$('.a-switch-pushes-channel-my').find('div').remove();
|
||||||
|
$('.a-switch-pushes-channel-my').find('.badge').text('nicht angemeldet');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$('#p-pushes-info').hide();
|
||||||
|
$('.a-switch-pushes-channel-all').hide();
|
||||||
|
$('.a-switch-pushes-channel-my').hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function pushesSubscribeClicked() {
|
||||||
|
showLoader();
|
||||||
|
if ($('#switch-pushes').prop('checked')) {
|
||||||
|
pushesSubscribe();
|
||||||
|
} else {
|
||||||
|
pushesUnSubscribe();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function pushesChannelClicked() {
|
||||||
|
dbSettingsSet('notify_channel_' + BOATCLASS + '_news', $('#switch-pushes-news').prop('checked'));
|
||||||
|
dbSettingsSet('notify_channel_' + BOATCLASS + '_regatta_changed_my', $('#switch-pushes-regatta-changed-my').prop('checked'));
|
||||||
|
dbSettingsSet('notify_channel_' + BOATCLASS + '_regatta_changed_all', $('#switch-pushes-regatta-changed-all').prop('checked'));
|
||||||
|
dbSettingsSet('notify_channel_' + BOATCLASS + '_result_ready_my', $('#switch-pushes-result-ready-my').prop('checked'));
|
||||||
|
dbSettingsSet('notify_channel_' + BOATCLASS + '_result_ready_all', $('#switch-pushes-result-ready-all').prop('checked'));
|
||||||
|
dbSettingsSet('notify_channel_' + BOATCLASS + '_meldeschluss', $('#switch-pushes-meldeschluss').prop('checked'));
|
||||||
|
}
|
||||||
|
|
||||||
|
function pushesOpenMenu() {
|
||||||
|
$('#menu-settings').hideMenu();
|
||||||
|
if (!pushesPossible) {
|
||||||
|
toastWarn('Dein Browser unterstützt leider keine Benachrichtigungen.', 5000);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (Notification.permission == 'denied') {
|
||||||
|
toastWarn('Benachrichtigungen werden von Deinem Browser blockiert.', 5000);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
swRegistration.pushManager.getSubscription().then(function(subscription) {
|
||||||
|
var isSub = (subscription !== null);
|
||||||
|
$('#switch-pushes').prop('checked', isSub);
|
||||||
|
updatePushSwitches();
|
||||||
|
$('#menu-pushes').showMenu();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
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');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
swRegistration.pushManager.getSubscription().then(function(subscription) {
|
||||||
|
var isSub = (subscription !== null);
|
||||||
|
if (isSub) {
|
||||||
|
$('#badge-pushes').removeClass('bg-red2-dark').addClass('bg-green2-dark').text('AN');
|
||||||
|
} else {
|
||||||
|
$('#badge-pushes').removeClass('bg-green2-dark').addClass('bg-red2-dark').text('AUS');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function updateNewsBadge() {
|
||||||
|
var newsRead = await dbSettingsGet('news_read_' + BOATCLASS);
|
||||||
|
if (newsRead === null) dbSettingsSet('news_read_' + BOATCLASS, newsRead = new Date());
|
||||||
|
var news = await dbGetData('news');
|
||||||
|
var now = new Date();
|
||||||
|
var sum = 0;
|
||||||
|
for (var n in news) {
|
||||||
|
var newsEntry = news[n];
|
||||||
|
newsEntry.date = new Date(Date.parse(newsEntry.date));
|
||||||
|
if (newsEntry.date > now) continue;
|
||||||
|
if (newsEntry.date < newsRead) continue;
|
||||||
|
sum ++;
|
||||||
|
}
|
||||||
|
updateBadge('more/news', sum);
|
||||||
}
|
}
|
||||||
|
|
||||||
var initRegatten = function() {
|
var initRegatten = function() {
|
||||||
showLoader();
|
showLoader();
|
||||||
|
|
||||||
|
log('[app] Initializing DB...');
|
||||||
|
|
||||||
initDatabase();
|
initDatabase();
|
||||||
|
|
||||||
|
log('[app] Loading app specific code...');
|
||||||
|
|
||||||
if (isLoggedIn()) {
|
if (isLoggedIn()) {
|
||||||
$('.show-loggedin').show();
|
$('.show-loggedin').show();
|
||||||
$('.show-notloggedin').hide();
|
$('.show-notloggedin').hide();
|
||||||
@@ -235,4 +499,67 @@ var initRegatten = function() {
|
|||||||
$('.show-loggedin').hide();
|
$('.show-loggedin').hide();
|
||||||
$('.show-notloggedin').show();
|
$('.show-notloggedin').show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pushes
|
||||||
|
$('#a-switch-pushes').click(pushesSubscribeClicked);
|
||||||
|
$('.a-switch-pushes-channel-all').click(pushesChannelClicked);
|
||||||
|
$('.a-switch-pushes-channel-my').click(pushesChannelClicked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var onServiceWorkerLoaded = function() {
|
||||||
|
log('[app] sW loaded');
|
||||||
|
if ((swRegistration !== null) && canUseLocalDB) {
|
||||||
|
pushesPossible = true;
|
||||||
|
updatePushBadge();
|
||||||
|
} else {
|
||||||
|
$('#badge-pushes').removeClass('bg-green2-dark').addClass('bg-red2-dark').text('NOT SUPPORTED');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var onDatabaseLoaded = function() {
|
||||||
|
log('[app] DB loaded');
|
||||||
|
if (!canUseLocalDB && !$('#menu-welcome').hasClass('menu-active')) {
|
||||||
|
function NoDbWarningOk() {
|
||||||
|
createCookie('regatten_nodb_banner', true, 1);
|
||||||
|
$('#menu-nodb-warning').hideMenu();
|
||||||
|
}
|
||||||
|
function showNoDbWarning() {
|
||||||
|
if (!readCookie('regatten_nodb_banner')) {
|
||||||
|
$('#menu-nodb-warning').showMenu();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$('#menu-nodb-warning-okay').click(NoDbWarningOk);
|
||||||
|
showNoDbWarning();
|
||||||
|
}
|
||||||
|
|
||||||
|
onServiceWorkerLoaded();
|
||||||
|
initPushSettings();
|
||||||
|
|
||||||
|
updateNewsBadge();
|
||||||
|
}
|
||||||
|
|
||||||
|
var onAfterSync = function() {
|
||||||
|
updateNewsBadge();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add console opener to preloader
|
||||||
|
var addConsoleOpenerToPreloader = function() {
|
||||||
|
addConsoleOpenerToPreloader = function(){};
|
||||||
|
var preloader = document.getElementById('preloader');
|
||||||
|
var button = document.createElement('a');
|
||||||
|
button.href = '#';
|
||||||
|
button.classList = 'btn rounded-s text-uppercase font-900 shadow-m m-3';
|
||||||
|
button.style.position = 'fixed';
|
||||||
|
button.style.bottom = 0;
|
||||||
|
button.style.right = 0;
|
||||||
|
button.innerHTML = '</>';
|
||||||
|
button.onclick = function(){
|
||||||
|
alert('CONSOLE OPENED\nDir werden jetzt einige Entwickler-Informationen angezeigt. Du kannst die Console über das X oben rechts wieder schließen.');
|
||||||
|
mobileConsole.displayConsole();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
setTimeout(function(){
|
||||||
|
preloader.appendChild(button);
|
||||||
|
}, 5000);
|
||||||
|
}
|
||||||
|
addConsoleOpenerToPreloader();
|
||||||
|
|||||||
@@ -173,6 +173,13 @@
|
|||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*** BLOCKQUOTE ***/
|
||||||
|
blockquote {
|
||||||
|
border-left: 0.5em solid rgba(0, 0, 0, 0.125);
|
||||||
|
font-style: italic;
|
||||||
|
padding-left: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
/*** BLINKING ICONS ***/
|
/*** BLINKING ICONS ***/
|
||||||
@keyframes fa-blink {
|
@keyframes fa-blink {
|
||||||
0% { opacity: 1; }
|
0% { opacity: 1; }
|
||||||
|
|||||||
@@ -12,6 +12,9 @@
|
|||||||
define('QUERY_URL', 'http://' . $_SERVER['SERVER_NAME'] . '/api/' . BOATCLASS . '/'); // url to api backend
|
define('QUERY_URL', 'http://' . $_SERVER['SERVER_NAME'] . '/api/' . BOATCLASS . '/'); // url to api backend
|
||||||
define('LOGGING_APIKEY', 'xxx'); // Apikey for Logging API -> get from ostertun.net/logging
|
define('LOGGING_APIKEY', 'xxx'); // Apikey for Logging API -> get from ostertun.net/logging
|
||||||
|
|
||||||
|
// PUSH
|
||||||
|
define('PUSH_SERVER_KEY', '');
|
||||||
|
|
||||||
// BOAT CLASS
|
// BOAT CLASS
|
||||||
$_CLASS = array(
|
$_CLASS = array(
|
||||||
'name' => 'Pirat',
|
'name' => 'Pirat',
|
||||||
|
|||||||
13
server/content/go2url.php
Normal file
13
server/content/go2url.php
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$sp['title'] = 'Umleitung - Regatten.net ' . $_CLASS['name'];
|
||||||
|
|
||||||
|
// Title
|
||||||
|
$content = '<h1>Umleitung</h1>';
|
||||||
|
$content .= '<p>Wir leiten Dich in Kürze zur gewünschten Website weiter</p>';
|
||||||
|
|
||||||
|
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-title']);
|
||||||
|
|
||||||
|
$sp['scripts'] .= $scripts->load('go2url');
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -11,8 +11,7 @@
|
|||||||
|
|
||||||
// Favorites
|
// Favorites
|
||||||
$content = '<h2>Deine Favoriten</h2>';
|
$content = '<h2>Deine Favoriten</h2>';
|
||||||
$thead = '<tr><th>Segler</th><th id="th-ranking">Rangliste</th></tr>';
|
$content .= '<div id="div-favorites" class="normal-list mb-0"></div>';
|
||||||
$content .= $tpl->load('table', [$thead, 'html-id' => 'table-favorites', 'css-class' => 'mb-0 mt-3']);
|
|
||||||
$content .= '<p id="p-favorites" class="mt-3">';
|
$content .= '<p id="p-favorites" class="mt-3">';
|
||||||
$content .= 'Du folgst <b>keinen</b> Seglern.<br>';
|
$content .= 'Du folgst <b>keinen</b> Seglern.<br>';
|
||||||
$content .= 'Um jemandem zu folgen, gehe zur <a href="' . LINK_PRE . 'sailors">Segler-Liste</a> und wähle bis zu fünf Segler aus.';
|
$content .= 'Um jemandem zu folgen, gehe zur <a href="' . LINK_PRE . 'sailors">Segler-Liste</a> und wähle bis zu fünf Segler aus.';
|
||||||
@@ -38,6 +37,18 @@
|
|||||||
|
|
||||||
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-notloggedin']);
|
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-notloggedin']);
|
||||||
|
|
||||||
|
// Notification Info
|
||||||
|
$content = '<h2 class="color-white">Push-Benachrichtigungen</h2>';
|
||||||
|
$content .= '<p class="mt-3 mb-3 color-white">';
|
||||||
|
$content .= '<b>Bleibe immer auf dem Laufendem!</b><br>';
|
||||||
|
$content .= 'Aktiviere einfach unsere Push-Benachrichtigungen und wir informieren Dich über alle Änderungen.<br>';
|
||||||
|
$content .= 'Du bestimmst natürlich, welche Benachrichtigungen Du bekommen möchtest.';
|
||||||
|
$content .= '</p>';
|
||||||
|
$content .= $tpl->load('button', ['Jetzt aktivieren', '#', 'html-id' => 'button-notifications-activate', 'css-class' => 'bg-green2-dark']);
|
||||||
|
$content .= '<p class="text-center mt-3"><a id="a-notifications-later" class="color-grey2-light text-uppercase font-900">Vielleicht später</a></p>';
|
||||||
|
|
||||||
|
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-notifications', 'css-class' => 'bg-blue2-dark']);
|
||||||
|
|
||||||
// Next
|
// Next
|
||||||
$content = '<h2>Nächste Regatten</h2>';
|
$content = '<h2>Nächste Regatten</h2>';
|
||||||
$content .= '<div id="div-next" class="regattas-list mb-0"></div>';
|
$content .= '<div id="div-next" class="regattas-list mb-0"></div>';
|
||||||
@@ -79,6 +90,10 @@
|
|||||||
$items .= $tpl->load('menu/item-icon', ['Vereins-Website', '', 'html-id' => 'menu-item-clubwebsite', 'icon' => 'fa-globe']);
|
$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['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('onRegattaClicked');
|
||||||
$sp['scripts'] .= $scripts->load('index');
|
$sp['scripts'] .= $scripts->load('index');
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,28 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// TODO: Create site
|
$sp['title'] = 'News - Regatten.net ' . $_CLASS['name'];
|
||||||
|
|
||||||
$sp['title'] = 'Seite noch nicht unterstuuml;tzt - Regatten.net ' . $_CLASS['name'];
|
|
||||||
$sp['backbutton'] = true;
|
$sp['backbutton'] = true;
|
||||||
|
$sp['activenav'] = 5;
|
||||||
|
|
||||||
$content = $tpl->load('error', ['404', 'Seite existiert noch nicht']);
|
// Title
|
||||||
$content .= '<p>';
|
$content = "<h1>Neuigkeiten</h1>";
|
||||||
$content .= 'Die gesuchte Seite ist leider noch nicht verfügbar.<br>';
|
$content .= '<p>Aktuelles der letzten zwölf Monate</p>';
|
||||||
$content .= 'Wir arbeiten daran, sie schnellstmöglich zur Verfügung zu stellen.<br>';
|
|
||||||
$content .= 'Wie wäre es mit der Homepage?';
|
|
||||||
$content .= '</p>';
|
|
||||||
$content .= $tpl->load('button', ['Zur Startseite', LINK_PRE . 'index', 'css-class' => 'mb-3']);
|
|
||||||
$content .= $tpl->load('button', ['Kontakt', LINK_PRE . 'contact']);
|
|
||||||
|
|
||||||
$sp['output'] = $tpl->load('card', [$content, 'css-class' => 'text-center pt-3']);
|
$sp['output'] .= $tpl->load('card', [$content]);
|
||||||
|
|
||||||
|
$sp['output'] .= '<div id="news-entries"></div>';
|
||||||
|
|
||||||
|
// Pagination
|
||||||
|
$sp['output'] .= $tpl->load('pagination', ['html-id' => 'pagination']);
|
||||||
|
|
||||||
|
// Menu
|
||||||
|
$sp['menus'] .= $tpl->load('menu/modal', ['html-id' => 'menu-news', 'title' => 'Details']);
|
||||||
|
|
||||||
|
$sp['scripts'] .= $scripts->load('pagination', ['pageChange', 'page', 'pageCount', 'pagination']);
|
||||||
|
$cardTemplate = $tpl->load('card', ['%CONTENT%', 'html-id' => '%ID%', 'css-class' => 'card-news']);
|
||||||
|
$cardTemplate = str_replace("\n", '', $cardTemplate);
|
||||||
|
$cardTemplate = str_replace("\r", '', $cardTemplate);
|
||||||
|
$sp['scripts'] .= "<script>const cardTemplate = '" . $cardTemplate . "';</script>";
|
||||||
|
$sp['scripts'] .= $scripts->load('news');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -1,19 +1,49 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// TODO: Create site
|
$sp['title'] = 'Saison-Planung - Regatten.net ' . $_CLASS['name'];
|
||||||
|
$sp['backbutton'] = 'index';
|
||||||
|
$sp['activenav'] = 5;
|
||||||
|
|
||||||
$sp['title'] = 'Seite noch nicht unterstuuml;tzt - Regatten.net ' . $_CLASS['name'];
|
// Title
|
||||||
$sp['backbutton'] = true;
|
$content = '<h1>Saison-Planung</h1>';
|
||||||
|
$content .= $tpl->load('button', ['<i class="fas fa-list"></i> Saison-Planungen anderer', LINK_PRE . 'planning_list', 'css-class' => 'mt-2 mb-2']);
|
||||||
|
$content .= '<p class="mb-1"><b>Hinweis:</b> Diese Seite kannst nur Du sehen.<br>Wenn Du Deine Saison-Planung teilen möchtest, <a id="a-share-planning">klicke hier</a></p>';
|
||||||
|
$content .= $tpl->load('button', ['<i class="fas fa-edit"></i> bearbeiten', LINK_PRE . 'planning_edit']);
|
||||||
|
$content .= $tpl->load('select', ['html-id' => 'select-year', 'placeholder' => 'Jahr', 'css-class' => 'mt-3 mb-0']);
|
||||||
|
|
||||||
$content = $tpl->load('error', ['404', 'Seite existiert noch nicht']);
|
$sp['output'] .= $tpl->load('card', [$content, 'css-class' => 'show-loggedin']);
|
||||||
$content .= '<p>';
|
|
||||||
$content .= 'Die gesuchte Seite ist leider noch nicht verfügbar.<br>';
|
|
||||||
$content .= 'Wir arbeiten daran, sie schnellstmöglich zur Verfügung zu stellen.<br>';
|
|
||||||
$content .= 'Wie wäre es mit der Homepage?';
|
|
||||||
$content .= '</p>';
|
|
||||||
$content .= $tpl->load('button', ['Zur Startseite', LINK_PRE . 'index', 'css-class' => 'mb-3']);
|
|
||||||
$content .= $tpl->load('button', ['Kontakt', LINK_PRE . 'contact']);
|
|
||||||
|
|
||||||
$sp['output'] = $tpl->load('card', [$content, 'css-class' => 'text-center pt-3']);
|
// Not loggedin
|
||||||
|
$content = '<h1>Saison-Planung</h1>';
|
||||||
|
$content .= '<p>Um Deine Saison-Planung zu sehen, musst Du angemeldet sein.<br><a href="#" data-menu="menu-login">Melde Dich hier an</a> oder <a href="#" data-menu="menu-signup">registriere Dich jetzt kostenlos</a>.</p>';
|
||||||
|
|
||||||
|
$sp['output'] .= $tpl->load('card', [$content, 'css-class' => 'show-notloggedin']);
|
||||||
|
|
||||||
|
// Regattas
|
||||||
|
$content = '<p id="p-count" class="mb-0"></p>';
|
||||||
|
$content .= $tpl->load('input', ['html-id' => 'input-search', 'placeholder' => 'Suche', 'type' => 'text', 'css-class' => 'mt-2']);
|
||||||
|
$content .= '<div id="div-regattas" class="regattas-list mb-0"></div>';
|
||||||
|
|
||||||
|
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-regattas', 'css-class' => 'show-loggedin']);
|
||||||
|
|
||||||
|
// Menu
|
||||||
|
$items = '<p id="menu-item-yourplanning" class="mb-2 mt-1" style="line-height: 1.5em;"></p>';
|
||||||
|
$items .= $tpl->load('menu/item-icon', ['Status bearbeiten', '#', 'html-id' => 'menu-item-status', 'icon' => 'fa-edit']);
|
||||||
|
$items .= $tpl->load('menu/item-icon', ['Saison-Planungen', '', 'html-id' => 'menu-item-plannings', 'icon' => 'fa-calendar-alt']);
|
||||||
|
$items .= $tpl->load('menu/item-icon', ['Ergebnisse', '', 'html-id' => 'menu-item-results', 'icon' => 'fa-poll']);
|
||||||
|
$items .= $tpl->load('menu/item-icon', ['Bericht', '', 'html-id' => 'menu-item-bericht', 'icon' => 'fa-book']);
|
||||||
|
$items .= $tpl->load('menu/item-icon', ['Informationen', '', 'html-id' => 'menu-item-info', 'icon' => 'fa-info']);
|
||||||
|
$items .= $tpl->load('menu/item-icon-badge', ['Meldung', '', 'html-id' => 'menu-item-meldung', 'icon' => 'fa-file-signature', 'badge-id' => 'badge-regatta-meldung']);
|
||||||
|
$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]);
|
||||||
|
|
||||||
|
// Menu Edit status
|
||||||
|
$items = $tpl->load('menu/item-switch', ['Gemeldet', 'html-id' => 'switch-status-gemeldet', 'icon' => 'fa-file-signature']);
|
||||||
|
$items .= $tpl->load('menu/item-switch', ['Bezahlt', 'html-id' => 'switch-status-bezahlt', 'icon' => 'fa-euro-sign', 'css-class' => 'border-0']);
|
||||||
|
$sp['menus'] .= $tpl->load('menu/bottom', [$items, 'html-id' => 'menu-status', 'title' => 'Status bearbeiten', 'height' => 220]);
|
||||||
|
|
||||||
|
$sp['scripts'] .= $scripts->load('onRegattaClicked');
|
||||||
|
$sp['scripts'] .= $scripts->load('planning');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -1,19 +1,31 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// TODO: Create site
|
$sp['title'] = 'Saison-Planung bearbeiten - Regatten.net ' . $_CLASS['name'];
|
||||||
|
$sp['backbutton'] = 'planning';
|
||||||
|
$sp['activenav'] = 5;
|
||||||
|
|
||||||
$sp['title'] = 'Seite noch nicht unterstuuml;tzt - Regatten.net ' . $_CLASS['name'];
|
// Title, Inputs
|
||||||
$sp['backbutton'] = true;
|
$content = "<h1>Saison-Planung bearbeiten</h1>";
|
||||||
|
$content .= $tpl->load('select', ['html-id' => 'select-year', 'placeholder' => 'Jahr', 'css-class' => 'mt-3 mb-0']);
|
||||||
|
|
||||||
$content = $tpl->load('error', ['404', 'Seite existiert noch nicht']);
|
$sp['output'] .= $tpl->load('card', [$content]);
|
||||||
$content .= '<p>';
|
|
||||||
$content .= 'Die gesuchte Seite ist leider noch nicht verfügbar.<br>';
|
|
||||||
$content .= 'Wir arbeiten daran, sie schnellstmöglich zur Verfügung zu stellen.<br>';
|
|
||||||
$content .= 'Wie wäre es mit der Homepage?';
|
|
||||||
$content .= '</p>';
|
|
||||||
$content .= $tpl->load('button', ['Zur Startseite', LINK_PRE . 'index', 'css-class' => 'mb-3']);
|
|
||||||
$content .= $tpl->load('button', ['Kontakt', LINK_PRE . 'contact']);
|
|
||||||
|
|
||||||
$sp['output'] = $tpl->load('card', [$content, 'css-class' => 'text-center pt-3']);
|
// Regattas
|
||||||
|
$content = '<p id="p-count" class="mb-0"></p>';
|
||||||
|
$content .= $tpl->load('input', ['html-id' => 'input-search', 'placeholder' => 'Suche', 'type' => 'text', 'css-class' => 'mt-2']);
|
||||||
|
$content .= '<div id="div-regattas" class="ranking-detail-list mb-0"></div>';
|
||||||
|
|
||||||
|
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-regattas']);
|
||||||
|
|
||||||
|
// Menu
|
||||||
|
$items = $tpl->load('menu/item-switch', ['In die Saison-Planung aufnehmen', 'html-id' => 'switch-planning-include', 'icon' => 'fa-check']);
|
||||||
|
$items .= $tpl->load('menu/item-simple', ['', '#', 'html-id' => 'item-steuermann']);
|
||||||
|
$sp['menus'] .= $tpl->load('menu/bottom', [$items, 'html-id' => 'menu-edit', 'title' => 'Regatta bearbeiten', 'height' => 320]);
|
||||||
|
|
||||||
|
// Select sailor
|
||||||
|
$items = $tpl->load('input', ['html-id' => 'input-edit-search', 'placeholder' => 'Suche', 'type' => 'text']);
|
||||||
|
$sp['menus'] .= $tpl->load('menu/modal', [$items, 'html-id' => 'menu-sailor', 'height' => 500, 'width' => 350]);
|
||||||
|
|
||||||
|
$sp['scripts'] .= $scripts->load('planning_edit');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -1,19 +1,27 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// TODO: Create site
|
$sp['title'] = 'Saison-Planungen - Regatten.net ' . $_CLASS['name'];
|
||||||
|
$sp['backbutton'] = 'planning';
|
||||||
|
$sp['activenav'] = 5;
|
||||||
|
|
||||||
$sp['title'] = 'Seite noch nicht unterstuuml;tzt - Regatten.net ' . $_CLASS['name'];
|
// Title
|
||||||
$sp['backbutton'] = true;
|
$content = '<h1>Saison-Planungen</h1>';
|
||||||
|
$content .= $tpl->load('select', ['html-id' => 'select-year', 'placeholder' => 'Jahr', 'css-class' => 'mt-3 mb-0']);
|
||||||
|
|
||||||
$content = $tpl->load('error', ['404', 'Seite existiert noch nicht']);
|
$sp['output'] .= $tpl->load('card', [$content, 'css-class' => 'show-loggedin']);
|
||||||
$content .= '<p>';
|
|
||||||
$content .= 'Die gesuchte Seite ist leider noch nicht verfügbar.<br>';
|
|
||||||
$content .= 'Wir arbeiten daran, sie schnellstmöglich zur Verfügung zu stellen.<br>';
|
|
||||||
$content .= 'Wie wäre es mit der Homepage?';
|
|
||||||
$content .= '</p>';
|
|
||||||
$content .= $tpl->load('button', ['Zur Startseite', LINK_PRE . 'index', 'css-class' => 'mb-3']);
|
|
||||||
$content .= $tpl->load('button', ['Kontakt', LINK_PRE . 'contact']);
|
|
||||||
|
|
||||||
$sp['output'] = $tpl->load('card', [$content, 'css-class' => 'text-center pt-3']);
|
// Not loggedin
|
||||||
|
$content = '<h1>Saison-Planungen</h1>';
|
||||||
|
$content .= '<p>Um die Saison-Planungen anderer zu sehen, musst Du angemeldet sein.<br><a href="#" data-menu="menu-login">Melde Dich hier an</a> oder <a href="#" data-menu="menu-signup">registriere Dich jetzt kostenlos</a>.</p>';
|
||||||
|
|
||||||
|
$sp['output'] .= $tpl->load('card', [$content, 'css-class' => 'show-notloggedin']);
|
||||||
|
|
||||||
|
// Regattas
|
||||||
|
$content = $tpl->load('input', ['html-id' => 'input-search', 'placeholder' => 'Suche', 'type' => 'text']);
|
||||||
|
$content .= '<div id="div-users" class="normal-list mb-0"></div>';
|
||||||
|
|
||||||
|
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-regattas', 'css-class' => 'show-loggedin']);
|
||||||
|
|
||||||
|
$sp['scripts'] .= $scripts->load('planning_list');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -1,19 +1,36 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// TODO: Create site
|
$sp['title'] = 'Saison-Planung - Regatten.net ' . $_CLASS['name'];
|
||||||
|
$sp['backbutton'] = 'planning_list';
|
||||||
|
$sp['activenav'] = 5;
|
||||||
|
|
||||||
$sp['title'] = 'Seite noch nicht unterstuuml;tzt - Regatten.net ' . $_CLASS['name'];
|
// Title
|
||||||
$sp['backbutton'] = true;
|
$content = '<h1>Saison-Planung</h1>';
|
||||||
|
$content .= '<p id="p-username" class="mb-1"></p>';
|
||||||
|
$content .= $tpl->load('button', ['<i class="fas fa-share-alt"></i> Teilen', '#', 'html-id' => 'button-share']);
|
||||||
|
$content .= $tpl->load('select', ['html-id' => 'select-year', 'placeholder' => 'Jahr', 'css-class' => 'mt-3 mb-0']);
|
||||||
|
|
||||||
$content = $tpl->load('error', ['404', 'Seite existiert noch nicht']);
|
$sp['output'] .= $tpl->load('card', [$content]);
|
||||||
$content .= '<p>';
|
|
||||||
$content .= 'Die gesuchte Seite ist leider noch nicht verfügbar.<br>';
|
|
||||||
$content .= 'Wir arbeiten daran, sie schnellstmöglich zur Verfügung zu stellen.<br>';
|
|
||||||
$content .= 'Wie wäre es mit der Homepage?';
|
|
||||||
$content .= '</p>';
|
|
||||||
$content .= $tpl->load('button', ['Zur Startseite', LINK_PRE . 'index', 'css-class' => 'mb-3']);
|
|
||||||
$content .= $tpl->load('button', ['Kontakt', LINK_PRE . 'contact']);
|
|
||||||
|
|
||||||
$sp['output'] = $tpl->load('card', [$content, 'css-class' => 'text-center pt-3']);
|
// Regattas
|
||||||
|
$content = '<p id="p-count" class="mb-0"></p>';
|
||||||
|
$content .= $tpl->load('input', ['html-id' => 'input-search', 'placeholder' => 'Suche', 'type' => 'text', 'css-class' => 'mt-2']);
|
||||||
|
$content .= '<div id="div-regattas" class="ranking-detail-list mb-0"></div>';
|
||||||
|
|
||||||
|
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-regattas']);
|
||||||
|
|
||||||
|
// Menu
|
||||||
|
$items = '<p id="menu-item-yourplanning" class="mb-2 mt-1" style="line-height: 1.5em;"></p>';
|
||||||
|
$items .= $tpl->load('menu/item-icon', ['Saison-Planungen', '', 'html-id' => 'menu-item-plannings', 'icon' => 'fa-calendar-alt']);
|
||||||
|
$items .= $tpl->load('menu/item-icon', ['Ergebnisse', '', 'html-id' => 'menu-item-results', 'icon' => 'fa-poll']);
|
||||||
|
$items .= $tpl->load('menu/item-icon', ['Bericht', '', 'html-id' => 'menu-item-bericht', 'icon' => 'fa-book']);
|
||||||
|
$items .= $tpl->load('menu/item-icon', ['Informationen', '', 'html-id' => 'menu-item-info', 'icon' => 'fa-info']);
|
||||||
|
$items .= $tpl->load('menu/item-icon-badge', ['Meldung', '', 'html-id' => 'menu-item-meldung', 'icon' => 'fa-file-signature', 'badge-id' => 'badge-regatta-meldung']);
|
||||||
|
$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('planning_view');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -31,9 +31,11 @@
|
|||||||
$sp['output'] .= $tpl->load('pagination', ['html-id' => 'pagination']);
|
$sp['output'] .= $tpl->load('pagination', ['html-id' => 'pagination']);
|
||||||
|
|
||||||
// Menu
|
// 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']);
|
$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 = '<p class="mb-2 mt-1" style="line-height: 1.5em;">Bitte trage hier den Jahrgang ein:</p>';
|
$items = '<p class="mb-2 mt-1" style="line-height: 1.5em;">Bitte trage hier den Jahrgang ein:</p>';
|
||||||
$items .= $tpl->load('input', ['html-id' => 'input-edityear', 'placeholder' => 'Jahrgang', 'type' => 'number']);
|
$items .= $tpl->load('input', ['html-id' => 'input-edityear', 'placeholder' => 'Jahrgang', 'type' => 'number']);
|
||||||
|
|||||||
@@ -1,29 +1,29 @@
|
|||||||
<div id="menu-share" class="menu menu-box-bottom menu-box-detached rounded-m" data-menu-height="345" data-menu-effect="menu-over">
|
<div id="menu-share" class="menu menu-box-bottom menu-box-detached rounded-m" data-menu-height="345" data-menu-effect="menu-over">
|
||||||
<div class="menu-title mt-n1"><h1>Share the Love</h1><p class="color-highlight">Just Tap the Social Icon. We'll add the Link</p><a href="#" class="close-menu"><i class="fa fa-times"></i></a></div>
|
<div class="menu-title mt-n1"><h1>Seite Teilen</h1><p class="color-highlight">Teile diese Seite mit Deinen Freunden!</p><a href="#" class="close-menu"><i class="fa fa-times"></i></a></div>
|
||||||
<div class="content mb-0">
|
<div class="content mb-0">
|
||||||
<div class="divider mb-0"></div>
|
<div class="divider mb-0"></div>
|
||||||
<div class="list-group list-custom-small list-icon-0">
|
<div class="list-group list-custom-small list-icon-0">
|
||||||
<a href="#" class="shareToFacebook">
|
<a href="#" class="shareToFacebook" target="_blank">
|
||||||
<i class="font-18 fab fa-facebook color-facebook"></i>
|
<i class="font-18 fab fa-facebook color-facebook"></i>
|
||||||
<span class="font-13">Facebook</span>
|
<span class="font-13">Facebook</span>
|
||||||
<i class="fa fa-angle-right"></i>
|
<i class="fa fa-angle-right"></i>
|
||||||
</a>
|
</a>
|
||||||
<a href="#" class="shareToTwitter">
|
<a href="#" class="shareToTwitter" target="_blank">
|
||||||
<i class="font-18 fab fa-twitter-square color-twitter"></i>
|
<i class="font-18 fab fa-twitter-square color-twitter"></i>
|
||||||
<span class="font-13">Twitter</span>
|
<span class="font-13">Twitter</span>
|
||||||
<i class="fa fa-angle-right"></i>
|
<i class="fa fa-angle-right"></i>
|
||||||
</a>
|
</a>
|
||||||
<a href="#" class="shareToLinkedIn">
|
<a href="#" class="shareToLinkedIn" target="_blank">
|
||||||
<i class="font-18 fab fa-linkedin color-linkedin"></i>
|
<i class="font-18 fab fa-linkedin color-linkedin"></i>
|
||||||
<span class="font-13">LinkedIn</span>
|
<span class="font-13">LinkedIn</span>
|
||||||
<i class="fa fa-angle-right"></i>
|
<i class="fa fa-angle-right"></i>
|
||||||
</a>
|
</a>
|
||||||
<a href="#" class="shareToWhatsApp">
|
<a href="#" class="shareToWhatsApp" target="_blank">
|
||||||
<i class="font-18 fab fa-whatsapp-square color-whatsapp"></i>
|
<i class="font-18 fab fa-whatsapp-square color-whatsapp"></i>
|
||||||
<span class="font-13">WhatsApp</span>
|
<span class="font-13">WhatsApp</span>
|
||||||
<i class="fa fa-angle-right"></i>
|
<i class="fa fa-angle-right"></i>
|
||||||
</a>
|
</a>
|
||||||
<a href="#" class="shareToMail border-0">
|
<a href="#" class="shareToMail border-0" target="_blank">
|
||||||
<i class="font-18 fa fa-envelope-square color-mail"></i>
|
<i class="font-18 fa fa-envelope-square color-mail"></i>
|
||||||
<span class="font-13">Email</span>
|
<span class="font-13">Email</span>
|
||||||
<i class="fa fa-angle-right"></i>
|
<i class="fa fa-angle-right"></i>
|
||||||
@@ -92,11 +92,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="menu-settings" class="menu menu-box-bottom menu-box-detached rounded-m" data-menu-height="270">
|
<div id="menu-settings" class="menu menu-box-bottom menu-box-detached rounded-m" data-menu-height="260">
|
||||||
<div class="menu-title"><h1>Einstellungen</h1><p class="color-highlight"> </p><a href="#" class="close-menu"><i class="fa fa-times"></i></a></div>
|
<div class="menu-title"><h1>Einstellungen</h1><p class="color-highlight"> </p><a href="#" class="close-menu"><i class="fa fa-times"></i></a></div>
|
||||||
<div class="divider divider-margins mb-n2"></div>
|
<div class="divider divider-margins mb-n2"></div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<div class="list-group list-custom-small">
|
<div class="list-group list-custom-small">
|
||||||
|
<?php if (false) { /* DARK MODE DISABLED (set menu height to 310) */ ?>
|
||||||
<a href="#" data-toggle-theme data-trigger-switch="switch-dark" class="pb-2">
|
<a href="#" data-toggle-theme data-trigger-switch="switch-dark" class="pb-2">
|
||||||
<i class="fa font-14 fa-moon rounded-s bg-dark1-dark color-white"></i>
|
<i class="fa font-14 fa-moon rounded-s bg-dark1-dark color-white"></i>
|
||||||
<span>Dark Mode</span>
|
<span>Dark Mode</span>
|
||||||
@@ -105,12 +106,13 @@
|
|||||||
<label class="custom-control-label" for="switch-dark"></label>
|
<label class="custom-control-label" for="switch-dark"></label>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
<?php } ?>
|
||||||
<a href="#" data-menu="menu-login" class="show-notloggedin">
|
<a href="#" data-menu="menu-login" class="show-notloggedin">
|
||||||
<i class="fa font-14 fa-sign-in-alt rounded-s bg-highlight color-white"></i>
|
<i class="fa font-14 fa-sign-in-alt rounded-s bg-highlight color-white"></i>
|
||||||
<span>Login</span>
|
<span>Login</span>
|
||||||
<i class="fa fa-angle-right"></i>
|
<i class="fa fa-angle-right"></i>
|
||||||
</a>
|
</a>
|
||||||
<a href="#" data-menu="menu-signup" class="show-notloggedin border-0">
|
<a href="#" data-menu="menu-signup" class="show-notloggedin">
|
||||||
<i class="fa font-14 fa-user-plus rounded-s bg-highlight color-white"></i>
|
<i class="fa font-14 fa-user-plus rounded-s bg-highlight color-white"></i>
|
||||||
<span>Registrieren</span>
|
<span>Registrieren</span>
|
||||||
<span class="badge bg-red2-dark color-white">FREE</span>
|
<span class="badge bg-red2-dark color-white">FREE</span>
|
||||||
@@ -120,45 +122,130 @@
|
|||||||
<span>Account</span>
|
<span>Account</span>
|
||||||
<i class="fa fa-angle-right"></i>
|
<i class="fa fa-angle-right"></i>
|
||||||
</a>
|
</a>
|
||||||
<a href="#" onclick="logout();" class="show-loggedin border-0">
|
<a href="#" onclick="logout();" class="show-loggedin">
|
||||||
<i class="fa font-14 fa-sign-out-alt rounded-s bg-highlight color-white"></i>
|
<i class="fa font-14 fa-sign-out-alt rounded-s bg-highlight color-white"></i>
|
||||||
<span>Logout</span>
|
<span>Logout</span>
|
||||||
<i class="fa fa-angle-right"></i>
|
<i class="fa fa-angle-right"></i>
|
||||||
</a>
|
</a>
|
||||||
|
<a href="#" onclick="pushesOpenMenu()" class="border-0">
|
||||||
|
<i class="fa font-14 fa-bell rounded-s bg-highlight color-white"></i>
|
||||||
|
<span>Benachrichtigungen</span>
|
||||||
|
<span id="badge-pushes" class="badge color-white"></span>
|
||||||
|
<i class="fa fa-angle-right"></i>
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="menu-developer" class="menu menu-box-bottom menu-box-detached rounded-m" data-menu-height="310">
|
<div id="menu-pushes" class="menu menu-box-bottom menu-box-detached rounded-m" data-menu-height="500">
|
||||||
|
<div class="menu-title"><h1>Benachrichtigungen</h1><p class="color-highlight">Bleibe immer auf dem aktuellen Stand</p><a href="#" class="close-menu"><i class="fa fa-times"></i></a></div>
|
||||||
|
<div class="divider divider-margins mb-n2"></div>
|
||||||
|
<div class="content">
|
||||||
|
<div class="list-group list-custom-small">
|
||||||
|
<a id="a-switch-pushes" href="#" data-trigger-switch="switch-pushes" class="pb-2">
|
||||||
|
<i class="fa font-14 fa-bell rounded-s bg-highlight color-white"></i>
|
||||||
|
<span>Benachrichtigungen aktivieren</span>
|
||||||
|
<div class="custom-control scale-switch ios-switch">
|
||||||
|
<input type="checkbox" class="ios-input" id="switch-pushes">
|
||||||
|
<label class="custom-control-label" for="switch-pushes"></label>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
<div class="divider"></div>
|
||||||
|
<p style="line-height: 1.5em;" id="p-pushes-info">
|
||||||
|
Wähle hier, über was Du informiert werden möchtest.<br>
|
||||||
|
(meine) bezieht sich auf die Regatten, die in Deiner Saison-Planung sind,<br>
|
||||||
|
(alle) informiert Dich über alle Regatten
|
||||||
|
</p>
|
||||||
|
<a href="#" data-trigger-switch="switch-pushes-news" class="pb-2 a-switch-pushes-channel-all">
|
||||||
|
<i class="fa font-14 fa-newspaper rounded-s bg-highlight color-white"></i>
|
||||||
|
<span>Neuigkeiten</span>
|
||||||
|
<div class="custom-control scale-switch ios-switch">
|
||||||
|
<input type="checkbox" class="ios-input" id="switch-pushes-news">
|
||||||
|
<label class="custom-control-label" for="switch-pushes-news"></label>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
<a href="#" data-trigger-switch="switch-pushes-regatta-changed-my" class="pb-2 a-switch-pushes-channel-my">
|
||||||
|
<i class="fa font-14 fa-calendar-check rounded-s bg-highlight color-white"></i>
|
||||||
|
<span>Regatta verschoben (meine)</span>
|
||||||
|
<span class="badge bg-red2-dark color-white"></span>
|
||||||
|
<div class="custom-control scale-switch ios-switch">
|
||||||
|
<input type="checkbox" class="ios-input" id="switch-pushes-regatta-changed-my">
|
||||||
|
<label class="custom-control-label" for="switch-pushes-regatta-changed-my"></label>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
<a href="#" data-trigger-switch="switch-pushes-regatta-changed-all" class="pb-2 a-switch-pushes-channel-all">
|
||||||
|
<i class="fa font-14 fa-calendar-check rounded-s bg-highlight color-white"></i>
|
||||||
|
<span>Regatta verschoben (alle)</span>
|
||||||
|
<div class="custom-control scale-switch ios-switch">
|
||||||
|
<input type="checkbox" class="ios-input" id="switch-pushes-regatta-changed-all">
|
||||||
|
<label class="custom-control-label" for="switch-pushes-regatta-changed-all"></label>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
<a href="#" data-trigger-switch="switch-pushes-result-ready-my" class="pb-2 a-switch-pushes-channel-my">
|
||||||
|
<i class="fa font-14 fa-poll rounded-s bg-highlight color-white"></i>
|
||||||
|
<span>Ergebnisse verfügbar (meine)</span>
|
||||||
|
<span class="badge bg-red2-dark color-white"></span>
|
||||||
|
<div class="custom-control scale-switch ios-switch">
|
||||||
|
<input type="checkbox" class="ios-input" id="switch-pushes-result-ready-my">
|
||||||
|
<label class="custom-control-label" for="switch-pushes-result-ready-my"></label>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
<a href="#" data-trigger-switch="switch-pushes-result-ready-all" class="pb-2 a-switch-pushes-channel-all">
|
||||||
|
<i class="fa font-14 fa-poll rounded-s bg-highlight color-white"></i>
|
||||||
|
<span>Ergebnisse verfügbar (alle)</span>
|
||||||
|
<div class="custom-control scale-switch ios-switch">
|
||||||
|
<input type="checkbox" class="ios-input" id="switch-pushes-result-ready-all">
|
||||||
|
<label class="custom-control-label" for="switch-pushes-result-ready-all"></label>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
<a href="#" data-trigger-switch="switch-pushes-meldeschluss" class="pb-2 a-switch-pushes-channel-my">
|
||||||
|
<i class="fa font-14 fa-file-signature rounded-s bg-highlight color-white"></i>
|
||||||
|
<span>Melde-Erinnerungen</span>
|
||||||
|
<span class="badge bg-red2-dark color-white"></span>
|
||||||
|
<div class="custom-control scale-switch ios-switch">
|
||||||
|
<input type="checkbox" class="ios-input" id="switch-pushes-meldeschluss">
|
||||||
|
<label class="custom-control-label" for="switch-pushes-meldeschluss"></label>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="menu-developer" class="menu menu-box-bottom menu-box-detached rounded-m" data-menu-height="360">
|
||||||
<div class="menu-title"><h1>Entwickler-Optionen</h1><p class="color-highlight">Version <?php echo PWA_VERSION; ?></p><a href="#" class="close-menu"><i class="fa fa-times"></i></a></div>
|
<div class="menu-title"><h1>Entwickler-Optionen</h1><p class="color-highlight">Version <?php echo PWA_VERSION; ?></p><a href="#" class="close-menu"><i class="fa fa-times"></i></a></div>
|
||||||
<div class="divider divider-margins mb-n2"></div>
|
<div class="divider divider-margins mb-n2"></div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<div class="list-group list-custom-small">
|
<div class="list-group list-custom-small">
|
||||||
<a href="https://info.ostertun.net/regatten/beta">
|
<a href="https://github.com/ostertun/RegattenApp/wiki">
|
||||||
<i class="fa font-14 fa-info rounded-s bg-highlight color-white"></i>
|
<i class="fa font-14 fa-info rounded-s bg-highlight color-white"></i>
|
||||||
<span>Infos zur BETA</span>
|
<span>App-Wiki</span>
|
||||||
<i class="fa fa-angle-right"></i>
|
<i class="fa fa-angle-right"></i>
|
||||||
</a>
|
</a>
|
||||||
<a href="javascript:resetDb(false);">
|
<a href="javascript:deleteDb();">
|
||||||
<i class="fa font-14 fa-database rounded-s bg-highlight color-white"></i>
|
<i class="fa font-14 fa-database rounded-s bg-highlight color-white"></i>
|
||||||
<span>Reset Database</span>
|
<span>Reset Database</span>
|
||||||
<i class="fa fa-angle-right"></i>
|
<i class="fa fa-angle-right"></i>
|
||||||
</a>
|
</a>
|
||||||
<a href="javascript:resetCache();">
|
<a href="javascript:deleteCache();">
|
||||||
<i class="fa font-14 fa-trash-alt rounded-s bg-highlight color-white"></i>
|
<i class="fa font-14 fa-trash-alt rounded-s bg-highlight color-white"></i>
|
||||||
<span>Reset Cache</span>
|
<span>Reset Cache</span>
|
||||||
<i class="fa fa-angle-right"></i>
|
<i class="fa fa-angle-right"></i>
|
||||||
</a>
|
</a>
|
||||||
<a href="https://report.regatten.net/" class="border-0">
|
<a href="https://github.com/ostertun/RegattenApp/issues">
|
||||||
<i class="fa font-14 fa-bug rounded-s bg-highlight color-white"></i>
|
<i class="fa font-14 fa-bug rounded-s bg-highlight color-white"></i>
|
||||||
<span>Problem melden</span>
|
<span>Problem melden</span>
|
||||||
<i class="fa fa-angle-right"></i>
|
<i class="fa fa-angle-right"></i>
|
||||||
</a>
|
</a>
|
||||||
|
<a href="#" onclick="mobileConsole.displayConsole(); return false;" class="border-0 menu-close">
|
||||||
|
<i class="fa font-14 fa-terminal rounded-s bg-highlight color-white"></i>
|
||||||
|
<span>Console anzeigen</span>
|
||||||
|
<i class="fa fa-angle-right"></i>
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="menu-login" class="menu menu-box-top menu-box-detached rounded-m" data-menu-height="270">
|
<div id="menu-login" class="menu menu-box-top menu-box-detached rounded-m" data-menu-height="320">
|
||||||
<div class="content bottom-0">
|
<div class="content bottom-0">
|
||||||
<h1 class="text-center mt-5 font-900">Login</h1>
|
<h1 class="text-center mt-5 font-900">Login</h1>
|
||||||
<div class="input-style input-style-2 has-icon input-required">
|
<div class="input-style input-style-2 has-icon input-required">
|
||||||
@@ -172,18 +259,29 @@
|
|||||||
<input id="input-login-password" class="form-control" type="password" placeholder="Passwort" />
|
<input id="input-login-password" class="form-control" type="password" placeholder="Passwort" />
|
||||||
</div>
|
</div>
|
||||||
<a class="btn btn-m mt-2 mb-2 btn-full bg-green2-dark text-uppercase font-900" href="#" onclick="login();">Login</a>
|
<a class="btn btn-m mt-2 mb-2 btn-full bg-green2-dark text-uppercase font-900" href="#" onclick="login();">Login</a>
|
||||||
|
<p class="text-center mt-3"><a class="text-uppercase font-900" href="https://regatten.net/reset">Benutzername oder Passwort vergessen</a></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="menu-signup" class="menu menu-box-modal menu-box-detached rounded-m" data-menu-height="300">
|
<div id="menu-signup" class="menu menu-box-top menu-box-detached rounded-m" data-menu-height="340">
|
||||||
<div class="content bottom-0">
|
<div class="content bottom-0">
|
||||||
<h1 class="text-center mt-5 font-900">Registrieren</h1>
|
<h1 class="text-center mt-5 font-900">Registrieren</h1>
|
||||||
<p class="text-center">
|
<div class="input-style input-style-2 has-icon input-required">
|
||||||
Momentan kannst Du Dich leider nicht in der App registrieren.<br>
|
<i class="input-icon fa fa-user color-theme"></i>
|
||||||
Das ist aber kein Problem, registriere Dich einfach kostenlos auf unserer Website!
|
<span class="color-highlight">Benutzername</span>
|
||||||
</p>
|
<input id="input-signup-username" class="form-control" type="name" placeholder="Benutzername" />
|
||||||
<a href="https://regatten.net/de/signup" class="btn btn-center-xl btn-m shadow-xl rounded-s bg-highlight font-900 text-center">Registrieren</a>
|
</div>
|
||||||
<p class="text-center font-10 bottom-0">Du kannst Dich danach in dieser App anmelden.</p>
|
<div class="input-style input-style-2 has-icon input-required">
|
||||||
|
<i class="input-icon fa fa-envelope color-theme"></i>
|
||||||
|
<span class="color-highlight">Email</span>
|
||||||
|
<input id="input-signup-email" class="form-control" type="email" placeholder="Email" />
|
||||||
|
</div>
|
||||||
|
<div class="input-style input-style-2 has-icon input-required">
|
||||||
|
<i class="input-icon fa fa-lock color-theme"></i>
|
||||||
|
<span class="color-highlight">Passwort</span>
|
||||||
|
<input id="input-signup-password" class="form-control" type="password" placeholder="Passwort" />
|
||||||
|
</div>
|
||||||
|
<a class="btn btn-m mt-2 mb-2 btn-full bg-green2-dark text-uppercase font-900" href="#" onclick="signup();">Registrieren</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -206,14 +304,17 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="menu-update">
|
<div id="menu-nodb-warning" class="menu menu-box-bottom menu-box-detached rounded-m" data-height="500">
|
||||||
|
<div class="menu-title"><h1>Warnung</h1><p class="color-highlight">Datenbank nicht unterstützt</p><a href="#" class="close-menu"><i class="fa fa-times"></i></a></div>
|
||||||
|
<div class="divider divider-margins mb-n2"></div>
|
||||||
<div class="content bottom-0">
|
<div class="content bottom-0">
|
||||||
<p class="text-center mt-5"><i class="fa fa-sync-alt fa-7x color-highlight fa-spin"></i></p>
|
<p>
|
||||||
<h1 class="text-center mt-5 font-900">Update Verfügbar</h1>
|
Das Speichern der benötigten Daten wird von Deinem Gerät nicht unterstützt.<br>
|
||||||
<p class="text-center">
|
Da deshalb die Daten jedesmal direkt vom Server geladen werden müssen, kannst Du die App nicht offline nutzen.<br>
|
||||||
Eine neue Version unserer App ist verfügbar. Keine Sorge, Du musst nichts machen. Wir aktuallisieren den Inhalt in wenigen Sekunden.
|
Das Nachladen kann außerdem gerade bei großen Datenmengen (wie Ranglisten) sehr lange dauern.
|
||||||
|
Wir empfehlen Dir daher, auf diesem Gerät unsere normale Website zu benutzen. Diese ist auch für Mobil-Geräte optimiert.
|
||||||
</p>
|
</p>
|
||||||
<a href="#" class="page-update btn btn-center-xl btn-m shadow-xl rounded-s bg-highlight font-900 text-center">Update</a>
|
<a class="btn btn-m mt-2 btn-full bg-highlight text-uppercase font-900" href="https://regatten.net/">Zur Website</a>
|
||||||
<p class="text-center font-10 bottom-0">Die App wird neu laden und das Update ist abgeschlossen.</p>
|
<a id="menu-nodb-warning-okay" class="btn btn-m mt-2 mb-3 btn-full bg-highlight text-uppercase font-900" href="#">Nicht erneut anzeigen</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
<html lang="de">
|
<html lang="de">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
|
<script type="text/javascript" src="<?php echo SERVER_ADDR; ?>/client/scripts/mobileconsole.js"></script>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
||||||
@@ -17,7 +18,7 @@
|
|||||||
<link rel="apple-touch-icon" sizes="180x180" href="<?php echo SERVER_ADDR; ?>/client/app/icons/icon-192x192.png">
|
<link rel="apple-touch-icon" sizes="180x180" href="<?php echo SERVER_ADDR; ?>/client/app/icons/icon-192x192.png">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body class="detect-theme" data-background="none" data-highlight="blue2">
|
<body class="theme-light" data-background="none" data-highlight="blue2"><?php /* DARK MODE DISABLED: set class to "detect-theme" */ ?>
|
||||||
|
|
||||||
<div id="preloader"><div class="spinner-border color-highlight" role="status"></div></div>
|
<div id="preloader"><div class="spinner-border color-highlight" role="status"></div></div>
|
||||||
|
|
||||||
@@ -26,7 +27,8 @@
|
|||||||
<?php include(__DIR__ . '/headerfooter.php'); ?>
|
<?php include(__DIR__ . '/headerfooter.php'); ?>
|
||||||
|
|
||||||
<!--start of page content, add your stuff here-->
|
<!--start of page content, add your stuff here-->
|
||||||
<div class="page-content header-clear-medium">
|
<div class="page-content header-clear">
|
||||||
|
<div id="syncstatus" class="text-right mr-2 mb-1">Zuletzt aktualisiert: nie</div>
|
||||||
<?php echo $sp['output']; ?>
|
<?php echo $sp['output']; ?>
|
||||||
</div>
|
</div>
|
||||||
<!--end of page content, off canvas elements here-->
|
<!--end of page content, off canvas elements here-->
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ async function onEditBoatnameClick() {
|
|||||||
if (xhr.status == 0) {
|
if (xhr.status == 0) {
|
||||||
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um den Bootsnamen zu bearbeiten');
|
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um den Bootsnamen zu bearbeiten');
|
||||||
} else {
|
} else {
|
||||||
console.log('EditBoatname: unbekannter Fehler', status, error);
|
log('EditBoatname: unbekannter Fehler', status, error);
|
||||||
console.log(xhr);
|
log(xhr);
|
||||||
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
|
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
|
||||||
}
|
}
|
||||||
hideLoader();
|
hideLoader();
|
||||||
|
|||||||
@@ -68,10 +68,10 @@ function addRace() {
|
|||||||
rlp: (100 * rlf * ((fb + 1 - pl) / fb))
|
rlp: (100 * rlf * ((fb + 1 - pl) / fb))
|
||||||
};
|
};
|
||||||
|
|
||||||
$('#input-rlf').val('');
|
$('#input-rlf').val('').trigger('focusin').trigger('focusout');
|
||||||
$('#input-m').val('');
|
$('#input-m').val('').trigger('focusin').trigger('focusout');
|
||||||
$('#input-fb').val('');
|
$('#input-fb').val('').trigger('focusin').trigger('focusout');
|
||||||
$('#input-pl').val('');
|
$('#input-pl').val('').trigger('focusin').trigger('focusout');
|
||||||
|
|
||||||
races.push(race);
|
races.push(race);
|
||||||
reCalc();
|
reCalc();
|
||||||
|
|||||||
@@ -23,16 +23,16 @@ function sendMessage() {
|
|||||||
if (xhr.status == 0) {
|
if (xhr.status == 0) {
|
||||||
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um eine Nachricht zu versenden');
|
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um eine Nachricht zu versenden');
|
||||||
} else {
|
} else {
|
||||||
console.log('Contact: unbekannter Fehler', status, error);
|
log('Contact: unbekannter Fehler', status, error);
|
||||||
console.log(xhr);
|
log(xhr);
|
||||||
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
|
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
|
||||||
}
|
}
|
||||||
hideLoader();
|
hideLoader();
|
||||||
},
|
},
|
||||||
success: function (data, status, xhr) {
|
success: function (data, status, xhr) {
|
||||||
toastOk('Nachricht erfolgreich versandt!');
|
toastOk('Nachricht erfolgreich versandt!');
|
||||||
$('#input-subject').val('');
|
$('#input-subject').val('').trigger('focusin').trigger('focusout');
|
||||||
$('#input-message').val('');
|
$('#input-message').val('').trigger('focusin').trigger('focusout');
|
||||||
hideLoader();
|
hideLoader();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
12
server/scripts/go2url.js
Normal file
12
server/scripts/go2url.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
var siteScript = function() {
|
||||||
|
hideLoader();
|
||||||
|
setTimeout(function() {
|
||||||
|
var url = findGetParameter('url');
|
||||||
|
if (url === null) {
|
||||||
|
$('#card-title').find('p').html('Wir konnten Dich leider nicht umleiten.<br><a href="' + LINK_PRE + 'index">Hier kommst Du zurück zur Startseite</a>');
|
||||||
|
} else {
|
||||||
|
showLoader();
|
||||||
|
location.href = url;
|
||||||
|
}
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
@@ -1,8 +1,84 @@
|
|||||||
|
var firstCall = true;
|
||||||
var today;
|
var today;
|
||||||
|
var onUpdatePushBadge;
|
||||||
|
|
||||||
|
var onUnfollowClicked = async function() {
|
||||||
|
var id = $('#menu-item-unfollow').attr('data-sailor-id');
|
||||||
|
showLoader();
|
||||||
|
$('#menu-favorite').hideMenu();
|
||||||
|
var auth = {
|
||||||
|
id: localStorage.getItem('auth_id'),
|
||||||
|
hash: localStorage.getItem('auth_hash')
|
||||||
|
}
|
||||||
|
$.ajax({
|
||||||
|
url: QUERY_URL + 'sailor_unfollow',
|
||||||
|
method: 'POST',
|
||||||
|
data: {
|
||||||
|
auth: auth,
|
||||||
|
sailor: id
|
||||||
|
},
|
||||||
|
error: function (xhr, status, error) {
|
||||||
|
if (xhr.status == 0) {
|
||||||
|
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um Deine Favoriten zu bearbeiten.');
|
||||||
|
} else {
|
||||||
|
log('Unfollow: 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();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var onFavoriteClicked = async function(id) {
|
||||||
|
var sailor = await dbGetData('sailors', id);
|
||||||
|
|
||||||
|
$('#menu-favorite').find('.menu-title').find('p').text(sailor.name);
|
||||||
|
|
||||||
|
$('#menu-item-unfollow').attr('data-sailor-id', sailor.id);
|
||||||
|
|
||||||
|
$('#menu-favorite').showMenu();
|
||||||
|
}
|
||||||
|
|
||||||
var siteScript = async function() {
|
var siteScript = async function() {
|
||||||
today = getToday();
|
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();
|
||||||
|
}
|
||||||
|
$('#menu-item-unfollow').click(onUnfollowClicked);
|
||||||
|
}
|
||||||
|
|
||||||
if (isLoggedIn()) {
|
if (isLoggedIn()) {
|
||||||
$('#card-notloggedin').hide();
|
$('#card-notloggedin').hide();
|
||||||
|
|
||||||
@@ -18,31 +94,41 @@ var siteScript = async function() {
|
|||||||
}
|
}
|
||||||
if (watched.length > 0) {
|
if (watched.length > 0) {
|
||||||
var year = (new Date()).getFullYear();
|
var year = (new Date()).getFullYear();
|
||||||
$('#th-ranking').html('Rangliste ' + year);
|
|
||||||
var ranking = (await dbGetRanking(parseDate('01.12.' + (year - 1)), parseDate('30.11.' + year), false, false))[0];
|
var ranking = (await dbGetRanking(parseDate('01.12.' + (year - 1)), parseDate('30.11.' + year), false, false))[0];
|
||||||
tbody = '';
|
var list = '';
|
||||||
for (i in watched) {
|
for (i in watched) {
|
||||||
sailor = watched[i];
|
sailor = watched[i];
|
||||||
tbody += '<tr><td>' + sailor.name + '</td><td>';
|
var club = null;
|
||||||
|
if (sailor.club != null)
|
||||||
|
club = await dbGetData('clubs', sailor.club);
|
||||||
var rank = null;
|
var rank = null;
|
||||||
for (r in ranking) {
|
for (r in ranking) {
|
||||||
if (ranking[r].id == sailor.id) {
|
if (ranking[r].id == sailor.id) {
|
||||||
rank = ranking[r].rank;
|
rank = ranking[r];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
list += '<div onclick="onFavoriteClicked(' + sailor.id + ');">';
|
||||||
|
list += '<div>';
|
||||||
|
// Name
|
||||||
|
list += '<div><b>' + sailor.name + '</b></div>';
|
||||||
|
list += '</div><div>';
|
||||||
if (rank == null) {
|
if (rank == null) {
|
||||||
tbody += '<i>nicht in der Rangliste</i>';
|
list += '<div>Nicht in der Rangliste</div>';
|
||||||
} else {
|
} else {
|
||||||
tbody += '<b>' + rank + '.</b> Platz';
|
// Rank
|
||||||
|
list += '<div>Platz <b>' + rank.rank + '</b></div>';
|
||||||
|
// rlp
|
||||||
|
list += '<div>' + rank.rlp.toFixed(3) + ' Punkte</div>';
|
||||||
}
|
}
|
||||||
tbody += '</td></tr>';
|
list += '</div></div>';
|
||||||
}
|
}
|
||||||
$('#table-favorites').find('tbody').html(tbody);
|
$('#div-favorites').html(list);
|
||||||
$('#p-favorites').hide();
|
$('#p-favorites').hide();
|
||||||
$('#table-favorites').show();
|
$('#div-favorites').show();
|
||||||
} else {
|
} else {
|
||||||
$('#table-favorites').hide();
|
$('#div-favorites').hide();
|
||||||
$('#p-favorites').show();
|
$('#p-favorites').show();
|
||||||
}
|
}
|
||||||
$('#card-favorites').show();
|
$('#card-favorites').show();
|
||||||
@@ -50,7 +136,7 @@ var siteScript = async function() {
|
|||||||
// Your next
|
// Your next
|
||||||
var planningsDB = await dbGetDataIndex('plannings', 'user', user.id);
|
var planningsDB = await dbGetDataIndex('plannings', 'user', user.id);
|
||||||
var minDate = getToday();
|
var minDate = getToday();
|
||||||
minDate.setDate(minDate.getDate() - 1);
|
minDate.setDate(minDate.getDate());
|
||||||
var maxDate = getToday();
|
var maxDate = getToday();
|
||||||
maxDate.setDate(maxDate.getDate() + 28);
|
maxDate.setDate(maxDate.getDate() + 28);
|
||||||
var regattas = await dbGetRegattasRange(minDate, maxDate);
|
var regattas = await dbGetRegattasRange(minDate, maxDate);
|
||||||
@@ -120,8 +206,10 @@ var siteScript = async function() {
|
|||||||
ms = parseDate(regatta['meldungSchluss']);
|
ms = parseDate(regatta['meldungSchluss']);
|
||||||
}
|
}
|
||||||
var diff = Math.round((ms - today) / 86400000);
|
var diff = Math.round((ms - today) / 86400000);
|
||||||
if ((ms >= today) && (diff < 7)) {
|
if (ms < today) {
|
||||||
color = ' color-red2-dark';
|
color = ' color-red2-dark';
|
||||||
|
} else if (diff < 7) {
|
||||||
|
color = ' color-yellow2-dark';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -164,7 +252,7 @@ var siteScript = async function() {
|
|||||||
|
|
||||||
// Next
|
// Next
|
||||||
var minDate = getToday();
|
var minDate = getToday();
|
||||||
minDate.setDate(minDate.getDate() - 1);
|
minDate.setDate(minDate.getDate());
|
||||||
var maxDate = getToday();
|
var maxDate = getToday();
|
||||||
maxDate.setDate(maxDate.getDate() + 14);
|
maxDate.setDate(maxDate.getDate() + 14);
|
||||||
var regattas = await dbGetRegattasRange(minDate, maxDate);
|
var regattas = await dbGetRegattasRange(minDate, maxDate);
|
||||||
@@ -227,8 +315,10 @@ var siteScript = async function() {
|
|||||||
ms = parseDate(regatta['meldungSchluss']);
|
ms = parseDate(regatta['meldungSchluss']);
|
||||||
}
|
}
|
||||||
var diff = Math.round((ms - today) / 86400000);
|
var diff = Math.round((ms - today) / 86400000);
|
||||||
if ((ms >= today) && (diff < 7)) {
|
if (ms < today) {
|
||||||
color = ' color-red2-dark';
|
color = ' color-red2-dark';
|
||||||
|
} else if (diff < 7) {
|
||||||
|
color = ' color-yellow2-dark';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -269,12 +359,9 @@ var siteScript = async function() {
|
|||||||
var maxDate = getToday();
|
var maxDate = getToday();
|
||||||
maxDate.setDate(maxDate.getDate() - 1);
|
maxDate.setDate(maxDate.getDate() - 1);
|
||||||
var regattas = await dbGetRegattasRange(minDate, maxDate);
|
var regattas = await dbGetRegattasRange(minDate, maxDate);
|
||||||
var regattaResults = [];
|
regattas.sort(function(a,b){
|
||||||
for (id in regattas) {
|
return b.date.localeCompare(a.date);
|
||||||
var entry = regattas[id];
|
});
|
||||||
var results = await dbGetDataIndex('results', 'regatta', entry['id']);
|
|
||||||
regattaResults[entry['id']] = (results.length > 0);
|
|
||||||
}
|
|
||||||
if (regattas.length > 0) {
|
if (regattas.length > 0) {
|
||||||
list = '';
|
list = '';
|
||||||
for (i in regattas) {
|
for (i in regattas) {
|
||||||
@@ -316,7 +403,7 @@ var siteScript = async function() {
|
|||||||
icons.push('<i class="fas fa-book"></i>');
|
icons.push('<i class="fas fa-book"></i>');
|
||||||
if (regatta['canceled'] == '1') {
|
if (regatta['canceled'] == '1') {
|
||||||
icons.push('<i class="fas fa-times color-red2-dark"></i>');
|
icons.push('<i class="fas fa-times color-red2-dark"></i>');
|
||||||
} else if (regattaResults[regatta['id']]) {
|
} else if (regatta['results'] == '1') {
|
||||||
icons.push('<i class="fas fa-poll"></i>');
|
icons.push('<i class="fas fa-poll"></i>');
|
||||||
}
|
}
|
||||||
list += '<div class="color-green2-dark">' + icons.join(' ') + '</div>';
|
list += '<div class="color-green2-dark">' + icons.join(' ') + '</div>';
|
||||||
|
|||||||
88
server/scripts/news.js
Normal file
88
server/scripts/news.js
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
var firstCall = true;
|
||||||
|
var rows = [];
|
||||||
|
var page = 1;
|
||||||
|
var pageCount = 0;
|
||||||
|
const showCount = 10;
|
||||||
|
|
||||||
|
async function onNewsClicked(id) {
|
||||||
|
var newsEntry = await dbGetData('news', id);
|
||||||
|
if (newsEntry == null) return;
|
||||||
|
|
||||||
|
$('#menu-news').css('height', '80%');
|
||||||
|
$('#menu-news').css('width', '90%');
|
||||||
|
$('#menu-news').find('.menu-title').find('p').text(newsEntry.title);
|
||||||
|
$('#menu-news').find('.content').addClass('pb-3');
|
||||||
|
$('#menu-news').find('.content').html(newsEntry.html);
|
||||||
|
|
||||||
|
$('#menu-news').showMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
function pageChange() {
|
||||||
|
$('h1')[0].scrollIntoView({ behavior: "smooth" });
|
||||||
|
drawList();
|
||||||
|
}
|
||||||
|
|
||||||
|
function addCard(newsEntry) {
|
||||||
|
var badge = '';
|
||||||
|
if (newsEntry.unread) {
|
||||||
|
badge += '<span class="badge bg-highlight color-white p-1">NEW</span> ';
|
||||||
|
}
|
||||||
|
var content = '<h2>' + badge + newsEntry.title + '</h2>';
|
||||||
|
content += '<p class="mb-2"><i>' + formatDate('d.m.Y', newsEntry.date) + '</i></p>';
|
||||||
|
content += '<p class="mb-0">' + newsEntry.description.replace('\n', '<br>') + '</p>';
|
||||||
|
if (newsEntry.html != '') {
|
||||||
|
content += '<a class="btn btn-full rounded-s text-uppercase font-900 shadow-m bg-highlight mt-3" href="#" onclick="onNewsClicked(' + newsEntry.id + '); return false;">Mehr lesen</a>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#news-entries').append(cardTemplate.replace('%ID%', 'card-news-' + newsEntry.id).replace('%CONTENT%', content));
|
||||||
|
}
|
||||||
|
|
||||||
|
async function drawList() {
|
||||||
|
$('.card-news').remove();
|
||||||
|
if (rows.length > 0) {
|
||||||
|
var offset = (page - 1) * showCount;
|
||||||
|
var count = (page == pageCount ? (rows.length % showCount) : showCount);
|
||||||
|
if (count == 0) count = showCount;
|
||||||
|
|
||||||
|
for (i = 0; i < count; i ++) {
|
||||||
|
addCard(rows[i + offset]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var siteScript = async function() {
|
||||||
|
if (firstCall) {
|
||||||
|
firstCall = false;
|
||||||
|
initPagination();
|
||||||
|
}
|
||||||
|
rows = [];
|
||||||
|
var news = await dbGetData('news');
|
||||||
|
news.sort(function (a,b) {
|
||||||
|
return b.date.localeCompare(a.date);
|
||||||
|
});
|
||||||
|
var newsRead = await dbSettingsGet('news_read_' + BOATCLASS);
|
||||||
|
var now = new Date();
|
||||||
|
var lastYear = new Date();
|
||||||
|
lastYear.setFullYear(lastYear.getFullYear() - 1);
|
||||||
|
for (var n in news) {
|
||||||
|
var newsEntry = news[n];
|
||||||
|
newsEntry.date = new Date(Date.parse(newsEntry.date));
|
||||||
|
if (newsEntry.date > now) continue;
|
||||||
|
if (newsEntry.date < lastYear) break;
|
||||||
|
newsEntry.unread = (newsEntry.date > newsRead);
|
||||||
|
rows.push(newsEntry);
|
||||||
|
}
|
||||||
|
pageCount = Math.ceil(rows.length / showCount);
|
||||||
|
if ((page < 1) || (page > pageCount)) {
|
||||||
|
if (page < 1) {
|
||||||
|
page = 1;
|
||||||
|
} else {
|
||||||
|
page = pageCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
drawPagination();
|
||||||
|
drawList();
|
||||||
|
dbSettingsSet('news_read_' + BOATCLASS, now);
|
||||||
|
updateNewsBadge();
|
||||||
|
hideLoader();
|
||||||
|
}
|
||||||
@@ -32,11 +32,26 @@ async function onRegattaClicked(id) {
|
|||||||
crew.push(sailor.name);
|
crew.push(sailor.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var status = '';
|
||||||
|
if (planning.gemeldet == '1') status = 'gemeldet';
|
||||||
|
if (planning.bezahlt == '1') {
|
||||||
|
if (status != '') status += ' und ';
|
||||||
|
status += 'bezahlt';
|
||||||
|
}
|
||||||
|
if (status != '') crew.push('<font style="font-style:italic;">' + status + '</font>');
|
||||||
$('#menu-item-yourplanning').html(crew.join('<br>'));
|
$('#menu-item-yourplanning').html(crew.join('<br>'));
|
||||||
} else {
|
} else {
|
||||||
$('#menu-item-yourplanning').hide();
|
$('#menu-item-yourplanning').hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Planning: Edit Status
|
||||||
|
if ((planning != null) && (typeof planningEditStatus === 'function')) {
|
||||||
|
$('#menu-item-status').show();
|
||||||
|
$('#menu-item-status').attr('onclick', 'planningEditStatus(' + regatta['id'] + ')');
|
||||||
|
} else {
|
||||||
|
$('#menu-item-status').hide();
|
||||||
|
}
|
||||||
|
|
||||||
// Planning
|
// Planning
|
||||||
if ((plannings.length > 0) && (dateTo >= today)) {
|
if ((plannings.length > 0) && (dateTo >= today)) {
|
||||||
$('#menu-item-plannings').show();
|
$('#menu-item-plannings').show();
|
||||||
@@ -46,8 +61,7 @@ async function onRegattaClicked(id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Results
|
// Results
|
||||||
var results = await dbGetDataIndex('results', 'regatta', regatta['id']);
|
if (regatta['results'] == '1') {
|
||||||
if (results.length > 0) {
|
|
||||||
$('#menu-item-results').show();
|
$('#menu-item-results').show();
|
||||||
$('#menu-item-results').attr('href', LINK_PRE + 'result?regatta=' + regatta['id']);
|
$('#menu-item-results').attr('href', LINK_PRE + 'result?regatta=' + regatta['id']);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
307
server/scripts/planning.js
Normal file
307
server/scripts/planning.js
Normal file
@@ -0,0 +1,307 @@
|
|||||||
|
async function planningSwitchChanged() {
|
||||||
|
showLoader();
|
||||||
|
var id = $('#switch-status-gemeldet').data('regatta');
|
||||||
|
var gemeldet = $('#switch-status-gemeldet').prop('checked');
|
||||||
|
var bezahlt = $('#switch-status-bezahlt').prop('checked');
|
||||||
|
var auth = {
|
||||||
|
id: localStorage.getItem('auth_id'),
|
||||||
|
hash: localStorage.getItem('auth_hash')
|
||||||
|
}
|
||||||
|
$.ajax({
|
||||||
|
url: QUERY_URL + 'planning_set_state',
|
||||||
|
method: 'POST',
|
||||||
|
data: {
|
||||||
|
auth: auth,
|
||||||
|
regatta: id,
|
||||||
|
gemeldet: gemeldet,
|
||||||
|
bezahlt: bezahlt
|
||||||
|
},
|
||||||
|
error: function (xhr, status, error) {
|
||||||
|
if (xhr.status == 401) {
|
||||||
|
log('authentification failed');
|
||||||
|
toastError('Authentifizierung fehlgeschlagen. Versuche es erneut.');
|
||||||
|
} else if (xhr.status == 0) {
|
||||||
|
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um den Status zu ändern');
|
||||||
|
} else {
|
||||||
|
log('Login: unbekannter Fehler', status, error);
|
||||||
|
log(xhr);
|
||||||
|
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
|
||||||
|
}
|
||||||
|
$('#menu-status').hideMenu();
|
||||||
|
hideLoader();
|
||||||
|
},
|
||||||
|
success: function (data, status, xhr) {
|
||||||
|
sync();
|
||||||
|
hideLoader();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function planningEditStatus(id) {
|
||||||
|
$('#menu-regatta').hideMenu();
|
||||||
|
|
||||||
|
var regatta = await dbGetData('regattas', id);
|
||||||
|
|
||||||
|
$('#menu-status').find('.menu-title').find('p').text(regatta.name);
|
||||||
|
|
||||||
|
var plannings = await dbGetDataIndex('plannings', 'regatta', regatta['id']);
|
||||||
|
var planning = null;
|
||||||
|
if (isLoggedIn()) {
|
||||||
|
for (i in plannings) {
|
||||||
|
if (plannings[i]['user'] == USER_ID) {
|
||||||
|
planning = plannings[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (planning !== null) {
|
||||||
|
$('#switch-status-gemeldet').data('regatta', id);
|
||||||
|
$('#switch-status-gemeldet').prop('checked', planning.gemeldet == '1');
|
||||||
|
$('#switch-status-bezahlt').prop('checked', planning.bezahlt == '1');
|
||||||
|
$('#menu-status').showMenu();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectChange() {
|
||||||
|
var val = $('#select-year').val();
|
||||||
|
|
||||||
|
if (typeof siteScript === 'function') {
|
||||||
|
history.replaceState(null, '', '?year=' + val);
|
||||||
|
showLoader();
|
||||||
|
siteScript();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function initYear() {
|
||||||
|
var year = findGetParameter('year');
|
||||||
|
if (year === null) year = new Date().getFullYear();
|
||||||
|
|
||||||
|
$('#select-year').html('<option value="' + year + '">' + year + '</option>');
|
||||||
|
$('#select-year').val(year);
|
||||||
|
}
|
||||||
|
|
||||||
|
var firstCall = true;
|
||||||
|
var rows = [];
|
||||||
|
var today;
|
||||||
|
|
||||||
|
async function drawList () {
|
||||||
|
window.setTimeout(function () {
|
||||||
|
var list = '';
|
||||||
|
rows.forEach(function (entry) {
|
||||||
|
if (entry == null) {
|
||||||
|
list += '<div><div align="center" class="color-highlight"><b>Heute ist der ' + formatDate('d.m.Y', today) + '</b></div></div>';
|
||||||
|
} else if (search($('#input-search').val(), entry.keywords)) {
|
||||||
|
list += entry.content;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('#div-regattas').html(list);
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
var siteScript = async function() {
|
||||||
|
if (!isLoggedIn()) {
|
||||||
|
hideLoader();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (firstCall) {
|
||||||
|
firstCall = false;
|
||||||
|
initYear();
|
||||||
|
$('#select-year').change(selectChange);
|
||||||
|
$('#input-search').on('input', drawList);
|
||||||
|
$('#switch-status-gemeldet').parent().parent().click(planningSwitchChanged);
|
||||||
|
$('#switch-status-bezahlt').parent().parent().click(planningSwitchChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#a-share-planning').attr('href', LINK_PRE + 'planning_view?user=' + USER_ID);
|
||||||
|
|
||||||
|
today = getToday();
|
||||||
|
|
||||||
|
var selectedYear = $('#select-year').val();
|
||||||
|
var minDate = parseDate(selectedYear + '-01-01');
|
||||||
|
var maxDate = parseDate(selectedYear + '-12-31');
|
||||||
|
var regattas = await dbGetRegattasRange(minDate, maxDate);
|
||||||
|
var plannings = await dbGetDataIndex('plannings', 'user', USER_ID);
|
||||||
|
for (var i = regattas.length - 1; i >= 0; i --) {
|
||||||
|
var entry = regattas[i];
|
||||||
|
var okay = false;
|
||||||
|
for (p in plannings) {
|
||||||
|
if (plannings[p].regatta == entry.id) {
|
||||||
|
regattas[i].planning = plannings[p];
|
||||||
|
okay = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!okay) {
|
||||||
|
regattas.splice(i, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var years = await dbGetData('years');
|
||||||
|
years.sort(function (a, b) {
|
||||||
|
if (a['year'] > b['year']) return -1;
|
||||||
|
if (a['year'] < b['year']) return 1;
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
var options = '';
|
||||||
|
for (id in years) {
|
||||||
|
var year = years[id]['year'];
|
||||||
|
options += '<option value="' + year + '">' + year + '</option>';
|
||||||
|
}
|
||||||
|
$('#select-year').html(options);
|
||||||
|
$('#select-year').val(selectedYear);
|
||||||
|
|
||||||
|
var count = regattas.length;
|
||||||
|
if (count > 0) {
|
||||||
|
if (count == 1) {
|
||||||
|
$('#p-count').html('Es wurde 1 Regatta gefunden!');
|
||||||
|
} else {
|
||||||
|
$('#p-count').html('Es wurden ' + count + ' Regatten gefunden!');
|
||||||
|
}
|
||||||
|
$('#div-regattas').show();
|
||||||
|
$('#input-search').parent().show();
|
||||||
|
|
||||||
|
var heute = false;
|
||||||
|
|
||||||
|
rows = [];
|
||||||
|
|
||||||
|
for (id in regattas) {
|
||||||
|
var entry = regattas[id];
|
||||||
|
var club = null;
|
||||||
|
if (entry['club'] != null)
|
||||||
|
club = await dbGetData('clubs', entry['club']);
|
||||||
|
if (entry.planning.steuermann !== null) {
|
||||||
|
entry.planning.steuermann = (await dbGetData('sailors', entry.planning.steuermann)).name;
|
||||||
|
}
|
||||||
|
var crewString = entry.planning.crew.split(',');
|
||||||
|
entry.planning.crew = [];
|
||||||
|
for (c in crewString) {
|
||||||
|
var sailor = await dbGetData('sailors', crewString[c]);
|
||||||
|
if (sailor !== null) {
|
||||||
|
entry.planning.crew.push(sailor.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var dateFrom = entry['dateFrom'];
|
||||||
|
var dateTo = entry['dateTo'];
|
||||||
|
|
||||||
|
var row = { keywords: [], content: '' };
|
||||||
|
row.keywords.push(entry['name']);
|
||||||
|
if (entry['number'] != null) row.keywords.push(entry['number']);
|
||||||
|
if (club != null) row.keywords.push(club['kurz'], club['name']);
|
||||||
|
if (entry.planning.steuermann != null) row.keywords.push(entry.planning.steuermann);
|
||||||
|
for (c in entry.planning.crew) row.keywords.push(entry.planning.crew[c]);
|
||||||
|
|
||||||
|
if (!heute && (today <= dateFrom)) {
|
||||||
|
rows.push(null);
|
||||||
|
heute = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
row.content += '<div onclick="onRegattaClicked(' + entry['id'] + ');">';
|
||||||
|
|
||||||
|
// ZEILE 1
|
||||||
|
// Name
|
||||||
|
row.content += '<div><b>' + (entry['canceled'] == 1 ? '<s>' : '') + entry['name'] + (entry['canceled'] == 1 ? '</s>' : '') + '</b></div>';
|
||||||
|
|
||||||
|
// ZEILE 2
|
||||||
|
row.content += '<div>';
|
||||||
|
|
||||||
|
// Number
|
||||||
|
row.content += '<div>' + ((entry['number'] != null) ? ('# ' + entry['number']) : '') + '</div>';
|
||||||
|
|
||||||
|
// Club
|
||||||
|
row.content += '<div>' + ((club != null) ? club['kurz'] : '') + '</div>';
|
||||||
|
|
||||||
|
// Special
|
||||||
|
row.content += '<div>' + entry['special'] + '</div>';
|
||||||
|
|
||||||
|
// Icons
|
||||||
|
var icons = [];
|
||||||
|
if ((entry['meldung'] != '') && (dateTo >= today) && (entry['meldungOffen'] == '1') && (entry.planning.gemeldet != '1')) {
|
||||||
|
var color = '';
|
||||||
|
var planning = null;
|
||||||
|
if (isLoggedIn()) {
|
||||||
|
var plannings = await dbGetDataIndex('plannings', 'regatta', entry['id']);
|
||||||
|
for (id in plannings) {
|
||||||
|
if (plannings[id]['user'] == USER_ID) {
|
||||||
|
planning = plannings[id];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (entry['meldungSchluss'] != null) {
|
||||||
|
if ((planning == null) || (planning['gemeldet'] == '0')) {
|
||||||
|
var ms = 0;
|
||||||
|
if (entry['meldungEarly'] != null) {
|
||||||
|
ms = parseDate(entry['meldungEarly']);
|
||||||
|
}
|
||||||
|
if (ms < today) {
|
||||||
|
ms = parseDate(entry['meldungSchluss']);
|
||||||
|
}
|
||||||
|
var diff = Math.round((ms - today) / 86400000);
|
||||||
|
if (ms < today) {
|
||||||
|
color = ' color-red2-dark';
|
||||||
|
} else if (diff < 7) {
|
||||||
|
color = ' color-yellow2-dark';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((planning != null) && (planning['gemeldet'] == '0')) {
|
||||||
|
color += ' fa-blink';
|
||||||
|
}
|
||||||
|
icons.push('<i class="fas fa-file-signature' + color + '"></i>');
|
||||||
|
}
|
||||||
|
if (entry['bericht'] != '')
|
||||||
|
icons.push('<i class="fas fa-book"></i>');
|
||||||
|
if (entry['canceled'] == '1') {
|
||||||
|
icons.push('<i class="fas fa-times color-red2-dark"></i>');
|
||||||
|
} else if (entry['results'] == '1') {
|
||||||
|
icons.push('<i class="fas fa-poll"></i>');
|
||||||
|
}
|
||||||
|
if (entry.planning.gemeldet == '1') {
|
||||||
|
icons.push('<i class="fas fa-file-signature color-highlight"></i>');
|
||||||
|
}
|
||||||
|
if (entry.planning.bezahlt == '1') {
|
||||||
|
icons.push('<i class="fas fa-euro-sign color-highlight"></i>');
|
||||||
|
}
|
||||||
|
row.content += '<div class="color-green2-dark">' + icons.join(' ') + '</div>';
|
||||||
|
|
||||||
|
row.content += '</div>';
|
||||||
|
|
||||||
|
// ZEILE 3
|
||||||
|
row.content += '<div>';
|
||||||
|
|
||||||
|
// Date
|
||||||
|
if (entry['length'] < 1) {
|
||||||
|
if (formatDate('d.m', dateFrom) == '01.01') {
|
||||||
|
row.content += '<div><font class="color-red2-dark">Datum noch unklar</font></div>';
|
||||||
|
} else {
|
||||||
|
row.content += '<div>' + formatDate("d.m.Y", dateFrom) + ' - <font class="color-red2-dark">Datum nicht final</font></div>';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
row.content += '<div>' + formatDate("d.m.Y", dateFrom) + ' - ' + formatDate("d.m.Y", dateTo) + '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// RLF
|
||||||
|
row.content += '<div>' + parseFloat(entry['rlf']).toFixed(2) + '</div>';
|
||||||
|
|
||||||
|
row.content += '</div></div>';
|
||||||
|
|
||||||
|
rows.push(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!heute) {
|
||||||
|
rows.push(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
drawList();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$('#p-count').html('Du hast noch keine Regatten in Deiner Saison-Planung!');
|
||||||
|
$('#div-regattas').hide();
|
||||||
|
$('#input-search').parent().hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
hideLoader();
|
||||||
|
}
|
||||||
474
server/scripts/planning_edit.js
Normal file
474
server/scripts/planning_edit.js
Normal file
@@ -0,0 +1,474 @@
|
|||||||
|
async function planningSwitchChanged() {
|
||||||
|
showLoader();
|
||||||
|
var id = $('#switch-planning-include').data('regatta');
|
||||||
|
var include = $('#switch-planning-include').prop('checked');
|
||||||
|
var auth = {
|
||||||
|
id: localStorage.getItem('auth_id'),
|
||||||
|
hash: localStorage.getItem('auth_hash')
|
||||||
|
}
|
||||||
|
if (include) {
|
||||||
|
// add to planning
|
||||||
|
$.ajax({
|
||||||
|
url: QUERY_URL + 'planning_add',
|
||||||
|
method: 'POST',
|
||||||
|
data: {
|
||||||
|
auth: auth,
|
||||||
|
regatta: id
|
||||||
|
},
|
||||||
|
error: function (xhr, status, error) {
|
||||||
|
if (xhr.status == 401) {
|
||||||
|
log('authentification failed');
|
||||||
|
toastError('Authentifizierung fehlgeschlagen. Versuche es erneut.');
|
||||||
|
} else if (xhr.status == 0) {
|
||||||
|
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um die Änderungen zu speichern');
|
||||||
|
} else {
|
||||||
|
log('planning_add: unbekannter Fehler', status, error);
|
||||||
|
log(xhr);
|
||||||
|
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
|
||||||
|
}
|
||||||
|
$('#menu-edit').hideMenu();
|
||||||
|
hideLoader();
|
||||||
|
},
|
||||||
|
success: async function (data, status, xhr) {
|
||||||
|
await sync();
|
||||||
|
planningEdit(id);
|
||||||
|
hideLoader();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// remove from planning
|
||||||
|
$.ajax({
|
||||||
|
url: QUERY_URL + 'planning_remove',
|
||||||
|
method: 'POST',
|
||||||
|
data: {
|
||||||
|
auth: auth,
|
||||||
|
regatta: id
|
||||||
|
},
|
||||||
|
error: function (xhr, status, error) {
|
||||||
|
if (xhr.status == 401) {
|
||||||
|
log('authentification failed');
|
||||||
|
toastError('Authentifizierung fehlgeschlagen. Versuche es erneut.');
|
||||||
|
} else if (xhr.status == 0) {
|
||||||
|
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um die Änderungen zu speichern');
|
||||||
|
} else {
|
||||||
|
log('planning_remove: unbekannter Fehler', status, error);
|
||||||
|
log(xhr);
|
||||||
|
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
|
||||||
|
}
|
||||||
|
$('#menu-edit').hideMenu();
|
||||||
|
hideLoader();
|
||||||
|
},
|
||||||
|
success: async function (data, status, xhr) {
|
||||||
|
await sync();
|
||||||
|
planningEdit(id);
|
||||||
|
hideLoader();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var sailorIsSteuermann;
|
||||||
|
var sailors = [];
|
||||||
|
|
||||||
|
async function sailorSelected(sid) {
|
||||||
|
$('#menu-sailor').hideMenu();
|
||||||
|
showLoader();
|
||||||
|
var rid = $('#switch-planning-include').data('regatta');
|
||||||
|
var action = (sailorIsSteuermann ? 'planning_set_steuermann' : 'planning_add_crew');
|
||||||
|
// add sailor
|
||||||
|
var auth = {
|
||||||
|
id: localStorage.getItem('auth_id'),
|
||||||
|
hash: localStorage.getItem('auth_hash')
|
||||||
|
}
|
||||||
|
$.ajax({
|
||||||
|
url: QUERY_URL + action,
|
||||||
|
method: 'POST',
|
||||||
|
data: {
|
||||||
|
auth: auth,
|
||||||
|
regatta: rid,
|
||||||
|
sailor: sid
|
||||||
|
},
|
||||||
|
error: function (xhr, status, error) {
|
||||||
|
if (xhr.status == 401) {
|
||||||
|
log('authentification failed');
|
||||||
|
toastError('Authentifizierung fehlgeschlagen. Versuche es erneut.');
|
||||||
|
} else if (xhr.status == 0) {
|
||||||
|
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um die Änderungen zu speichern');
|
||||||
|
} else {
|
||||||
|
log(action + ': 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();
|
||||||
|
planningEdit(rid);
|
||||||
|
hideLoader();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function sailorsSearch() {
|
||||||
|
$('.item-sailor-search').remove();
|
||||||
|
if (sailorIsSteuermann) {
|
||||||
|
var item = '<a class="item-sailor-search" onclick="sailorSelected(null)">';
|
||||||
|
item += '<span style="font-style:italic;">noch unklar</span>';
|
||||||
|
item += '<i class="fa fa-angle-right"></i>';
|
||||||
|
item += '</a>';
|
||||||
|
$('#menu-sailor').find('.content').find('.list-group').append(item);
|
||||||
|
}
|
||||||
|
if ($('#input-edit-search').val().length >= 3) {
|
||||||
|
sailors.forEach(function (entry) {
|
||||||
|
if (search($('#input-edit-search').val(), entry.keywords)) {
|
||||||
|
$('#menu-sailor').find('.content').find('.list-group').append(entry.content);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
var item = '<p class="item-sailor-search">Gib mindestens 3 Zeichen ein</p>';
|
||||||
|
$('#menu-sailor').find('.content').find('.list-group').append(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function initSailors() {
|
||||||
|
sailors = [];
|
||||||
|
var dbSailors = await dbGetData('sailors');
|
||||||
|
dbSailors.sort(function(a,b){
|
||||||
|
return a.name.localeCompare(b.name);
|
||||||
|
});
|
||||||
|
for (s in dbSailors) {
|
||||||
|
var item = '<a class="item-sailor-search" onclick="sailorSelected(' + dbSailors[s].id + ')">';
|
||||||
|
item += '<span>' + dbSailors[s].name + '</span>';
|
||||||
|
item += '<i class="fa fa-angle-right"></i>';
|
||||||
|
item += '</a>';
|
||||||
|
sailors.push({
|
||||||
|
keywords: [dbSailors[s].name],
|
||||||
|
content: item
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function planningChangeCrew(sid = null) {
|
||||||
|
if (sid !== null) {
|
||||||
|
showLoader();
|
||||||
|
var rid = $('#switch-planning-include').data('regatta');
|
||||||
|
// remove sailor
|
||||||
|
var auth = {
|
||||||
|
id: localStorage.getItem('auth_id'),
|
||||||
|
hash: localStorage.getItem('auth_hash')
|
||||||
|
}
|
||||||
|
$.ajax({
|
||||||
|
url: QUERY_URL + 'planning_remove_crew',
|
||||||
|
method: 'POST',
|
||||||
|
data: {
|
||||||
|
auth: auth,
|
||||||
|
regatta: rid,
|
||||||
|
sailor: sid
|
||||||
|
},
|
||||||
|
error: function (xhr, status, error) {
|
||||||
|
if (xhr.status == 401) {
|
||||||
|
log('authentification failed');
|
||||||
|
toastError('Authentifizierung fehlgeschlagen. Versuche es erneut.');
|
||||||
|
} else if (xhr.status == 0) {
|
||||||
|
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um die Änderungen zu speichern');
|
||||||
|
} else {
|
||||||
|
log('planning_remove_crew: unbekannter Fehler', status, error);
|
||||||
|
log(xhr);
|
||||||
|
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
|
||||||
|
}
|
||||||
|
$('#menu-edit').hideMenu();
|
||||||
|
hideLoader();
|
||||||
|
},
|
||||||
|
success: async function (data, status, xhr) {
|
||||||
|
await sync();
|
||||||
|
planningEdit(rid);
|
||||||
|
hideLoader();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
sailorIsSteuermann = false;
|
||||||
|
$('#input-edit-search').val('').trigger('focusin').trigger('focusout');
|
||||||
|
sailorsSearch();
|
||||||
|
$('#menu-edit').hideMenu();
|
||||||
|
$('#menu-sailor').find('.menu-title').find('h1').text('Crew hinzufügen');
|
||||||
|
$('#menu-sailor').showMenu();
|
||||||
|
$('#input-edit-search').focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function planningChangeSteuermann() {
|
||||||
|
sailorIsSteuermann = true;
|
||||||
|
$('#input-edit-search').val('').trigger('focusin').trigger('focusout');
|
||||||
|
sailorsSearch();
|
||||||
|
$('#menu-edit').hideMenu();
|
||||||
|
$('#menu-sailor').find('.menu-title').find('h1').text('Steuermann/-frau bearbeiten');
|
||||||
|
$('#menu-sailor').showMenu();
|
||||||
|
$('#input-edit-search').focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function planningEdit(id) {
|
||||||
|
var regatta = await dbGetData('regattas', id);
|
||||||
|
|
||||||
|
$('#menu-edit').find('.menu-title').find('p').text(regatta.name);
|
||||||
|
|
||||||
|
var plannings = await dbGetDataIndex('plannings', 'regatta', regatta['id']);
|
||||||
|
var planning = null;
|
||||||
|
if (isLoggedIn()) {
|
||||||
|
for (i in plannings) {
|
||||||
|
if (plannings[i]['user'] == USER_ID) {
|
||||||
|
planning = plannings[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#switch-planning-include').data('regatta', id);
|
||||||
|
if (planning !== null) {
|
||||||
|
$('#switch-planning-include').prop('checked', true);
|
||||||
|
$('#item-steuermann').show();
|
||||||
|
if (planning.steuermann !== null) {
|
||||||
|
$('#item-steuermann').find('span').text('Am Steuer: ' + (await dbGetData('sailors', planning.steuermann)).name);
|
||||||
|
} else {
|
||||||
|
$('#item-steuermann').find('span').html('Am Steuer: <font style="font-style:italic;">noch unklar</font>');
|
||||||
|
}
|
||||||
|
$('.item-crew').remove();
|
||||||
|
var crew = planning.crew.split(',');
|
||||||
|
for (c in crew) {
|
||||||
|
var sailor = await dbGetData('sailors', crew[c]);
|
||||||
|
if (sailor !== null) {
|
||||||
|
var item = '<a class="item-crew" onclick="planningChangeCrew(' + sailor.id + ')">';
|
||||||
|
item += '<span>' + sailor.name + '</span>';
|
||||||
|
item += '<i class="fa fa-angle-right"></i>';
|
||||||
|
item += '</a>';
|
||||||
|
$('#menu-edit').find('.content').find('.list-group').append(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var item = '<a class="item-crew" onclick="planningChangeCrew()">';
|
||||||
|
item += '<span style="font-style:italic;">Weiteren Segler hinzufügen</span>';
|
||||||
|
item += '<i class="fa fa-angle-right"></i>';
|
||||||
|
item += '</a>';
|
||||||
|
$('#menu-edit').find('.content').find('.list-group').append(item);
|
||||||
|
} else {
|
||||||
|
$('#switch-planning-include').prop('checked', false);
|
||||||
|
$('#item-steuermann').hide();
|
||||||
|
$('.item-crew').remove();
|
||||||
|
}
|
||||||
|
$('#menu-edit').showMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectChange() {
|
||||||
|
var val = $('#select-year').val();
|
||||||
|
|
||||||
|
if (typeof siteScript === 'function') {
|
||||||
|
history.replaceState(null, '', '?year=' + val);
|
||||||
|
showLoader();
|
||||||
|
siteScript();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function initYear() {
|
||||||
|
var year = findGetParameter('year');
|
||||||
|
if (year === null) year = new Date().getFullYear();
|
||||||
|
|
||||||
|
$('#select-year').html('<option value="' + year + '">' + year + '</option>');
|
||||||
|
$('#select-year').val(year);
|
||||||
|
}
|
||||||
|
|
||||||
|
var firstCall = true;
|
||||||
|
var rows = [];
|
||||||
|
var today;
|
||||||
|
|
||||||
|
async function drawList () {
|
||||||
|
window.setTimeout(function () {
|
||||||
|
var list = '';
|
||||||
|
rows.forEach(function (entry) {
|
||||||
|
if (entry == null) {
|
||||||
|
list += '<div><div align="center" class="color-highlight"><b>Heute ist der ' + formatDate('d.m.Y', today) + '</b></div></div>';
|
||||||
|
} else if (search($('#input-search').val(), entry.keywords)) {
|
||||||
|
list += entry.content;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('#div-regattas').html(list);
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
var siteScript = async function() {
|
||||||
|
if (!isLoggedIn()) {
|
||||||
|
location.href = LINK_PRE + 'planning';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (firstCall) {
|
||||||
|
firstCall = false;
|
||||||
|
initYear();
|
||||||
|
$('#select-year').change(selectChange);
|
||||||
|
$('#input-search').on('input', drawList);
|
||||||
|
$('#switch-planning-include').parent().parent().click(planningSwitchChanged);
|
||||||
|
$('#item-steuermann').click(planningChangeSteuermann);
|
||||||
|
$('#input-edit-search').on('input', sailorsSearch);
|
||||||
|
initSailors();
|
||||||
|
}
|
||||||
|
|
||||||
|
today = getToday();
|
||||||
|
|
||||||
|
var selectedYear = $('#select-year').val();
|
||||||
|
var minDate = parseDate(selectedYear + '-01-01');
|
||||||
|
var maxDate = parseDate(selectedYear + '-12-31');
|
||||||
|
var regattas = await dbGetRegattasRange(minDate, maxDate);
|
||||||
|
var plannings = await dbGetDataIndex('plannings', 'user', USER_ID);
|
||||||
|
for (var i = regattas.length - 1; i >= 0; i --) {
|
||||||
|
var entry = regattas[i];
|
||||||
|
var okay = false;
|
||||||
|
for (p in plannings) {
|
||||||
|
if (plannings[p].regatta == entry.id) {
|
||||||
|
regattas[i].planning = plannings[p];
|
||||||
|
okay = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!okay) {
|
||||||
|
regattas[i].planning = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var years = await dbGetData('years');
|
||||||
|
years.sort(function (a, b) {
|
||||||
|
if (a['year'] > b['year']) return -1;
|
||||||
|
if (a['year'] < b['year']) return 1;
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
var options = '';
|
||||||
|
for (id in years) {
|
||||||
|
var year = years[id]['year'];
|
||||||
|
options += '<option value="' + year + '">' + year + '</option>';
|
||||||
|
}
|
||||||
|
$('#select-year').html(options);
|
||||||
|
$('#select-year').val(selectedYear);
|
||||||
|
|
||||||
|
var count = regattas.length;
|
||||||
|
if (count > 0) {
|
||||||
|
if (count == 1) {
|
||||||
|
$('#p-count').html('Es wurde 1 Regatta gefunden!');
|
||||||
|
} else {
|
||||||
|
$('#p-count').html('Es wurden ' + count + ' Regatten gefunden!');
|
||||||
|
}
|
||||||
|
$('#div-regattas').show();
|
||||||
|
$('#input-search').parent().show();
|
||||||
|
|
||||||
|
var heute = false;
|
||||||
|
|
||||||
|
rows = [];
|
||||||
|
|
||||||
|
for (id in regattas) {
|
||||||
|
var entry = regattas[id];
|
||||||
|
var club = null;
|
||||||
|
if (entry['club'] != null)
|
||||||
|
club = await dbGetData('clubs', entry['club']);
|
||||||
|
if (entry.planning !== null) {
|
||||||
|
if (entry.planning.steuermann !== null) {
|
||||||
|
entry.planning.steuermann = (await dbGetData('sailors', entry.planning.steuermann)).name;
|
||||||
|
}
|
||||||
|
var crewString = entry.planning.crew.split(',');
|
||||||
|
entry.planning.crew = [];
|
||||||
|
for (c in crewString) {
|
||||||
|
var sailor = await dbGetData('sailors', crewString[c]);
|
||||||
|
if (sailor !== null) {
|
||||||
|
entry.planning.crew.push(sailor.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var dateFrom = entry['dateFrom'];
|
||||||
|
var dateTo = entry['dateTo'];
|
||||||
|
|
||||||
|
var row = { keywords: [], content: '' };
|
||||||
|
row.keywords.push(entry['name']);
|
||||||
|
if (entry['number'] != null) row.keywords.push(entry['number']);
|
||||||
|
if (club != null) row.keywords.push(club['kurz'], club['name']);
|
||||||
|
|
||||||
|
if (!heute && (today <= dateFrom)) {
|
||||||
|
rows.push(null);
|
||||||
|
heute = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entry.planning !== null) {
|
||||||
|
row.content += '<div onclick="planningEdit(' + entry['id'] + ');">';
|
||||||
|
} else {
|
||||||
|
row.content += '<div onclick="planningEdit(' + entry['id'] + ');" style="opacity:0.5;">';
|
||||||
|
}
|
||||||
|
|
||||||
|
// ZEILE 1
|
||||||
|
// Name
|
||||||
|
row.content += '<div><b>' + (entry['canceled'] == 1 ? '<s>' : '') + entry['name'] + (entry['canceled'] == 1 ? '</s>' : '') + '</b></div>';
|
||||||
|
|
||||||
|
// ZEILE 2
|
||||||
|
row.content += '<div>';
|
||||||
|
|
||||||
|
// Number
|
||||||
|
row.content += '<div>' + ((entry['number'] != null) ? ('# ' + entry['number']) : '') + '</div>';
|
||||||
|
|
||||||
|
// Special
|
||||||
|
row.content += '<div>' + entry['special'] + '</div>';
|
||||||
|
|
||||||
|
// Club
|
||||||
|
row.content += '<div>' + ((club != null) ? club['kurz'] : '') + '</div>';
|
||||||
|
|
||||||
|
row.content += '</div>';
|
||||||
|
|
||||||
|
// ZEILE 3
|
||||||
|
row.content += '<div>';
|
||||||
|
|
||||||
|
// Date
|
||||||
|
if (entry['length'] < 1) {
|
||||||
|
if (formatDate('d.m', dateFrom) == '01.01') {
|
||||||
|
row.content += '<div><font class="color-red2-dark">Datum noch unklar</font></div>';
|
||||||
|
} else {
|
||||||
|
row.content += '<div>' + formatDate("d.m.Y", dateFrom) + ' - <font class="color-red2-dark">Datum nicht final</font></div>';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
row.content += '<div>' + formatDate("d.m.Y", dateFrom) + ' - ' + formatDate("d.m.Y", dateTo) + '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// RLF
|
||||||
|
row.content += '<div>' + parseFloat(entry['rlf']).toFixed(2) + '</div>';
|
||||||
|
|
||||||
|
row.content += '</div>';
|
||||||
|
|
||||||
|
if (entry.planning !== null) {
|
||||||
|
// ZEILE 4
|
||||||
|
row.content += '<div></div>';
|
||||||
|
|
||||||
|
// ZEILE 5
|
||||||
|
row.content += '<div>';
|
||||||
|
row.content += '<div>' + (entry.planning.steuermann !== null ? entry.planning.steuermann : 'noch unklar') + '</div>';
|
||||||
|
row.content += '</div>';
|
||||||
|
|
||||||
|
// ZEILE 6...
|
||||||
|
for (var i in entry.planning.crew) {
|
||||||
|
row.content += '<div>';
|
||||||
|
row.content += '<div>' + entry.planning.crew[i] + '</div>';
|
||||||
|
row.content += '</div>';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
row.content += '<div>Du planst nicht, hierhin zu fahren</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
row.content += '</div>';
|
||||||
|
|
||||||
|
rows.push(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!heute) {
|
||||||
|
rows.push(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
drawList();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$('#p-count').html('Keine Regatten gefunden!');
|
||||||
|
$('#div-regattas').hide();
|
||||||
|
$('#input-search').parent().hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
hideLoader();
|
||||||
|
}
|
||||||
147
server/scripts/planning_list.js
Normal file
147
server/scripts/planning_list.js
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
async function onUserClicked(id) {
|
||||||
|
var user = await dbGetData('users', id);
|
||||||
|
if (user !== null) {
|
||||||
|
location.href = LINK_PRE + 'planning_view?user=' + user.id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectChange() {
|
||||||
|
var val = $('#select-year').val();
|
||||||
|
|
||||||
|
if (typeof siteScript === 'function') {
|
||||||
|
history.replaceState(null, '', '?year=' + val);
|
||||||
|
showLoader();
|
||||||
|
siteScript();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function initYear() {
|
||||||
|
var year = findGetParameter('year');
|
||||||
|
if (year === null) year = new Date().getFullYear();
|
||||||
|
|
||||||
|
$('#select-year').html('<option value="' + year + '">' + year + '</option>');
|
||||||
|
$('#select-year').val(year);
|
||||||
|
}
|
||||||
|
|
||||||
|
var firstCall = true;
|
||||||
|
var rows = [];
|
||||||
|
var today;
|
||||||
|
|
||||||
|
async function drawList () {
|
||||||
|
window.setTimeout(function () {
|
||||||
|
var list = '';
|
||||||
|
rows.forEach(function (entry) {
|
||||||
|
if (search($('#input-search').val(), entry.keywords)) {
|
||||||
|
list += entry.content;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('#div-users').html(list);
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
var siteScript = async function() {
|
||||||
|
if (!isLoggedIn()) {
|
||||||
|
hideLoader();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (firstCall) {
|
||||||
|
firstCall = false;
|
||||||
|
initYear();
|
||||||
|
$('#select-year').change(selectChange);
|
||||||
|
$('#input-search').on('input', drawList);
|
||||||
|
}
|
||||||
|
|
||||||
|
var selectedYear = $('#select-year').val();
|
||||||
|
var minDate = parseDate(selectedYear + '-01-01');
|
||||||
|
var maxDate = parseDate(selectedYear + '-12-31');
|
||||||
|
var regattas = await dbGetRegattasRange(minDate, maxDate);
|
||||||
|
var plannings = {};
|
||||||
|
for (var i in regattas) {
|
||||||
|
var entry = regattas[i];
|
||||||
|
var planning = await dbGetDataIndex('plannings', 'regatta', entry.id);
|
||||||
|
for (p in planning) {
|
||||||
|
if (!(planning[p].user in plannings)) {
|
||||||
|
plannings[planning[p].user] = {
|
||||||
|
user: await dbGetData('users', planning[p].user),
|
||||||
|
regattas: [],
|
||||||
|
sailors: {}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
plannings[planning[p].user].regattas.push(entry);
|
||||||
|
var sailor = null;
|
||||||
|
if (planning[p].steuermann !== null) sailor = await dbGetData('sailors', planning[p].steuermann);
|
||||||
|
if (sailor !== null) {
|
||||||
|
if (!(sailor.id in plannings[planning[p].user].sailors)) plannings[planning[p].user].sailors[sailor.id] = sailor.name;
|
||||||
|
}
|
||||||
|
var crew = planning[p].crew.split(',');
|
||||||
|
for (i in crew) {
|
||||||
|
sailor = await dbGetData('sailors', crew[i]);
|
||||||
|
if (sailor !== null) {
|
||||||
|
if (!(sailor.id in plannings[planning[p].user].sailors)) plannings[planning[p].user].sailors[sailor.id] = sailor.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
plannings = Object.values(plannings);
|
||||||
|
plannings.sort(function(a,b){
|
||||||
|
return a.user.username.localeCompare(b.user.username);
|
||||||
|
});
|
||||||
|
|
||||||
|
var years = await dbGetData('years');
|
||||||
|
years.sort(function (a, b) {
|
||||||
|
if (a['year'] > b['year']) return -1;
|
||||||
|
if (a['year'] < b['year']) return 1;
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
var options = '';
|
||||||
|
for (id in years) {
|
||||||
|
var year = years[id]['year'];
|
||||||
|
options += '<option value="' + year + '">' + year + '</option>';
|
||||||
|
}
|
||||||
|
$('#select-year').html(options);
|
||||||
|
$('#select-year').val(selectedYear);
|
||||||
|
|
||||||
|
var count = plannings.length;
|
||||||
|
if (count > 0) {
|
||||||
|
$('#input-search').parent().show();
|
||||||
|
|
||||||
|
rows = [];
|
||||||
|
|
||||||
|
for (id in plannings) {
|
||||||
|
var entry = plannings[id];
|
||||||
|
|
||||||
|
var row = { keywords: [], content: '' };
|
||||||
|
row.keywords.push(entry.user.username);
|
||||||
|
for (i in entry.sailors) {
|
||||||
|
row.keywords.push(entry.sailors[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
row.content += '<div onclick="onUserClicked(' + entry.user.id + ');">';
|
||||||
|
|
||||||
|
// ZEILE 1
|
||||||
|
row.content += '<div></div>';
|
||||||
|
|
||||||
|
// ZEILE 2
|
||||||
|
row.content += '<div>';
|
||||||
|
|
||||||
|
// Name
|
||||||
|
row.content += '<div>' + entry.user.username + '</div>';
|
||||||
|
|
||||||
|
// Count of regattas
|
||||||
|
row.content += '<div>' + entry.regattas.length + ' Regatten</div>';
|
||||||
|
|
||||||
|
row.content += '</div></div>';
|
||||||
|
|
||||||
|
rows.push(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
drawList();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$('#div-users').html('Es hat noch niemand eine Saison-Planung erstellt');
|
||||||
|
$('#input-search').parent().hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
hideLoader();
|
||||||
|
}
|
||||||
220
server/scripts/planning_view.js
Normal file
220
server/scripts/planning_view.js
Normal file
@@ -0,0 +1,220 @@
|
|||||||
|
function selectChange() {
|
||||||
|
var val = $('#select-year').val();
|
||||||
|
|
||||||
|
if (typeof siteScript === 'function') {
|
||||||
|
history.replaceState(null, '', '?year=' + val);
|
||||||
|
showLoader();
|
||||||
|
siteScript();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function initYear() {
|
||||||
|
var year = findGetParameter('year');
|
||||||
|
if (year === null) year = new Date().getFullYear();
|
||||||
|
|
||||||
|
$('#select-year').html('<option value="' + year + '">' + year + '</option>');
|
||||||
|
$('#select-year').val(year);
|
||||||
|
}
|
||||||
|
|
||||||
|
var firstCall = true;
|
||||||
|
var rows = [];
|
||||||
|
var today;
|
||||||
|
|
||||||
|
async function drawList () {
|
||||||
|
window.setTimeout(function () {
|
||||||
|
var list = '';
|
||||||
|
rows.forEach(function (entry) {
|
||||||
|
if (entry == null) {
|
||||||
|
list += '<div><div align="center" class="color-highlight"><b>Heute ist der ' + formatDate('d.m.Y', today) + '</b></div></div>';
|
||||||
|
} else if (search($('#input-search').val(), entry.keywords)) {
|
||||||
|
list += entry.content;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('#div-regattas').html(list);
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
var siteScript = async function() {
|
||||||
|
var userid = findGetParameter('user');
|
||||||
|
var user = null;
|
||||||
|
if (userid !== null) {
|
||||||
|
user = await dbGetData('users', userid);
|
||||||
|
}
|
||||||
|
if (user === null) {
|
||||||
|
location.href = LINK_PRE + 'planning_list';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#p-username').text(user.username);
|
||||||
|
|
||||||
|
if (isLoggedIn() && (userid == USER_ID)) {
|
||||||
|
$('#button-share').show();
|
||||||
|
$('#button-share').click(function(){
|
||||||
|
$('#menu-share').showMenu();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$('#button-share').hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (firstCall) {
|
||||||
|
firstCall = false;
|
||||||
|
initYear();
|
||||||
|
$('#select-year').change(selectChange);
|
||||||
|
$('#input-search').on('input', drawList);
|
||||||
|
}
|
||||||
|
|
||||||
|
today = getToday();
|
||||||
|
|
||||||
|
var selectedYear = $('#select-year').val();
|
||||||
|
var minDate = parseDate(selectedYear + '-01-01');
|
||||||
|
var maxDate = parseDate(selectedYear + '-12-31');
|
||||||
|
var regattas = await dbGetRegattasRange(minDate, maxDate);
|
||||||
|
var plannings = await dbGetDataIndex('plannings', 'user', user.id);
|
||||||
|
for (var i = regattas.length - 1; i >= 0; i --) {
|
||||||
|
var entry = regattas[i];
|
||||||
|
var okay = false;
|
||||||
|
for (p in plannings) {
|
||||||
|
if (plannings[p].regatta == entry.id) {
|
||||||
|
regattas[i].planning = plannings[p];
|
||||||
|
okay = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!okay) {
|
||||||
|
regattas.splice(i, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var years = await dbGetData('years');
|
||||||
|
years.sort(function (a, b) {
|
||||||
|
if (a['year'] > b['year']) return -1;
|
||||||
|
if (a['year'] < b['year']) return 1;
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
var options = '';
|
||||||
|
for (id in years) {
|
||||||
|
var year = years[id]['year'];
|
||||||
|
options += '<option value="' + year + '">' + year + '</option>';
|
||||||
|
}
|
||||||
|
$('#select-year').html(options);
|
||||||
|
$('#select-year').val(selectedYear);
|
||||||
|
|
||||||
|
var count = regattas.length;
|
||||||
|
if (count > 0) {
|
||||||
|
if (count == 1) {
|
||||||
|
$('#p-count').html('Es wurde 1 Regatta gefunden!');
|
||||||
|
} else {
|
||||||
|
$('#p-count').html('Es wurden ' + count + ' Regatten gefunden!');
|
||||||
|
}
|
||||||
|
$('#div-regattas').show();
|
||||||
|
$('#input-search').parent().show();
|
||||||
|
|
||||||
|
var heute = false;
|
||||||
|
|
||||||
|
rows = [];
|
||||||
|
|
||||||
|
for (id in regattas) {
|
||||||
|
var entry = regattas[id];
|
||||||
|
var club = null;
|
||||||
|
if (entry['club'] != null)
|
||||||
|
club = await dbGetData('clubs', entry['club']);
|
||||||
|
if (entry.planning.steuermann !== null) {
|
||||||
|
entry.planning.steuermann = (await dbGetData('sailors', entry.planning.steuermann)).name;
|
||||||
|
}
|
||||||
|
var crewString = entry.planning.crew.split(',');
|
||||||
|
entry.planning.crew = [];
|
||||||
|
for (c in crewString) {
|
||||||
|
var sailor = await dbGetData('sailors', crewString[c]);
|
||||||
|
if (sailor !== null) {
|
||||||
|
entry.planning.crew.push(sailor.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var dateFrom = entry['dateFrom'];
|
||||||
|
var dateTo = entry['dateTo'];
|
||||||
|
|
||||||
|
var row = { keywords: [], content: '' };
|
||||||
|
row.keywords.push(entry['name']);
|
||||||
|
if (entry['number'] != null) row.keywords.push(entry['number']);
|
||||||
|
if (club != null) row.keywords.push(club['kurz'], club['name']);
|
||||||
|
if (entry.planning.steuermann != null) row.keywords.push(entry.planning.steuermann);
|
||||||
|
for (c in entry.planning.crew) row.keywords.push(entry.planning.crew[c]);
|
||||||
|
|
||||||
|
if (!heute && (today <= dateFrom)) {
|
||||||
|
rows.push(null);
|
||||||
|
heute = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
row.content += '<div onclick="onRegattaClicked(' + entry['id'] + ');">';
|
||||||
|
|
||||||
|
// ZEILE 1
|
||||||
|
// Name
|
||||||
|
row.content += '<div><b>' + (entry['canceled'] == 1 ? '<s>' : '') + entry['name'] + (entry['canceled'] == 1 ? '</s>' : '') + '</b></div>';
|
||||||
|
|
||||||
|
// ZEILE 2
|
||||||
|
row.content += '<div>';
|
||||||
|
|
||||||
|
// Number
|
||||||
|
row.content += '<div>' + ((entry['number'] != null) ? ('# ' + entry['number']) : '') + '</div>';
|
||||||
|
|
||||||
|
// Special
|
||||||
|
row.content += '<div>' + entry['special'] + '</div>';
|
||||||
|
|
||||||
|
// Club
|
||||||
|
row.content += '<div>' + ((club != null) ? club['kurz'] : '') + '</div>';
|
||||||
|
|
||||||
|
row.content += '</div>';
|
||||||
|
|
||||||
|
// ZEILE 3
|
||||||
|
row.content += '<div>';
|
||||||
|
|
||||||
|
// Date
|
||||||
|
if (entry['length'] < 1) {
|
||||||
|
if (formatDate('d.m', dateFrom) == '01.01') {
|
||||||
|
row.content += '<div><font class="color-red2-dark">Datum noch unklar</font></div>';
|
||||||
|
} else {
|
||||||
|
row.content += '<div>' + formatDate("d.m.Y", dateFrom) + ' - <font class="color-red2-dark">Datum nicht final</font></div>';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
row.content += '<div>' + formatDate("d.m.Y", dateFrom) + ' - ' + formatDate("d.m.Y", dateTo) + '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// RLF
|
||||||
|
row.content += '<div>' + parseFloat(entry['rlf']).toFixed(2) + '</div>';
|
||||||
|
|
||||||
|
row.content += '</div>';
|
||||||
|
|
||||||
|
// ZEILE 4
|
||||||
|
row.content += '<div></div>';
|
||||||
|
|
||||||
|
// ZEILE 5
|
||||||
|
row.content += '<div>';
|
||||||
|
row.content += '<div>' + (entry.planning.steuermann !== null ? entry.planning.steuermann : 'noch unklar') + '</div>';
|
||||||
|
row.content += '</div>';
|
||||||
|
|
||||||
|
// ZEILE 6...
|
||||||
|
for (var i in entry.planning.crew) {
|
||||||
|
row.content += '<div>';
|
||||||
|
row.content += '<div>' + entry.planning.crew[i] + '</div>';
|
||||||
|
row.content += '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
row.content += '</div>';
|
||||||
|
|
||||||
|
rows.push(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!heute) {
|
||||||
|
rows.push(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
drawList();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$('#p-count').html(user.username + ' hat noch keine Regatten in seiner/ihrer Saison-Planung!');
|
||||||
|
$('#div-regattas').hide();
|
||||||
|
$('#input-search').parent().hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
hideLoader();
|
||||||
|
}
|
||||||
@@ -111,8 +111,8 @@ async function selectChange(callSiteScript = true) {
|
|||||||
var year = parseInt($('#select-year').val());
|
var year = parseInt($('#select-year').val());
|
||||||
if (type == "user") {
|
if (type == "user") {
|
||||||
$('#select-year').parent().hide();
|
$('#select-year').parent().hide();
|
||||||
$('#input-from').parent().show();
|
$('#input-from').trigger('focusin').trigger('focusout').parent().show();
|
||||||
$('#input-to').parent().show();
|
$('#input-to').trigger('focusin').trigger('focusout').parent().show();
|
||||||
$('#input-jugend').parent().parent().show();
|
$('#input-jugend').parent().parent().show();
|
||||||
$('#input-jugstrict').parent().parent().show();
|
$('#input-jugstrict').parent().parent().show();
|
||||||
$('#button-show').show();
|
$('#button-show').show();
|
||||||
@@ -174,7 +174,21 @@ async function selectChange(callSiteScript = true) {
|
|||||||
$('#input-jugend').prop('checked', jugend);
|
$('#input-jugend').prop('checked', jugend);
|
||||||
$('#input-jugstrict').prop('checked', jugstrict);
|
$('#input-jugstrict').prop('checked', jugstrict);
|
||||||
|
|
||||||
if (callSiteScript && (typeof siteScript === 'function'))
|
if (callSiteScript && (typeof siteScript === 'function')) {
|
||||||
|
history.replaceState(null, '', '?type=' + type + '&year=' + year);
|
||||||
|
showLoader();
|
||||||
|
siteScript();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function buttonShowPressed() {
|
||||||
|
if (typeof siteScript === 'function') {
|
||||||
|
var chboxes = '';
|
||||||
|
if ($('#input-jugend').prop('checked')) chboxes += '&jugend=on'
|
||||||
|
if ($('#input-jugstrict').prop('checked')) chboxes += '&jugstrict=on'
|
||||||
|
history.replaceState(null, '', '?type=user&from=' + $('#input-from').val() + "&to=" + $('#input-to').val() + chboxes)
|
||||||
|
showLoader();
|
||||||
siteScript();
|
siteScript();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -190,6 +204,19 @@ function initSelects() {
|
|||||||
$('#select-year').html('<option value="' + year + '">' + year + '</option>');
|
$('#select-year').html('<option value="' + year + '">' + year + '</option>');
|
||||||
$('#select-year').val(year);
|
$('#select-year').val(year);
|
||||||
|
|
||||||
|
if (type == "user") {
|
||||||
|
var from = findGetParameter('from');
|
||||||
|
var to = findGetParameter('to');
|
||||||
|
if (from === null) from = formatDate('Y-m-d')
|
||||||
|
if (to === null) to = formatDate('Y-m-d')
|
||||||
|
$('#input-from').val(from).trigger('focusin').trigger('focusout');
|
||||||
|
$('#input-to').val(to).trigger('focusin').trigger('focusout');
|
||||||
|
var jugend = findGetParameter('jugend');
|
||||||
|
var jugstrict = findGetParameter('jugstrict');
|
||||||
|
$('#input-jugend').prop('checked', jugend !== null);
|
||||||
|
$('#input-jugstrict').prop('checked', jugstrict !== null);
|
||||||
|
}
|
||||||
|
|
||||||
selectChange(false);
|
selectChange(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,7 +245,7 @@ var siteScript = async function() {
|
|||||||
initSelects();
|
initSelects();
|
||||||
$('#select-type').change(selectChange);
|
$('#select-type').change(selectChange);
|
||||||
$('#select-year').change(selectChange);
|
$('#select-year').change(selectChange);
|
||||||
$('#button-show').click(siteScript);
|
$('#button-show').click(buttonShowPressed);
|
||||||
$('#input-search').on('input', drawList);
|
$('#input-search').on('input', drawList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
function selectChange(callSiteScript = true) {
|
function selectChange(callSiteScript = true) {
|
||||||
var val = $('#select-year').val();
|
var val = $('#select-year').val();
|
||||||
if (val == "user") {
|
if (val == "user") {
|
||||||
$('#input-from').parent().show();
|
$('#input-from').trigger('focusin').trigger('focusout').parent().show();
|
||||||
$('#input-to').parent().show();
|
$('#input-to').trigger('focusin').trigger('focusout').parent().show();
|
||||||
$('#button-show').show();
|
$('#button-show').show();
|
||||||
} else {
|
} else {
|
||||||
$('#input-from').parent().hide();
|
$('#input-from').parent().hide();
|
||||||
@@ -12,7 +12,18 @@ function selectChange(callSiteScript = true) {
|
|||||||
$('#input-from').val(val + '-01-01');
|
$('#input-from').val(val + '-01-01');
|
||||||
$('#input-to').val(val + '-12-31');
|
$('#input-to').val(val + '-12-31');
|
||||||
|
|
||||||
if (callSiteScript && (typeof siteScript === 'function'))
|
if (callSiteScript && (typeof siteScript === 'function')) {
|
||||||
|
history.replaceState(null, '', '?year=' + val);
|
||||||
|
showLoader();
|
||||||
|
siteScript();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function buttonShowPressed() {
|
||||||
|
if (typeof siteScript === 'function') {
|
||||||
|
history.replaceState(null, '', '?year=user&from=' + $('#input-from').val() + "&to=" + $('#input-to').val());
|
||||||
|
showLoader();
|
||||||
siteScript();
|
siteScript();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -24,6 +35,15 @@ function initYear() {
|
|||||||
$('#select-year').html('<option value="' + year + '">' + year + '</option>');
|
$('#select-year').html('<option value="' + year + '">' + year + '</option>');
|
||||||
$('#select-year').val(year);
|
$('#select-year').val(year);
|
||||||
|
|
||||||
|
if (year == "user") {
|
||||||
|
var from = findGetParameter('from');
|
||||||
|
var to = findGetParameter('to');
|
||||||
|
if (from === null) from = formatDate('Y-m-d')
|
||||||
|
if (to === null) to = formatDate('Y-m-d')
|
||||||
|
$('#input-from').val(from).trigger('focusin').trigger('focusout');
|
||||||
|
$('#input-to').val(to).trigger('focusin').trigger('focusout');
|
||||||
|
}
|
||||||
|
|
||||||
selectChange(false);
|
selectChange(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +70,7 @@ var siteScript = async function() {
|
|||||||
firstCall = false;
|
firstCall = false;
|
||||||
initYear();
|
initYear();
|
||||||
$('#select-year').change(selectChange);
|
$('#select-year').change(selectChange);
|
||||||
$('#button-show').click(siteScript);
|
$('#button-show').click(buttonShowPressed);
|
||||||
$('#input-search').on('input', drawList);
|
$('#input-search').on('input', drawList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,12 +79,6 @@ var siteScript = async function() {
|
|||||||
var minDate = parseDate($('#input-from').val());
|
var minDate = parseDate($('#input-from').val());
|
||||||
var maxDate = parseDate($('#input-to').val());
|
var maxDate = parseDate($('#input-to').val());
|
||||||
var regattas = await dbGetRegattasRange(minDate, maxDate);
|
var regattas = await dbGetRegattasRange(minDate, maxDate);
|
||||||
var regattaResults = [];
|
|
||||||
for (id in regattas) {
|
|
||||||
var entry = regattas[id];
|
|
||||||
var results = await dbGetDataIndex('results', 'regatta', entry['id']);
|
|
||||||
regattaResults[entry['id']] = (results.length > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
var selectedYear = $('#select-year').val();
|
var selectedYear = $('#select-year').val();
|
||||||
|
|
||||||
@@ -160,8 +174,10 @@ var siteScript = async function() {
|
|||||||
ms = parseDate(entry['meldungSchluss']);
|
ms = parseDate(entry['meldungSchluss']);
|
||||||
}
|
}
|
||||||
var diff = Math.round((ms - today) / 86400000);
|
var diff = Math.round((ms - today) / 86400000);
|
||||||
if ((ms >= today) && (diff < 7)) {
|
if (ms < today) {
|
||||||
color = ' color-red2-dark';
|
color = ' color-red2-dark';
|
||||||
|
} else if (diff < 7) {
|
||||||
|
color = ' color-yellow2-dark';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -174,7 +190,7 @@ var siteScript = async function() {
|
|||||||
icons.push('<i class="fas fa-book"></i>');
|
icons.push('<i class="fas fa-book"></i>');
|
||||||
if (entry['canceled'] == '1') {
|
if (entry['canceled'] == '1') {
|
||||||
icons.push('<i class="fas fa-times color-red2-dark"></i>');
|
icons.push('<i class="fas fa-times color-red2-dark"></i>');
|
||||||
} else if (regattaResults[entry['id']]) {
|
} else if (entry['results'] == '1') {
|
||||||
icons.push('<i class="fas fa-poll"></i>');
|
icons.push('<i class="fas fa-poll"></i>');
|
||||||
}
|
}
|
||||||
row.content += '<div class="color-green2-dark">' + icons.join(' ') + '</div>';
|
row.content += '<div class="color-green2-dark">' + icons.join(' ') + '</div>';
|
||||||
|
|||||||
@@ -4,6 +4,40 @@ var displayed = [];
|
|||||||
var page = 1;
|
var page = 1;
|
||||||
var pageCount = 0;
|
var pageCount = 0;
|
||||||
const showCount = 25;
|
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.<br>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() {
|
async function onEditYearClick() {
|
||||||
var id = $('#button-edityear').attr('data-sailor-id');
|
var id = $('#button-edityear').attr('data-sailor-id');
|
||||||
@@ -21,8 +55,8 @@ async function onEditYearClick() {
|
|||||||
if (xhr.status == 0) {
|
if (xhr.status == 0) {
|
||||||
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um den Jahrgang zu bearbeiten');
|
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um den Jahrgang zu bearbeiten');
|
||||||
} else {
|
} else {
|
||||||
console.log('EditYear: unbekannter Fehler', status, error);
|
log('EditYear: unbekannter Fehler', status, error);
|
||||||
console.log(xhr);
|
log(xhr);
|
||||||
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
|
toastError('Ein unbekannter Fehler ist aufgetreten. Bitte versuche es noch einmal', 5000);
|
||||||
}
|
}
|
||||||
hideLoader();
|
hideLoader();
|
||||||
@@ -50,6 +84,26 @@ async function onListClicked(id) {
|
|||||||
|
|
||||||
$('#menu-sailor').find('.menu-title').find('p').text(sailor.name);
|
$('#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
|
// Edit Year
|
||||||
$('#button-edityear').attr('data-sailor-id', sailor.id);
|
$('#button-edityear').attr('data-sailor-id', sailor.id);
|
||||||
$('#menu-edityear').find('.menu-title').find('p').text(sailor.name);
|
$('#menu-edityear').find('.menu-title').find('p').text(sailor.name);
|
||||||
@@ -134,6 +188,19 @@ var siteScript = async function() {
|
|||||||
$('#input-search').on('input', reSearch);
|
$('#input-search').on('input', reSearch);
|
||||||
$('#menu-item-year').click(function(){ $('#menu-sailor').hideMenu(); $('#menu-edityear').showMenu(); });
|
$('#menu-item-year').click(function(){ $('#menu-sailor').hideMenu(); $('#menu-edityear').showMenu(); });
|
||||||
$('#button-edityear').click(onEditYearClick);
|
$('#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');
|
var results = await dbGetData('sailors');
|
||||||
|
|||||||
8
server/templates/menu/item-switch.html
Normal file
8
server/templates/menu/item-switch.html
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<a href="#" data-trigger-switch="$$html-id;" class="pb-2 $$css-class;">
|
||||||
|
<i class="fa font-14 $$icon; rounded-s bg-highlight color-white"></i>
|
||||||
|
<span>$$0;</span>
|
||||||
|
<div class="custom-control scale-switch ios-switch">
|
||||||
|
<input type="checkbox" class="ios-input" id="$$html-id;">
|
||||||
|
<label class="custom-control-label" for="$$html-id;"></label>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<nav id="$$html-id;">
|
<nav id="$$html-id;" class="$$css-class;">
|
||||||
<ul class="pagination justify-content-center">
|
<ul class="pagination justify-content-center">
|
||||||
<li id="$$html-id;-1" class="page-item"><a onclick="onPaginationClick(this)" class="page-link color-black bg-theme rounded-xs shadow-x1 border-0" style="cursor: pointer;">1</a></li>
|
<li id="$$html-id;-1" class="page-item"><a onclick="onPaginationClick(this)" class="page-link color-black bg-theme rounded-xs shadow-x1 border-0" style="cursor: pointer;">1</a></li>
|
||||||
<li id="$$html-id;-2" class="page-item"><a onclick="onPaginationClick(this)" class="page-link color-black bg-theme rounded-xs shadow-x1 border-0" style="cursor: pointer;">2</a></li>
|
<li id="$$html-id;-2" class="page-item"><a onclick="onPaginationClick(this)" class="page-link color-black bg-theme rounded-xs shadow-x1 border-0" style="cursor: pointer;">2</a></li>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
define('PWA_VERSION', '1.5');
|
define('PWA_VERSION', '1.11h2');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -56,15 +56,19 @@ workbox.precaching.precacheAndRoute([
|
|||||||
'/manifest.json.php',
|
'/manifest.json.php',
|
||||||
];
|
];
|
||||||
$dirsToCache = [
|
$dirsToCache = [
|
||||||
'/client',
|
'/client/app',
|
||||||
|
'/client/fonts/css',
|
||||||
|
'/client/fonts/webfonts',
|
||||||
|
'/client/images',
|
||||||
|
'/client/scripts',
|
||||||
|
'/client/styles',
|
||||||
];
|
];
|
||||||
|
|
||||||
function addDir($path) {
|
function addDir($path) {
|
||||||
global $filesToCache;
|
global $filesToCache;
|
||||||
if ($dir = opendir(__DIR__ . $path)) {
|
if ($dir = opendir(__DIR__ . $path)) {
|
||||||
while (($file = readdir($dir)) !== false) {
|
while (($file = readdir($dir)) !== false) {
|
||||||
if ($file == '.') continue;
|
if (substr($file, 0, 1) == '.') continue;
|
||||||
if ($file == '..') continue;
|
|
||||||
if (is_dir(__DIR__ . $path . '/' . $file)) {
|
if (is_dir(__DIR__ . $path . '/' . $file)) {
|
||||||
addDir($path . '/' . $file);
|
addDir($path . '/' . $file);
|
||||||
} else {
|
} else {
|
||||||
@@ -105,3 +109,218 @@ workbox.routing.registerRoute(
|
|||||||
|
|
||||||
//Learn more about Service Workers and Configurations
|
//Learn more about Service Workers and Configurations
|
||||||
//https://developers.google.com/web/tools/workbox/
|
//https://developers.google.com/web/tools/workbox/
|
||||||
|
|
||||||
|
|
||||||
|
// DB
|
||||||
|
|
||||||
|
function openDb() {
|
||||||
|
return new Promise(function(resolve) {
|
||||||
|
if (indexedDB) {
|
||||||
|
var request = indexedDB.open('regatten_app_db_<?php echo BOATCLASS; ?>');
|
||||||
|
request.onerror = function (e) {
|
||||||
|
console.log('[sW] Cannot open DB:', e.targer.errorCode);
|
||||||
|
resolve(null);
|
||||||
|
};
|
||||||
|
request.onupgradeneeded = function (e) {
|
||||||
|
console.log('[sW] DB does not exist');
|
||||||
|
e.target.transaction.abort();
|
||||||
|
resolve(null);
|
||||||
|
};
|
||||||
|
request.onsuccess = function (e) {
|
||||||
|
console.log('[sW] DB loaded');
|
||||||
|
var db = e.target.result;
|
||||||
|
db.onerror = function (e) {
|
||||||
|
console.log('[sW] DB Error:', e);
|
||||||
|
};
|
||||||
|
resolve(db);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
resolve(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function dbSettingsGet(key) {
|
||||||
|
return new Promise(async function(resolve) {
|
||||||
|
var db = await openDb();
|
||||||
|
if (db !== null) {
|
||||||
|
var request = db.transaction('settings').objectStore('settings').get(key);
|
||||||
|
request.onsuccess = function (event) {
|
||||||
|
db.close();
|
||||||
|
console.log('[sW] DB closed');
|
||||||
|
resolve(typeof request.result != 'undefined' ? request.result.value : null);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
resolve(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function dbSettingsSet(key, value) {
|
||||||
|
var db = await openDb();
|
||||||
|
if (db != null) {
|
||||||
|
var os = db.transaction('settings', 'readwrite').objectStore('settings');
|
||||||
|
var request = os.put({ key: key, value: value});
|
||||||
|
request.onerror = function (event) {
|
||||||
|
console.log('[sW] Error while saving data to DB:', e);
|
||||||
|
db.close();
|
||||||
|
console.log('[sW] DB closed');
|
||||||
|
}
|
||||||
|
request.onsuccess = function (event) {
|
||||||
|
db.close();
|
||||||
|
console.log('[sW] DB closed');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// PUSHES
|
||||||
|
|
||||||
|
function getEntry(data, index, defaultValue) {
|
||||||
|
return ((typeof data[index] !== "undefined") ? data[index] : defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
function isMyRegatta(id) {
|
||||||
|
return new Promise(async function (resolve) {
|
||||||
|
var regattas = await dbSettingsGet('myregattas_<?php echo BOATCLASS; ?>');
|
||||||
|
if (regattas == null) resolve(false);
|
||||||
|
else resolve(regattas.includes(id.toString()));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
self.addEventListener('push', async function(event) {
|
||||||
|
console.log('[sW] Push received:', event.data.text());
|
||||||
|
|
||||||
|
var data;
|
||||||
|
try {
|
||||||
|
data = JSON.parse(event.data.text());
|
||||||
|
} catch(e) {
|
||||||
|
console.log(e);
|
||||||
|
data = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof data.type !== "undefined") {
|
||||||
|
switch (data.type) {
|
||||||
|
case 'notification':
|
||||||
|
if (typeof data.title === "undefined") break;
|
||||||
|
if (typeof data.body === "undefined") break;
|
||||||
|
if (typeof data.channel === "undefined") break;
|
||||||
|
|
||||||
|
// check channel
|
||||||
|
var okay = false;
|
||||||
|
switch (data.channel) {
|
||||||
|
case 'news':
|
||||||
|
if (await dbSettingsGet('notify_channel_<?php echo BOATCLASS; ?>_news')) okay = true;
|
||||||
|
break;
|
||||||
|
case 'regatta_changed':
|
||||||
|
if (await dbSettingsGet('notify_channel_<?php echo BOATCLASS; ?>_regatta_changed_all')) okay = true;
|
||||||
|
else if (await dbSettingsGet('notify_channel_<?php echo BOATCLASS; ?>_regatta_changed_my')) {
|
||||||
|
if (await isMyRegatta(getEntry(data, 'id', ''))) okay = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'result_ready':
|
||||||
|
if (await dbSettingsGet('notify_channel_<?php echo BOATCLASS; ?>_result_ready_all')) okay = true;
|
||||||
|
else if (await dbSettingsGet('notify_channel_<?php echo BOATCLASS; ?>_result_ready_my')) {
|
||||||
|
if (await isMyRegatta(getEntry(data, 'id', ''))) okay = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'meldeschluss':
|
||||||
|
if (await dbSettingsGet('notify_channel_<?php echo BOATCLASS; ?>_meldeschluss')) {
|
||||||
|
if (await isMyRegatta(getEntry(data, 'id', ''))) okay = true;
|
||||||
|
// TODO: only if not already registered
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
console.log('[sW] Unknown channel:', data.channel);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!okay) {
|
||||||
|
console.log('[sW] Notification channel not subscribed');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
data: data,
|
||||||
|
body: data.body,
|
||||||
|
icon: getEntry(data, 'icon', '<?php echo SERVER_ADDR; ?>/client/app/icons/icon-512x512.png'),
|
||||||
|
badge: '<?php echo SERVER_ADDR; ?>/client/app/icons/badge-128x128.png',
|
||||||
|
vibrate: [500,100,500]
|
||||||
|
};
|
||||||
|
if ((image = getEntry(data, 'image', null)) !== null) {
|
||||||
|
options.image = image;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Force refresh on next app open
|
||||||
|
var db = await openDb();
|
||||||
|
if (db != null) {
|
||||||
|
var os = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
||||||
|
var request = os.put({ table: 'last_sync', time: 1 });
|
||||||
|
request.onerror = function (event) {
|
||||||
|
console.log('[sW] Error while saving data to DB:', e);
|
||||||
|
db.close();
|
||||||
|
console.log('[sW] DB closed');
|
||||||
|
}
|
||||||
|
request.onsuccess = function (event) {
|
||||||
|
db.close();
|
||||||
|
console.log('[sW] DB closed');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('[sW] Showing notification');
|
||||||
|
self.registration.showNotification(data.title, options);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'forcesync':
|
||||||
|
// Force refresh on next app open
|
||||||
|
var db = await openDb();
|
||||||
|
if (db != null) {
|
||||||
|
var os = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
||||||
|
var request = os.put({ table: 'last_sync', time: 1 });
|
||||||
|
request.onerror = function (event) {
|
||||||
|
console.log('[sW] Error while saving data to DB:', e);
|
||||||
|
db.close();
|
||||||
|
console.log('[sW] DB closed');
|
||||||
|
}
|
||||||
|
request.onsuccess = function (event) {
|
||||||
|
console.log('[sW] Data successfully saved');
|
||||||
|
db.close();
|
||||||
|
console.log('[sW] DB closed');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
console.log('[sW] Push type unknown:', data.type);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log('[sW] No push type given!');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
self.addEventListener('notificationclick', function(event) {
|
||||||
|
var data = event.notification.data;
|
||||||
|
|
||||||
|
event.notification.close();
|
||||||
|
|
||||||
|
var url = '<?php echo SERVER_ADDR; ?>' + getEntry(data, 'url', '');
|
||||||
|
|
||||||
|
event.waitUntil(
|
||||||
|
clients.openWindow(url)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
self.addEventListener('pushsubscriptionchange', function(event) {
|
||||||
|
var formData = new URLSearchParams();
|
||||||
|
formData.append('old', JSON.stringify(event.oldSubscription));
|
||||||
|
formData.append('new', JSON.stringify(event.newSubscription));
|
||||||
|
event.waitUntil(
|
||||||
|
fetch('<?php echo QUERY_URL; ?>update_subscription', {
|
||||||
|
method: 'POST',
|
||||||
|
cache: 'no-cache',
|
||||||
|
body: formData
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user