Compare commits

...

14 Commits

Author SHA1 Message Date
ostertun
5c22604896 Merge branch 'release/v_1.11.2' 2020-10-22 11:38:44 +02:00
ostertun
4a65b48520 Release v_1.11.2 2020-10-22 11:38:28 +02:00
ostertun
4eb2970671 Special fields 2020-10-22 11:37:19 +02:00
ostertun
0298cefc8b Merge branch 'hotfix/error_reporting' 2020-10-22 01:17:11 +02:00
ostertun
e17f99d005 Merge branch 'hotfix/error_reporting' into develop 2020-10-22 01:17:11 +02:00
ostertun
15d7060354 gitflow-hotfix-stash: error_reporting 2020-10-22 01:10:37 +02:00
ostertun
d38de287dd Merge branch 'hotfix/ios_problems' 2020-10-21 16:27:02 +02:00
ostertun
1cb6de2402 Merge branch 'hotfix/ios_problems' into develop 2020-10-21 16:27:01 +02:00
ostertun
da2beac8d3 hotfix 2020-10-21 16:26:40 +02:00
ostertun
92a11bcfa5 gitflow-hotfix-stash: ios_problems 2020-10-21 16:26:02 +02:00
ostertun
2ddeac4ba4 sW: melde-erinnerungen only for regattas not registered 2020-10-16 13:45:02 +02:00
ostertun
a845137873 Merge branch 'hotfix/remote_logout' into develop 2020-10-16 13:01:24 +02:00
ostertun
8bc0d9b15e Merge branch 'hotfix/add_planning_list_button' into develop 2020-10-16 10:19:20 +02:00
ostertun
3ff17a63e0 Merge branch 'release/v_1.11' into develop 2020-10-15 19:41:33 +02:00
21 changed files with 250 additions and 62 deletions

View File

@@ -9,10 +9,16 @@
log('[tpl] Script "custom.js" loaded');
var loaderCount = 2;
var showConsoleButtonTimeout = setTimeout(function(){
$('#button-show-console').show();
}, 10000);
var showLoader = function() {
if (loaderCount < 1) {
$('#preloader').removeClass('preloader-hide');
loaderCount = 0;
showConsoleButtonTimeout = setTimeout(function(){
$('#button-show-console').show();
}, 10000);
log('[tpl] Loader shown');
}
loaderCount ++;
@@ -22,6 +28,8 @@ var hideLoader = function() {
if (loaderCount < 1) {
$('#preloader').addClass('preloader-hide');
loaderCount = 0;
clearTimeout(showConsoleButtonTimeout);
$('#button-show-console').hide();
log('[tpl] Loader hidden');
}
}

View File

@@ -1,4 +1,4 @@
const DB_VERSION = 6;
const DB_VERSION = 7;
const USER_ID = localStorage.getItem('auth_user');
const USER_NAME = localStorage.getItem('auth_username');
@@ -351,7 +351,7 @@ function dbGetRanking(minDate, maxDate, jugend, jugstrict) {
if (sailors[i].german == '0') {
sailors.splice(i, 1);
} else if (jugend) {
if (((sailors[i].year != null) && (sailors[i].year < (formatDate('Y', maxDate) - YOUTH_AGE))) ||
if (((sailors[i].year != null) && (sailors[i].year < (formatDate('Y', maxDate) - (await dbGetClassProp('youth-age'))))) ||
((sailors[i].year == null) && (jugstrict))) {
sailors.splice(i, 1);
}
@@ -417,6 +417,27 @@ function dbSettingsSet(key, value) {
}
}
function dbGetClassProp(key) {
return new Promise(function(resolve) {
if (canUseLocalDB) {
var request = db.transaction('class').objectStore('class').get(key);
request.onsuccess = function (event) {
resolve(typeof request.result != 'undefined' ? request.result.value : null);
}
} else {
getJSON(QUERY_URL + 'get_class_prop?key=' + key, function (code, data) {
if (code == 200) {
resolve(data.value);
} else {
log("[db] Something went wrong (HTTP " + code + ")");
fail(strings.error_network, 5000);
resolve(null);
}
});
}
});
}
async function updateSyncStatus() {
var lastSync = await dbGetData('update_times', 'last_sync');
lastSync = new Date(lastSync.time * 1000);
@@ -459,8 +480,16 @@ async function runPageScript() {
if (isLoggedIn()) {
var plannings = await dbGetDataIndex('plannings', 'user', USER_ID);
plannings = plannings.map(function (e) { return e.regatta; });
dbSettingsSet('myregattas_' + BOATCLASS, plannings);
plannings_all = plannings.map(function (e) { return e.regatta; });
dbSettingsSet('myregattas_' + BOATCLASS, plannings_all);
for (var i = plannings.length - 1; i >= 0; i --) {
if (plannings[i].gemeldet == '1') plannings.splice(i, 1);
}
plannings_meldung_off = plannings.map(function (e) { return e.regatta; });
dbSettingsSet('myregattas_' + BOATCLASS + '_meldung_off', plannings_meldung_off);
} else {
dbSettingsSet('myregattas_' + BOATCLASS, null);
dbSettingsSet('myregattas_' + BOATCLASS + '_meldung_off', null);
}
}
if (typeof updateSyncStatusTimer == 'undefined') {
@@ -495,7 +524,7 @@ function sync() {
localTimes[entry['table']] = entry['time'];
});
syncInProgress = 11;
syncInProgress = 12;
var syncOkay = true;
log("[db] Sync Start");
$('#i-sync').addClass('fa-spin');
@@ -525,6 +554,24 @@ function sync() {
getJSON(QUERY_URL + 'get_update_time', function (code, serverTimes) {
if (code == 200) {
// CLASS
getJSON(QUERY_URL + 'get_class', function (code, data) {
if (code == 200) {
var os = db.transaction('class', 'readwrite').objectStore('class');
log(data);
for (key in data) {
os.put({ key: key, value: data[key] });
}
syncInProgress --;
log('[db] class synced, remaining:', syncInProgress);
} else {
log("[db] class: Something went wrong (HTTP " + code + ")");
syncOkay = false;
syncInProgress --;
log('[db] class failed, remaining:', syncInProgress);
}
});
// CLUBS
if (localTimes['clubs'] < serverTimes['clubs']) {
getJSON(QUERY_URL + 'get_clubs?changed-after=' + localTimes['clubs'], function (code, data) {
@@ -954,7 +1001,7 @@ function initDatabase() {
db.onversionchange = function (event) {
if (syncTimer != null) window.clearInterval(syncTimer);
if (updateSyncStatusTimer != null) window.clearInterval(updateSyncStatusTimer);
// TODO document.getElementById('syncstatus').innerHTML = '';
$('#syncstatus').html('');
canUseLocalDB = false;
db.close();
location.reload;
@@ -1057,6 +1104,11 @@ function initDatabase() {
osUpdateTimes.add({ table: 'news', time: 0 });
}
if ((oldVersion < 7) && (newVersion >= 7)) {
log('[db] to version 7');
var osClass = db.createObjectStore('class', { keyPath: 'key' });
}
// Force resync after db update
if (oldVersion >= 1) {
var osUpdateTimes = upgradeTransaction.objectStore('update_times');

View File

@@ -38,6 +38,16 @@ function parseDate(string) {
return date;
}
function parseDbTimestamp(string) {
var year = string.substr(0, 4);
var month = string.substr(5, 2);
var day = string.substr(8, 2);
var hour = string.substr(11, 2);
var minute = string.substr(14, 2);
var second = string.substr(17, 2);
return new Date(year, month - 1, day, hour, minute, second);
}
function getToday() {
var date = new Date();
date = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));

View File

@@ -1155,6 +1155,8 @@ var mobileConsole = (function () {
if (!msgContainer.innerHTML) { return; }
leftContainer.appendChild(msgContainer);
var errorReportEntry = { message: arguments[1].newMessage };
if (detailTable || stackTable) {
setCSS(msgContainer, {cursor : 'pointer'});
leftContainer.appendChild(detailTable || stackTable);
@@ -1164,7 +1166,17 @@ var mobileConsole = (function () {
//populate right side
if (stackTrace && typeof stackTrace[stackTrace.length - 1] !== 'undefined') {
rightContainer.appendChild(setCSS(getLink(stackTrace[0].url, stackTrace[0].linkText), {color: '#808080'}));
errorReportEntry.stack = { caller: stackTrace[0].caller, file: stackTrace[0].url, line: stackTrace[0].line, col: stackTrace[0].col };
if ((typeof LINK_PRE !== 'undefined') && (errorReportEntry.stack.file.startsWith(LINK_PRE))) {
errorReportEntry.stack.file = errorReportEntry.stack.file.substr(LINK_PRE.length);
}
var pos = errorReportEntry.stack.file.indexOf('?');
if (pos >= 0) {
errorReportEntry.stack.file = errorReportEntry.stack.file.substr(0, pos);
}
}
if (typeof onConsoleOutput === 'function') onConsoleOutput(errorReportEntry);
//add to line
lineContainer.appendChild(leftContainer);

View File

@@ -95,12 +95,11 @@ $(document).ready(function(){
log('[pwa] iOS Detected');
if($('#menu-install-pwa-ios, .add-to-home').length){
if (!readCookie('Sticky_pwa_rejected_install')) {
setTimeout(function(){
function triggerPwaInstallIos() {
log('[pwa] Triggering PWA / Add to Home Screen Menu for iOS');
setTimeout(function(){
$('.add-to-home').addClass('add-to-home-visible add-to-home-ios');
$('#menu-install-pwa-ios, .menu-hider').addClass('menu-active');
},3000);
}
var welcomActive = $('#menu-welcome').hasClass('menu-active');
if (welcomActive) {
@@ -108,6 +107,7 @@ $(document).ready(function(){
} else {
triggerPwaInstallIos();
}
},3000);
};
}
}

View File

@@ -3,16 +3,40 @@
header('Content-Type: text/javascript');
require_once(__DIR__ . '/../../server/config.php');
require_once(__DIR__ . '/../../server/version.php');
?>
const QUERY_URL = '<?php echo QUERY_URL; ?>';
const BOATCLASS = '<?php echo BOATCLASS; ?>';
const LINK_PRE = '<?php echo SERVER_ADDR; ?>/';
const YOUTH_AGE = '<?php echo $_CLASS['youth-age']; ?>';
const YOUTH_GERMAN_NAME = '<?php echo $_CLASS['youth-german-name']; ?>';
const PUSH_SERVER_KEY = '<?php echo PUSH_SERVER_KEY; ?>';
var consoleOutput = [];
function onConsoleOutput(entry) {
consoleOutput.push(entry);
}
window.onerror = function(message, source, lineno, colno, errorError) {
if (source.startsWith(LINK_PRE)) {
source = source.substr(LINK_PRE.length);
}
var pos = source.indexOf('?');
if (pos >= 0) {
source = source.substr(0, pos);
}
consoleOutput.push({
message: message,
stack: {
caller: '',
file: source,
line: lineno,
col: colno
}
});
}
function log() {
var now = new Date();
var hour = now.getHours().toString();
@@ -471,7 +495,7 @@ async function updateNewsBadge() {
var sum = 0;
for (var n in news) {
var newsEntry = news[n];
newsEntry.date = new Date(Date.parse(newsEntry.date));
newsEntry.date = parseDbTimestamp(newsEntry.date);
if (newsEntry.date > now) continue;
if (newsEntry.date < newsRead) continue;
sum ++;
@@ -508,7 +532,7 @@ var initRegatten = function() {
var onServiceWorkerLoaded = function() {
log('[app] sW loaded');
if ((swRegistration !== null) && canUseLocalDB) {
if ((swRegistration !== null) && (swRegistration.pushManager) && canUseLocalDB) {
pushesPossible = true;
updatePushBadge();
} else {
@@ -547,19 +571,39 @@ var addConsoleOpenerToPreloader = function() {
addConsoleOpenerToPreloader = function(){};
var preloader = document.getElementById('preloader');
var button = document.createElement('a');
button.id = 'button-show-console';
button.href = '#';
button.classList = 'btn rounded-s text-uppercase font-900 shadow-m m-3';
button.classList = 'btn rounded-s text-uppercase font-900 shadow-m m-3 bg-red2-dark bg-white';
button.style.position = 'fixed';
button.style.bottom = 0;
button.style.left = 0;
button.style.right = 0;
button.innerHTML = '&lt;/&gt;';
button.innerHTML = 'Fehlerbericht senden';
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();
alert('FEHLERBERICHT\nEs wird jetzt ein Fehlerbericht an die Entwickler geschickt.\nBitte stelle sicher, dass Du mit dem Internet verbunden bist und drücke dann auf OK.');
$.ajax({
url: QUERY_URL + 'error_report',
method: 'POST',
data: {
errors: consoleOutput,
device: navigator.userAgent,
version: '<?php echo PWA_VERSION; ?>'
},
error: function (xhr, status, error) {
if (xhr.status == 0) {
alert('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um den Fehlerbericht zu senden');
} else {
alert('Beim Senden ist ein unbekannter Fehler aufgetreten. Bitte versuche es noch einmal');
}
},
success: function (data, status, xhr) {
alert('Wir leiten Dich jetzt zum erstellten Fehlerbericht um, sodass Du ggf. weitere Informationen ergänzen kannst.');
location.href = 'https://github.com/ostertun/RegattenApp/issues/' + data.issueNumber;
}
});
return false;
}
setTimeout(function(){
preloader.appendChild(button);
}, 5000);
$(button).hide();
}
addConsoleOpenerToPreloader();

View File

@@ -80,7 +80,8 @@
$sp['output'] .= $tpl->load('card', [$content]);
// Regattas Menu
$items = '<p id="menu-item-yourplanning" class="mb-2 mt-1" style="line-height: 1.5em;"></p>';
$items = '<p id="menu-item-special" class="mb-2 mt-1" style="line-height: 1.5em;"></p>';
$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']);

View File

@@ -27,7 +27,8 @@
$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 = '<p id="menu-item-special" class="mb-2 mt-1" style="line-height: 1.5em;"></p>';
$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']);

View File

@@ -20,7 +20,8 @@
$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 = '<p id="menu-item-special" class="mb-2 mt-1" style="line-height: 1.5em;"></p>';
$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']);

View File

@@ -21,8 +21,11 @@
$sp['output'] .= $tpl->load('card', [$content, 'html-id' => 'card-regattas']);
$sp['output'] .= $tpl->load('card', ['<p></p>', 'html-id' => 'card-special']);
// Menu
$items = '<p id="menu-item-yourplanning" class="mb-2 mt-1" style="line-height: 1.5em;"></p>';
$items = '<p id="menu-item-special" class="mb-2 mt-1" style="line-height: 1.5em;"></p>';
$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']);

View File

@@ -188,6 +188,9 @@ var siteScript = async function() {
list += '<div>' + ((club != null) ? club['kurz'] : '') + '</div>';
// Special
if (regatta.special.substr(0, 1) == '#') {
regatta.special = '* ' + regatta.special.substr(1);
}
list += '<div>' + regatta['special'] + '</div>';
// Icons
@@ -287,6 +290,9 @@ var siteScript = async function() {
list += '<div>' + ((club != null) ? club['kurz'] : '') + '</div>';
// Special
if (regatta.special.substr(0, 1) == '#') {
regatta.special = '* ' + regatta.special.substr(1);
}
list += '<div>' + regatta['special'] + '</div>';
// Icons
@@ -393,6 +399,9 @@ var siteScript = async function() {
list += '<div>' + ((club != null) ? club['kurz'] : '') + '</div>';
// Special
if (regatta.special.substr(0, 1) == '#') {
regatta.special = '* ' + regatta.special.substr(1);
}
list += '<div>' + regatta['special'] + '</div>';
// Icons

View File

@@ -66,7 +66,7 @@ var siteScript = async function() {
lastYear.setFullYear(lastYear.getFullYear() - 1);
for (var n in news) {
var newsEntry = news[n];
newsEntry.date = new Date(Date.parse(newsEntry.date));
newsEntry.date = parseDbTimestamp(newsEntry.date);
if (newsEntry.date > now) continue;
if (newsEntry.date < lastYear) break;
newsEntry.unread = (newsEntry.date > newsRead);

View File

@@ -6,6 +6,20 @@ async function onRegattaClicked(id) {
var dateTo = parseDate(regatta['date']);
dateTo.setDate(dateTo.getDate() + Math.max(parseInt(regatta['length']) - 1, 0));
var specialFields = await dbGetClassProp('special-fields');
if (specialFields === null) specialFields = {};
if (regatta.special.substr(0, 1) == '#') {
regatta.special = regatta.special.substr(1);
if (typeof specialFields[regatta.special] !== 'undefined') {
$('#menu-item-special').text(specialFields[regatta.special]);
} else {
$('#menu-item-special').text('ERROR');
}
$('#menu-item-special').show();
} else {
$('#menu-item-special').hide();
}
var plannings = await dbGetDataIndex('plannings', 'regatta', regatta['id']);
var planning = null;
if (isLoggedIn()) {

View File

@@ -214,6 +214,9 @@ var siteScript = async function() {
row.content += '<div>' + ((club != null) ? club['kurz'] : '') + '</div>';
// Special
if (entry.special.substr(0, 1) == '#') {
entry.special = '* ' + entry.special.substr(1);
}
row.content += '<div>' + entry['special'] + '</div>';
// Icons

View File

@@ -408,6 +408,9 @@ var siteScript = async function() {
row.content += '<div>' + ((entry['number'] != null) ? ('# ' + entry['number']) : '') + '</div>';
// Special
if (entry.special.substr(0, 1) == '#') {
entry.special = '* ' + entry.special.substr(1);
}
row.content += '<div>' + entry['special'] + '</div>';
// Club

View File

@@ -158,6 +158,9 @@ var siteScript = async function() {
row.content += '<div>' + ((entry['number'] != null) ? ('# ' + entry['number']) : '') + '</div>';
// Special
if (entry.special.substr(0, 1) == '#') {
entry.special = '* ' + entry.special.substr(1);
}
row.content += '<div>' + entry['special'] + '</div>';
// Club

View File

@@ -137,6 +137,7 @@ async function selectChange(callSiteScript = true) {
jugend = jugstrict = true;
break;
case 'idjm':
var youthGermanName = await dbGetClassProp('youth-german-name');
var beginn = null;
var regattas = await dbGetData('regattas');
regattas.sort(function(a,b){ return b.date.localeCompare(a.date); });
@@ -146,7 +147,7 @@ async function selectChange(callSiteScript = true) {
if ((date < parseDate('01.01.' + year)) || (date > parseDate('31.12.' + year))) {
continue;
}
if (regatta.name.indexOf(YOUTH_GERMAN_NAME) >= 0) {
if (regatta.name.indexOf(youthGermanName) >= 0) {
beginn = ((regatta.meldungSchluss != null) ? parseDate(regatta.meldungSchluss) : date);
break;
}
@@ -162,7 +163,7 @@ async function selectChange(callSiteScript = true) {
jugend = true;
jugstrict = false;
} else {
$('#div-rank').html('Keine ' + YOUTH_GERMAN_NAME + ' gefunden!');
$('#div-rank').html('Keine ' + youthGermanName + ' gefunden!');
$('#input-search').parent().hide();
return;
}

View File

@@ -109,6 +109,9 @@ var siteScript = async function() {
var heute = false;
rows = [];
var specialFields = await dbGetClassProp('special-fields');
if (specialFields === null) specialFields = {};
var specialShown = {};
for (id in regattas) {
var entry = regattas[id];
@@ -146,7 +149,16 @@ var siteScript = async function() {
row.content += '<div>' + ((club != null) ? club['kurz'] : '') + '</div>';
// Special
row.content += '<div>' + entry['special'] + '</div>';
if (entry.special.substr(0, 1) == '#') {
entry.special = entry.special.substr(1);
if (typeof specialFields[entry.special] !== 'undefined') {
specialShown[entry.special] = specialFields[entry.special];
entry.special = '* ' + entry.special;
} else {
entry.special = 'ERROR';
}
}
row.content += '<div>' + entry.special + '</div>';
// Icons
var icons = [];
@@ -223,12 +235,24 @@ var siteScript = async function() {
rows.push(null);
}
if (Object.keys(specialShown).length > 0) {
var specialText = '';
for (key in specialShown) {
specialText += '* ' + key + ': ' + specialShown[key] + '<br>';
}
$('#card-special').find('p').html(specialText);
$('#card-special').show();
} else {
$('#card-special').hide();
}
drawList();
} else {
$('#p-count').html('Keine Regatten gefunden!');
$('#div-regattas').hide();
$('#input-search').parent().hide();
$('#card-special').hide();
}
hideLoader();

View File

@@ -1,5 +1,5 @@
<?php
define('PWA_VERSION', '1.11h2');
define('PWA_VERSION', '1.11.2');
?>

View File

@@ -182,9 +182,9 @@ function getEntry(data, index, defaultValue) {
return ((typeof data[index] !== "undefined") ? data[index] : defaultValue);
}
function isMyRegatta(id) {
function isMyRegatta(id, suffix = '') {
return new Promise(async function (resolve) {
var regattas = await dbSettingsGet('myregattas_<?php echo BOATCLASS; ?>');
var regattas = await dbSettingsGet('myregattas_<?php echo BOATCLASS; ?>' + suffix);
if (regattas == null) resolve(false);
else resolve(regattas.includes(id.toString()));
});
@@ -228,8 +228,7 @@ self.addEventListener('push', async function(event) {
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
if (await isMyRegatta(getEntry(data, 'id', ''), '_meldung_off')) okay = true;
}
break;
default: