Merge branch 'release/v_1.8'

This commit is contained in:
ostertun
2020-10-02 01:29:43 +02:00
11 changed files with 329 additions and 212 deletions

View File

@@ -508,6 +508,9 @@ function sync() {
$('#i-sync').removeClass('fa-spin');
}, 500);
if (typeof onAfterSync === 'function') {
onAfterSync();
}
runPageScript();
}
}, 100);
@@ -1033,8 +1036,7 @@ function initDatabase() {
}
}
function resetDb(silent = true) {
$('#menu-developer').hideMenu();
function resetDb() {
if (canUseLocalDB) {
showLoader();
var osUpdateTimes = db.transaction('update_times', 'readwrite').objectStore('update_times');
@@ -1051,11 +1053,6 @@ function resetDb(silent = true) {
osUpdateTimes.put({ table: 'news', time: 0 });
osUpdateTimes.put({ table: 'users', time: 0 });
console.log('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();
} 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.');
}
}

View File

@@ -345,7 +345,7 @@ var mobileConsole = (function () {
top: 'auto',
right: 0,
width: '100%',
zIndex: 10000,
zIndex: 1000000,
padding: 0,
paddingBottom: options.browserinfo.isMobile ? '35px' : '25px',
margin: 0,
@@ -662,7 +662,7 @@ var mobileConsole = (function () {
height: newHeight
});
setCSS(document.body, {
paddingBottom: existingPadding + Math.abs(parseInt(newHeight, 10) + elements.topbar.offsetHeight) + 'px'
//paddingBottom: existingPadding + Math.abs(parseInt(newHeight, 10) + elements.topbar.offsetHeight) + 'px'
});
elements.buttons.toggler.innerHTML = (elements.base.minimized) ? elements.arrowDown : elements.arrowUp;
elements.buttons.toggler.setAttribute('title', (elements.base.minimized) ? 'Minimize console' : 'Maximize console');
@@ -747,7 +747,7 @@ var mobileConsole = (function () {
});
var existingPadding = isNaN(parseInt(document.body.style.paddingBottom, 10)) ? 0 : parseInt(document.body.style.paddingBottom, 10);
setCSS(document.body, {
paddingBottom: existingPadding + Math.abs(console.offsetHeight + elements.topbar.offsetHeight) + 'px'
//paddingBottom: existingPadding + Math.abs(console.offsetHeight + elements.topbar.offsetHeight) + 'px'
});
elements.scrollcontainer.scrollTop = elements.scrollcontainer.scrollHeight;
@@ -914,6 +914,7 @@ var mobileConsole = (function () {
while (i--) {
thisLine = lines[i].trim();
lineAndColumn = thisLine.match(/(?::)(\d+)(?::)(\d+)/);
if (lineAndColumn === null) continue;
url = urlFromString(thisLine).replace(lineAndColumn[0], '').split('#')[0] || '';
caller = htmlToString(thisLine.replace(urlFromString(thisLine), '').replace(separator, '').replace('at ', '').trim());
if (caller === '' || caller === lineAndColumn[0]) { continue; }

View File

@@ -122,8 +122,8 @@ var login = function() {
showLoader();
var username = $('#input-login-username').val();
var password = $('#input-login-password').val();
$('#input-login-username').val('');
$('#input-login-password').val('');
$('#input-login-username').val('').trigger('focusin').trigger('focusout');
$('#input-login-password').val('').trigger('focusin').trigger('focusout');
$.ajax({
url: QUERY_URL + 'login',
method: 'POST',
@@ -135,7 +135,7 @@ var login = function() {
error: function (xhr, status, error) {
if (xhr.status == 401) {
toastError('Benutzername oder Passwort falsch');
$('#input-login-username').val(username);
$('#input-login-username').val(username).trigger('focusin').trigger('focusout');
} else if (xhr.status == 0) {
toastError('Du bist momentan offline.<br>Stelle eine Internetverbindung her, um Dich anzumelden');
$('#menu-login').hideMenu();
@@ -203,7 +203,28 @@ 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) {
console.log('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) {
console.log('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();
navigator.serviceWorker.getRegistrations().then(function (registrations) {
for (let registration of registrations) {
@@ -217,7 +238,8 @@ function resetCache() {
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;
@@ -320,10 +342,16 @@ async function updatePushSwitches() {
if ($('#switch-pushes').prop('checked')) {
$('#p-pushes-info').show();
$('.a-switch-pushes-channel').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').hide();
$('.a-switch-pushes-channel-all').hide();
$('.a-switch-pushes-channel-my').hide();
}
}
@@ -380,6 +408,22 @@ function updatePushBadge() {
});
}
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() {
showLoader();
@@ -399,7 +443,8 @@ var initRegatten = function() {
// Pushes
$('#a-switch-pushes').click(pushesSubscribeClicked);
$('.a-switch-pushes-channel').click(pushesChannelClicked);
$('.a-switch-pushes-channel-all').click(pushesChannelClicked);
$('.a-switch-pushes-channel-my').click(pushesChannelClicked);
}
var onServiceWorkerLoaded = function() {
@@ -414,4 +459,32 @@ var onServiceWorkerLoaded = function() {
var onDatabaseLoaded = function() {
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 btn-full rounded-s text-uppercase font-900 shadow-m bg-highlight m-3';
button.style.position = 'fixed';
button.style.bottom = 0;
button.style.left = 0;
button.style.right = 0;
button.innerHTML = 'Show Console';
button.onclick = function(){
mobileConsole.displayConsole();
return false;
}
setTimeout(function(){
preloader.appendChild(button);
}, 5000);
}
addConsoleOpenerToPreloader();

View File

@@ -154,7 +154,7 @@
(meine) bezieht sich auf die Regatten, die in Deiner Saison-Planung sind,<br>
(alle) informiert Dich &uuml;ber alle Regatten
</p>
<a href="#" data-trigger-switch="switch-pushes-news" class="pb-2 a-switch-pushes-channel">
<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">
@@ -162,15 +162,16 @@
<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">
<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">
<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">
@@ -178,15 +179,16 @@
<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">
<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&uuml;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">
<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&uuml;gbar (alle)</span>
<div class="custom-control scale-switch ios-switch">
@@ -194,9 +196,10 @@
<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">
<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>
@@ -211,22 +214,22 @@
<div class="divider divider-margins mb-n2"></div>
<div class="content">
<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>
<span>Infos zur BETA</span>
<span>App-Wiki</span>
<i class="fa fa-angle-right"></i>
</a>
<a href="javascript:resetDb(false);">
<a href="javascript:deleteDb();">
<i class="fa font-14 fa-database rounded-s bg-highlight color-white"></i>
<span>Reset Database</span>
<i class="fa fa-angle-right"></i>
</a>
<a href="javascript:resetCache();">
<a href="javascript:deleteCache();">
<i class="fa font-14 fa-trash-alt rounded-s bg-highlight color-white"></i>
<span>Reset Cache</span>
<i class="fa fa-angle-right"></i>
</a>
<a href="https://report.regatten.net/">
<a href="https://github.com/ostertun/RegattenApp/issues">
<i class="fa font-14 fa-bug rounded-s bg-highlight color-white"></i>
<span>Problem melden</span>
<i class="fa fa-angle-right"></i>

View File

@@ -68,10 +68,10 @@ function addRace() {
rlp: (100 * rlf * ((fb + 1 - pl) / fb))
};
$('#input-rlf').val('');
$('#input-m').val('');
$('#input-fb').val('');
$('#input-pl').val('');
$('#input-rlf').val('').trigger('focusin').trigger('focusout');
$('#input-m').val('').trigger('focusin').trigger('focusout');
$('#input-fb').val('').trigger('focusin').trigger('focusout');
$('#input-pl').val('').trigger('focusin').trigger('focusout');
races.push(race);
reCalc();

View File

@@ -31,8 +31,8 @@ function sendMessage() {
},
success: function (data, status, xhr) {
toastOk('Nachricht erfolgreich versandt!');
$('#input-subject').val('');
$('#input-message').val('');
$('#input-subject').val('').trigger('focusin').trigger('focusout');
$('#input-message').val('').trigger('focusin').trigger('focusout');
hideLoader();
}
});

View File

@@ -12,7 +12,6 @@ async function onNewsClicked(id) {
}
function addCard(newsEntry) {
console.log(newsEntry);
var content = '<h2>' + 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>';
@@ -29,16 +28,17 @@ var siteScript = async function() {
news.sort(function (a,b) {
return b.date.localeCompare(a.date);
});
var today = getToday();
var lastYear = new Date(today);
var now = new Date();
var lastYear = new Date();
lastYear.setFullYear(lastYear.getFullYear() - 1);
console.log(today, lastYear);
for (var n in news) {
var newsEntry = news[n];
newsEntry.date = parseDate(newsEntry.date.substring(0, 10));
if (newsEntry.date > today) continue;
newsEntry.date = new Date(Date.parse(newsEntry.date));
if (newsEntry.date > now) continue;
if (newsEntry.date < lastYear) break;
addCard(newsEntry);
}
dbSettingsSet('news_read_' + BOATCLASS, now);
updateNewsBadge();
hideLoader();
}

View File

@@ -111,8 +111,8 @@ async function selectChange(callSiteScript = true) {
var year = parseInt($('#select-year').val());
if (type == "user") {
$('#select-year').parent().hide();
$('#input-from').parent().show();
$('#input-to').parent().show();
$('#input-from').trigger('focusin').trigger('focusout').parent().show();
$('#input-to').trigger('focusin').trigger('focusout').parent().show();
$('#input-jugend').parent().parent().show();
$('#input-jugstrict').parent().parent().show();
$('#button-show').show();
@@ -174,7 +174,19 @@ async function selectChange(callSiteScript = true) {
$('#input-jugend').prop('checked', jugend);
$('#input-jugstrict').prop('checked', jugstrict);
if (callSiteScript && (typeof siteScript === 'function'))
if (callSiteScript && (typeof siteScript === 'function')) {
history.replaceState(null, '', '?type=' + type + '&year=' + year)
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)
siteScript();
}
}
@@ -190,6 +202,19 @@ function initSelects() {
$('#select-year').html('<option value="' + year + '">' + year + '</option>');
$('#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);
}
@@ -218,7 +243,7 @@ var siteScript = async function() {
initSelects();
$('#select-type').change(selectChange);
$('#select-year').change(selectChange);
$('#button-show').click(siteScript);
$('#button-show').click(buttonShowPressed);
$('#input-search').on('input', drawList);
}

View File

@@ -1,8 +1,8 @@
function selectChange(callSiteScript = true) {
var val = $('#select-year').val();
if (val == "user") {
$('#input-from').parent().show();
$('#input-to').parent().show();
$('#input-from').trigger('focusin').trigger('focusout').parent().show();
$('#input-to').trigger('focusin').trigger('focusout').parent().show();
$('#button-show').show();
} else {
$('#input-from').parent().hide();
@@ -12,7 +12,16 @@ function selectChange(callSiteScript = true) {
$('#input-from').val(val + '-01-01');
$('#input-to').val(val + '-12-31');
if (callSiteScript && (typeof siteScript === 'function'))
if (callSiteScript && (typeof siteScript === 'function')) {
history.replaceState(null, '', '?year=' + val);
siteScript();
}
}
}
function buttonShowPressed() {
if (typeof siteScript === 'function') {
history.replaceState(null, '', '?year=user&from=' + $('#input-from').val() + "&to=" + $('#input-to').val())
siteScript();
}
}
@@ -24,6 +33,15 @@ function initYear() {
$('#select-year').html('<option value="' + year + '">' + year + '</option>');
$('#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);
}
@@ -50,7 +68,7 @@ var siteScript = async function() {
firstCall = false;
initYear();
$('#select-year').change(selectChange);
$('#button-show').click(siteScript);
$('#button-show').click(buttonShowPressed);
$('#input-search').on('input', drawList);
}

View File

@@ -1,5 +1,5 @@
<?php
define('PWA_VERSION', '1.7');
define('PWA_VERSION', '1.8');
?>