Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9ff0b96837 | ||
|
|
72ff731694 | ||
|
|
3959b208b5 | ||
|
|
7b500bf67d | ||
|
|
5c8c9db1de | ||
|
|
fa526b11a8 | ||
|
|
2dc2225263 | ||
|
|
fcf9dc9a20 | ||
|
|
203c2534eb | ||
|
|
730dd9112f | ||
|
|
13ceef37d9 | ||
|
|
54852f4383 | ||
|
|
8808d12bf1 | ||
|
|
c6d5450b0e | ||
|
|
15cbe15651 | ||
|
|
cb8a1817ae | ||
|
|
be98511957 |
@@ -483,257 +483,49 @@ function sync() {
|
|||||||
if (!canUseLocalDB) return false;
|
if (!canUseLocalDB) return false;
|
||||||
if (syncInProgress > 0) return false;
|
if (syncInProgress > 0) return false;
|
||||||
|
|
||||||
var now = Math.floor(Date.now() / 1000);
|
return new Promise(function(resolve) {
|
||||||
|
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) {
|
||||||
var localTimes = {};
|
var localTimes = {};
|
||||||
event.target.result.forEach(function (entry) {
|
event.target.result.forEach(function (entry) {
|
||||||
localTimes[entry['table']] = entry['time'];
|
localTimes[entry['table']] = entry['time'];
|
||||||
});
|
});
|
||||||
|
|
||||||
syncInProgress = 11;
|
syncInProgress = 11;
|
||||||
var syncOkay = true;
|
var syncOkay = true;
|
||||||
log("Sync Start");
|
log("Sync Start");
|
||||||
$('#i-sync').addClass('fa-spin');
|
$('#i-sync').addClass('fa-spin');
|
||||||
|
|
||||||
var interval = window.setInterval(function () {
|
var interval = window.setInterval(function () {
|
||||||
if (syncInProgress <= 0) {
|
if (syncInProgress <= 0) {
|
||||||
window.clearInterval(interval);
|
window.clearInterval(interval);
|
||||||
if (syncOkay) {
|
if (syncOkay) {
|
||||||
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 });
|
||||||
|
}
|
||||||
|
log("Sync Stop");
|
||||||
|
setTimeout(function(){
|
||||||
|
$('#i-sync').removeClass('fa-spin');
|
||||||
|
}, 500);
|
||||||
|
|
||||||
|
if (typeof onAfterSync === 'function') {
|
||||||
|
onAfterSync();
|
||||||
|
}
|
||||||
|
removeSyncInfoToPreloader();
|
||||||
|
runPageScript();
|
||||||
|
resolve();
|
||||||
}
|
}
|
||||||
log("Sync Stop");
|
}, 100);
|
||||||
setTimeout(function(){
|
|
||||||
$('#i-sync').removeClass('fa-spin');
|
|
||||||
}, 500);
|
|
||||||
|
|
||||||
if (typeof onAfterSync === 'function') {
|
getJSON(QUERY_URL + 'get_update_time', function (code, serverTimes) {
|
||||||
onAfterSync();
|
if (code == 200) {
|
||||||
}
|
|
||||||
removeSyncInfoToPreloader();
|
|
||||||
runPageScript();
|
|
||||||
}
|
|
||||||
}, 100);
|
|
||||||
|
|
||||||
getJSON(QUERY_URL + 'get_update_time', function (code, serverTimes) {
|
// CLUBS
|
||||||
if (code == 200) {
|
if (localTimes['clubs'] < serverTimes['clubs']) {
|
||||||
|
getJSON(QUERY_URL + 'get_clubs?changed-after=' + localTimes['clubs'], function (code, data) {
|
||||||
// CLUBS
|
|
||||||
if (localTimes['clubs'] < serverTimes['clubs']) {
|
|
||||||
getJSON(QUERY_URL + 'get_clubs?changed-after=' + localTimes['clubs'], function (code, data) {
|
|
||||||
if (code == 200) {
|
|
||||||
var os = db.transaction('clubs', 'readwrite').objectStore('clubs');
|
|
||||||
log(data);
|
|
||||||
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: 'clubs', time: serverTimes['clubs'] });
|
|
||||||
syncInProgress --;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
log("Something went wrong (HTTP " + code + ")");
|
|
||||||
syncOkay = false;
|
|
||||||
syncInProgress --;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
syncInProgress --;
|
|
||||||
}
|
|
||||||
|
|
||||||
// BOATS
|
|
||||||
if (localTimes['boats'] < serverTimes['boats']) {
|
|
||||||
getJSON(QUERY_URL + 'get_boats?changed-after=' + localTimes['boats'], function (code, data) {
|
|
||||||
if (code == 200) {
|
|
||||||
var os = db.transaction('boats', 'readwrite').objectStore('boats');
|
|
||||||
log(data);
|
|
||||||
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: 'boats', time: serverTimes['boats'] });
|
|
||||||
syncInProgress --;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
log("Something went wrong (HTTP " + code + ")");
|
|
||||||
syncOkay = false;
|
|
||||||
syncInProgress --;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
syncInProgress --;
|
|
||||||
}
|
|
||||||
|
|
||||||
// SAILORS
|
|
||||||
if (localTimes['sailors'] < serverTimes['sailors']) {
|
|
||||||
getJSON(QUERY_URL + 'get_sailors?changed-after=' + localTimes['sailors'], function (code, data) {
|
|
||||||
if (code == 200) {
|
|
||||||
var os = db.transaction('sailors', 'readwrite').objectStore('sailors');
|
|
||||||
log(data);
|
|
||||||
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: 'sailors', time: serverTimes['sailors'] });
|
|
||||||
syncInProgress --;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
log("Something went wrong (HTTP " + code + ")");
|
|
||||||
syncOkay = false;
|
|
||||||
syncInProgress --;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
syncInProgress --;
|
|
||||||
}
|
|
||||||
|
|
||||||
// REGATTAS
|
|
||||||
if (localTimes['regattas'] < serverTimes['regattas']) {
|
|
||||||
getJSON(QUERY_URL + 'get_regattas?changed-after=' + localTimes['regattas'], function (code, data) {
|
|
||||||
if (code == 200) {
|
|
||||||
var os = db.transaction('regattas', 'readwrite').objectStore('regattas');
|
|
||||||
log(data);
|
|
||||||
data.data.forEach(function (entry) {
|
|
||||||
os.put(entry);
|
|
||||||
});
|
|
||||||
os.openCursor().onsuccess = async function (event) {
|
|
||||||
var cursor = event.target.result;
|
|
||||||
if (cursor) {
|
|
||||||
if (!data.keys.includes(parseInt(cursor.key))) {
|
|
||||||
os.delete(cursor.key);
|
|
||||||
}
|
|
||||||
cursor.continue();
|
|
||||||
} else {
|
|
||||||
// update years
|
|
||||||
var regattas = await dbGetData('regattas');
|
|
||||||
var years = {};
|
|
||||||
for (id in regattas) {
|
|
||||||
var entry = regattas[id];
|
|
||||||
var date = parseDate(entry['date']);
|
|
||||||
var y = date.getFullYear();
|
|
||||||
years[y] = y;
|
|
||||||
}
|
|
||||||
var osYears = db.transaction('years', 'readwrite').objectStore('years');
|
|
||||||
osYears.clear().onsuccess = function (event) {
|
|
||||||
for (var y in years) {
|
|
||||||
osYears.put({ year: y });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
|
||||||
osUpdateTimes.put({ table: 'regattas', time: serverTimes['regattas'] });
|
|
||||||
syncInProgress --;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
log("Something went wrong (HTTP " + code + ")");
|
|
||||||
syncOkay = false;
|
|
||||||
syncInProgress --;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
syncInProgress --;
|
|
||||||
}
|
|
||||||
|
|
||||||
// RESULTS
|
|
||||||
if (localTimes['results'] < serverTimes['results']) {
|
|
||||||
getJSON(QUERY_URL + 'get_results?changed-after=' + localTimes['results'], function (code, data) {
|
|
||||||
if (code == 200) {
|
|
||||||
var os = db.transaction('results', 'readwrite').objectStore('results');
|
|
||||||
log(data);
|
|
||||||
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: 'results', time: serverTimes['results'] });
|
|
||||||
syncInProgress --;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
log("Something went wrong (HTTP " + code + ")");
|
|
||||||
syncOkay = false;
|
|
||||||
syncInProgress --;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
syncInProgress --;
|
|
||||||
}
|
|
||||||
|
|
||||||
// PLANNINGS
|
|
||||||
if (localTimes['plannings'] < serverTimes['plannings']) {
|
|
||||||
getJSON(QUERY_URL + 'get_plannings?changed-after=' + localTimes['plannings'], function (code, data) {
|
|
||||||
if (code == 200) {
|
|
||||||
var os = db.transaction('plannings', 'readwrite').objectStore('plannings');
|
|
||||||
log(data);
|
|
||||||
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: 'plannings', time: serverTimes['plannings'] });
|
|
||||||
syncInProgress --;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
log("Something went wrong (HTTP " + code + ")");
|
|
||||||
syncOkay = false;
|
|
||||||
syncInProgress --;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
syncInProgress --;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isLoggedIn()) {
|
|
||||||
// TRIM_BOATS
|
|
||||||
if (localTimes['trim_boats'] < serverTimes['trim_boats']) {
|
|
||||||
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('clubs', 'readwrite').objectStore('clubs');
|
||||||
log(data);
|
|
||||||
data.data.forEach(function (entry) {
|
data.data.forEach(function (entry) {
|
||||||
os.put(entry);
|
os.put(entry);
|
||||||
});
|
});
|
||||||
@@ -746,26 +538,27 @@ function sync() {
|
|||||||
cursor.continue();
|
cursor.continue();
|
||||||
} else {
|
} else {
|
||||||
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: 'clubs', time: serverTimes['clubs'] });
|
||||||
syncInProgress --;
|
syncInProgress --;
|
||||||
|
log('clubs synced, remaining:', syncInProgress);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
log("Something went wrong (HTTP " + code + ")");
|
log("clubs: Something went wrong (HTTP " + code + ")");
|
||||||
syncOkay = false;
|
syncOkay = false;
|
||||||
syncInProgress --;
|
syncInProgress --;
|
||||||
|
log('clubs failed, remaining:', syncInProgress);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
syncInProgress --;
|
syncInProgress --;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TRIM_USERS
|
// BOATS
|
||||||
if (localTimes['trim_users'] < serverTimes['trim_users']) {
|
if (localTimes['boats'] < serverTimes['boats']) {
|
||||||
getJSON(QUERY_URL + 'get_trim_users?changed-after=' + localTimes['trim_users'], 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('trim_users', 'readwrite').objectStore('trim_users');
|
var os = db.transaction('boats', 'readwrite').objectStore('boats');
|
||||||
log(data);
|
|
||||||
data.data.forEach(function (entry) {
|
data.data.forEach(function (entry) {
|
||||||
os.put(entry);
|
os.put(entry);
|
||||||
});
|
});
|
||||||
@@ -778,26 +571,27 @@ function sync() {
|
|||||||
cursor.continue();
|
cursor.continue();
|
||||||
} else {
|
} else {
|
||||||
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: 'boats', time: serverTimes['boats'] });
|
||||||
syncInProgress --;
|
syncInProgress --;
|
||||||
|
log('boats synced, remaining:', syncInProgress);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
log("Something went wrong (HTTP " + code + ")");
|
log("boats: Something went wrong (HTTP " + code + ")");
|
||||||
syncOkay = false;
|
syncOkay = false;
|
||||||
syncInProgress --;
|
syncInProgress --;
|
||||||
|
log('boats failed, remaining:', syncInProgress);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
syncInProgress --;
|
syncInProgress --;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TRIM_TRIMS
|
// SAILORS
|
||||||
if (localTimes['trim_trims'] < serverTimes['trim_trims']) {
|
if (localTimes['sailors'] < serverTimes['sailors']) {
|
||||||
getJSON(QUERY_URL + 'get_trim_trims?changed-after=' + localTimes['trim_trims'], 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('trim_trims', 'readwrite').objectStore('trim_trims');
|
var os = db.transaction('sailors', 'readwrite').objectStore('sailors');
|
||||||
log(data);
|
|
||||||
data.data.forEach(function (entry) {
|
data.data.forEach(function (entry) {
|
||||||
os.put(entry);
|
os.put(entry);
|
||||||
});
|
});
|
||||||
@@ -810,14 +604,301 @@ function sync() {
|
|||||||
cursor.continue();
|
cursor.continue();
|
||||||
} else {
|
} else {
|
||||||
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: 'sailors', time: serverTimes['sailors'] });
|
||||||
syncInProgress --;
|
syncInProgress --;
|
||||||
|
log('sailors synced, remaining:', syncInProgress);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
log("Something went wrong (HTTP " + code + ")");
|
log("sailors: Something went wrong (HTTP " + code + ")");
|
||||||
syncOkay = false;
|
syncOkay = false;
|
||||||
syncInProgress --;
|
syncInProgress --;
|
||||||
|
log('sailors failed, remaining:', syncInProgress);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
syncInProgress --;
|
||||||
|
}
|
||||||
|
|
||||||
|
// REGATTAS
|
||||||
|
if (localTimes['regattas'] < serverTimes['regattas']) {
|
||||||
|
getJSON(QUERY_URL + 'get_regattas?changed-after=' + localTimes['regattas'], function (code, data) {
|
||||||
|
if (code == 200) {
|
||||||
|
var os = db.transaction('regattas', 'readwrite').objectStore('regattas');
|
||||||
|
data.data.forEach(function (entry) {
|
||||||
|
os.put(entry);
|
||||||
|
});
|
||||||
|
os.openCursor().onsuccess = async function (event) {
|
||||||
|
var cursor = event.target.result;
|
||||||
|
if (cursor) {
|
||||||
|
if (!data.keys.includes(parseInt(cursor.key))) {
|
||||||
|
os.delete(cursor.key);
|
||||||
|
}
|
||||||
|
cursor.continue();
|
||||||
|
} else {
|
||||||
|
// update years
|
||||||
|
var regattas = await dbGetData('regattas');
|
||||||
|
var years = {};
|
||||||
|
for (id in regattas) {
|
||||||
|
var entry = regattas[id];
|
||||||
|
var date = parseDate(entry['date']);
|
||||||
|
var y = date.getFullYear();
|
||||||
|
years[y] = y;
|
||||||
|
}
|
||||||
|
var osYears = db.transaction('years', 'readwrite').objectStore('years');
|
||||||
|
osYears.clear().onsuccess = function (event) {
|
||||||
|
for (var y in years) {
|
||||||
|
osYears.put({ year: y });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
|
||||||
|
osUpdateTimes.put({ table: 'regattas', time: serverTimes['regattas'] });
|
||||||
|
syncInProgress --;
|
||||||
|
log('regattas synced, remaining:', syncInProgress);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
log("regattas: Something went wrong (HTTP " + code + ")");
|
||||||
|
syncOkay = false;
|
||||||
|
syncInProgress --;
|
||||||
|
log('regattas failed, remaining:', syncInProgress);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
syncInProgress --;
|
||||||
|
}
|
||||||
|
|
||||||
|
// RESULTS
|
||||||
|
if (localTimes['results'] < serverTimes['results']) {
|
||||||
|
getJSON(QUERY_URL + 'get_results?changed-after=' + localTimes['results'], function (code, data) {
|
||||||
|
if (code == 200) {
|
||||||
|
var os = db.transaction('results', 'readwrite').objectStore('results');
|
||||||
|
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: 'results', time: serverTimes['results'] });
|
||||||
|
syncInProgress --;
|
||||||
|
log('results synced, remaining:', syncInProgress);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
log("results: Something went wrong (HTTP " + code + ")");
|
||||||
|
syncOkay = false;
|
||||||
|
syncInProgress --;
|
||||||
|
log('results failed, remaining:', syncInProgress);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
syncInProgress --;
|
||||||
|
}
|
||||||
|
|
||||||
|
// PLANNINGS
|
||||||
|
if (localTimes['plannings'] < serverTimes['plannings']) {
|
||||||
|
getJSON(QUERY_URL + 'get_plannings?changed-after=' + localTimes['plannings'], function (code, data) {
|
||||||
|
if (code == 200) {
|
||||||
|
var os = db.transaction('plannings', 'readwrite').objectStore('plannings');
|
||||||
|
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: 'plannings', time: serverTimes['plannings'] });
|
||||||
|
syncInProgress --;
|
||||||
|
log('plannings synced, remaining:', syncInProgress);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
log("plannings: Something went wrong (HTTP " + code + ")");
|
||||||
|
syncOkay = false;
|
||||||
|
syncInProgress --;
|
||||||
|
log('plannings failed, remaining:', syncInProgress);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
syncInProgress --;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isLoggedIn()) {
|
||||||
|
// TRIM_BOATS
|
||||||
|
if (localTimes['trim_boats'] < serverTimes['trim_boats']) {
|
||||||
|
getJSON(QUERY_URL + 'get_trim_boats?changed-after=' + localTimes['trim_boats'], function (code, data) {
|
||||||
|
if (code == 200) {
|
||||||
|
var os = db.transaction('trim_boats', 'readwrite').objectStore('trim_boats');
|
||||||
|
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: 'trim_boats', time: serverTimes['trim_boats'] });
|
||||||
|
syncInProgress --;
|
||||||
|
log('trim_boats synced, remaining:', syncInProgress);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
log("trim_boats: Something went wrong (HTTP " + code + ")");
|
||||||
|
syncOkay = false;
|
||||||
|
syncInProgress --;
|
||||||
|
log('trim_boats failed, remaining:', syncInProgress);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
syncInProgress --;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TRIM_USERS
|
||||||
|
if (localTimes['trim_users'] < serverTimes['trim_users']) {
|
||||||
|
getJSON(QUERY_URL + 'get_trim_users?changed-after=' + localTimes['trim_users'], function (code, data) {
|
||||||
|
if (code == 200) {
|
||||||
|
var os = db.transaction('trim_users', 'readwrite').objectStore('trim_users');
|
||||||
|
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: 'trim_users', time: serverTimes['trim_users'] });
|
||||||
|
syncInProgress --;
|
||||||
|
log('trim_users synced, remaining:', syncInProgress);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
log("trim_users: Something went wrong (HTTP " + code + ")");
|
||||||
|
syncOkay = false;
|
||||||
|
syncInProgress --;
|
||||||
|
log('trim_users failed, remaining:', syncInProgress);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
syncInProgress --;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TRIM_TRIMS
|
||||||
|
if (localTimes['trim_trims'] < serverTimes['trim_trims']) {
|
||||||
|
getJSON(QUERY_URL + 'get_trim_trims?changed-after=' + localTimes['trim_trims'], function (code, data) {
|
||||||
|
if (code == 200) {
|
||||||
|
var os = db.transaction('trim_trims', 'readwrite').objectStore('trim_trims');
|
||||||
|
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: 'trim_trims', time: serverTimes['trim_trims'] });
|
||||||
|
syncInProgress --;
|
||||||
|
log('trim_trims synced, remaining:', syncInProgress);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
log("trim_trims: Something went wrong (HTTP " + code + ")");
|
||||||
|
syncOkay = false;
|
||||||
|
syncInProgress --;
|
||||||
|
log('trim_trims failed, remaining:', syncInProgress);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
syncInProgress --;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
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('news synced, remaining:', syncInProgress);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
log("news: Something went wrong (HTTP " + code + ")");
|
||||||
|
syncOkay = false;
|
||||||
|
syncInProgress --;
|
||||||
|
log('news failed, remaining:', syncInProgress);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
syncInProgress --;
|
||||||
|
}
|
||||||
|
|
||||||
|
// USERS
|
||||||
|
if (localTimes['users'] < serverTimes['users']) {
|
||||||
|
getJSON(QUERY_URL + 'get_users?changed-after=' + localTimes['users'], function (code, data) {
|
||||||
|
if (code == 200) {
|
||||||
|
var os = db.transaction('users', 'readwrite').objectStore('users');
|
||||||
|
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: 'users', time: serverTimes['users'] });
|
||||||
|
syncInProgress --;
|
||||||
|
log('users synced, remaining:', syncInProgress);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
log("users: Something went wrong (HTTP " + code + ")");
|
||||||
|
syncOkay = false;
|
||||||
|
syncInProgress --;
|
||||||
|
log('users failed, remaining:', syncInProgress);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -825,80 +906,13 @@ function sync() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
syncInProgress -= 3;
|
log("Something went wrong (HTTP " + code + ")");
|
||||||
|
syncOkay = false;
|
||||||
|
syncInProgress = 0;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
// 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');
|
|
||||||
log(data);
|
|
||||||
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 --;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
log("Something went wrong (HTTP " + code + ")");
|
|
||||||
syncOkay = false;
|
|
||||||
syncInProgress --;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
syncInProgress --;
|
|
||||||
}
|
|
||||||
|
|
||||||
// USERS
|
|
||||||
if (localTimes['users'] < serverTimes['users']) {
|
|
||||||
getJSON(QUERY_URL + 'get_users?changed-after=' + localTimes['users'], function (code, data) {
|
|
||||||
if (code == 200) {
|
|
||||||
var os = db.transaction('users', 'readwrite').objectStore('users');
|
|
||||||
log(data);
|
|
||||||
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: 'users', time: serverTimes['users'] });
|
|
||||||
syncInProgress --;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
log("Something went wrong (HTTP " + code + ")");
|
|
||||||
syncOkay = false;
|
|
||||||
syncInProgress --;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
syncInProgress --;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
log("Something went wrong (HTTP " + code + ")");
|
|
||||||
syncOkay = false;
|
|
||||||
syncInProgress = 0;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkSync() {
|
function checkSync() {
|
||||||
@@ -917,7 +931,7 @@ function initDatabase() {
|
|||||||
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) {
|
||||||
log("Cannot open DB: " + event.target.errorCode);
|
log("Cannot open DB: " + event.target);
|
||||||
|
|
||||||
runPageScript();
|
runPageScript();
|
||||||
};
|
};
|
||||||
@@ -935,7 +949,7 @@ function initDatabase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
db.onerror = function (event) {
|
db.onerror = function (event) {
|
||||||
log("DB Error: " + event.target.errorCode);
|
log("DB Error: " + event.target);
|
||||||
};
|
};
|
||||||
|
|
||||||
canUseLocalDB = true;
|
canUseLocalDB = true;
|
||||||
|
|||||||
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');
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -1,21 +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 .= 'Du kannst die Saison-Planung momentan leider noch nicht in der App bearbeiten.<br>';
|
|
||||||
$content .= 'Bis diese Funktion implementiert wurde, erstelle Deine Saison-Planung bitte auf <a target="_blank" href="https://regatten.net/' . BOATCLASS . '/planning_edit">unserer Website</a>.<br>';
|
|
||||||
$content .= 'Deine Saison-Planung wird dann automatisch synchronisiert und ist dann auch in dieser App verfügbar.<br>';
|
|
||||||
$content .= 'Wir arbeiten daran, dass Du Deine Saison-Planung bald auch in der App bearbeiten kannst.<br>';
|
|
||||||
$content .= '</p>';
|
|
||||||
$content .= $tpl->load('button', ['Zur Website', 'https://regatten.net/' . BOATCLASS, 'css-class' => 'mb-3']);
|
|
||||||
$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');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
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);
|
||||||
|
}
|
||||||
@@ -50,7 +50,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);
|
||||||
@@ -166,7 +166,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);
|
||||||
|
|||||||
@@ -18,13 +18,13 @@ async function planningSwitchChanged() {
|
|||||||
},
|
},
|
||||||
error: function (xhr, status, error) {
|
error: function (xhr, status, error) {
|
||||||
if (xhr.status == 401) {
|
if (xhr.status == 401) {
|
||||||
console.log('authentification failed');
|
log('authentification failed');
|
||||||
toastError('Authentifizierung fehlgeschlagen. Versuche es erneut.');
|
toastError('Authentifizierung fehlgeschlagen. Versuche es erneut.');
|
||||||
} else if (xhr.status == 0) {
|
} else if (xhr.status == 0) {
|
||||||
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um den Status zu ändern');
|
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um den Status zu ändern');
|
||||||
} else {
|
} else {
|
||||||
console.log('Login: unbekannter Fehler', status, error);
|
log('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);
|
||||||
}
|
}
|
||||||
$('#menu-status').hideMenu();
|
$('#menu-status').hideMenu();
|
||||||
@@ -35,8 +35,6 @@ async function planningSwitchChanged() {
|
|||||||
hideLoader();
|
hideLoader();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
console.log(id, gemeldet, bezahlt);
|
|
||||||
hideLoader();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function planningEditStatus(id) {
|
async function planningEditStatus(id) {
|
||||||
|
|||||||
473
server/scripts/planning_edit.js
Normal file
473
server/scripts/planning_edit.js
Normal file
@@ -0,0 +1,473 @@
|
|||||||
|
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);
|
||||||
|
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();
|
||||||
|
}
|
||||||
@@ -83,12 +83,6 @@ var siteScript = async function() {
|
|||||||
regattas.splice(i, 1);
|
regattas.splice(i, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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 years = await dbGetData('years');
|
var years = await dbGetData('years');
|
||||||
years.sort(function (a, b) {
|
years.sort(function (a, b) {
|
||||||
@@ -194,7 +188,7 @@ var siteScript = async function() {
|
|||||||
|
|
||||||
// ZEILE 5
|
// ZEILE 5
|
||||||
row.content += '<div>';
|
row.content += '<div>';
|
||||||
row.content += '<div>' + entry.planning.steuermann + '</div>';
|
row.content += '<div>' + (entry.planning.steuermann !== null ? entry.planning.steuermann : 'noch unklar') + '</div>';
|
||||||
row.content += '</div>';
|
row.content += '</div>';
|
||||||
|
|
||||||
// ZEILE 6...
|
// ZEILE 6...
|
||||||
@@ -205,72 +199,7 @@ var siteScript = async function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
row.content += '</div>';
|
row.content += '</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['info'] != '')
|
|
||||||
icons.push('<i class="fas fa-info"></i>');
|
|
||||||
if ((entry['meldung'] != '') && (dateTo >= today) && (entry['meldungOffen'] == '1')) {
|
|
||||||
var color = '';
|
|
||||||
if (entry['meldungSchluss'] != null) {
|
|
||||||
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';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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 (regattaResults[entry['id']]) {
|
|
||||||
icons.push('<i class="fas fa-poll"></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);
|
rows.push(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
define('PWA_VERSION', '1.9');
|
define('PWA_VERSION', '1.10.2');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -229,6 +229,7 @@ self.addEventListener('push', async function(event) {
|
|||||||
case 'meldeschluss':
|
case 'meldeschluss':
|
||||||
if (await dbSettingsGet('notify_channel_<?php echo BOATCLASS; ?>_meldeschluss')) {
|
if (await dbSettingsGet('notify_channel_<?php echo BOATCLASS; ?>_meldeschluss')) {
|
||||||
if (await isMyRegatta(getEntry(data, 'id', ''))) okay = true;
|
if (await isMyRegatta(getEntry(data, 'id', ''))) okay = true;
|
||||||
|
// TODO: only if not already registered
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user