Compare commits

...

7 Commits

Author SHA1 Message Date
ostertun
0298cefc8b Merge branch 'hotfix/error_reporting' 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
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
fa4770e12a Merge branch 'hotfix/remote_logout' 2020-10-16 13:01:24 +02:00
ostertun
a6f2568753 gitflow-hotfix-stash: remote_logout 2020-10-16 13:01:06 +02:00
8 changed files with 105 additions and 24 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');
}
}
@@ -370,7 +378,7 @@ eraseCookie('sticky_dark_mode');
$(this).parent().find('span').removeClass('input-style-1-inactive input-style-1-active');
}
});
log('[tpl] init a2h');
//Adding added-to-homescreen class to be targeted when used as PWA.

View File

@@ -910,7 +910,12 @@ function sync() {
}
} else {
log("[db] Something went wrong (HTTP " + code + ")");
if (code == 401) {
log("[db] Auth invalid. Logout initiated");
logoutClearStorage();
} else {
log("[db] Something went wrong (HTTP " + code + ")");
}
syncOkay = false;
syncInProgress = 0;
}

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,8 +1166,18 @@ 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);
lineContainer.appendChild(rightContainer);

View File

@@ -95,19 +95,19 @@ $(document).ready(function(){
log('[pwa] iOS Detected');
if($('#menu-install-pwa-ios, .add-to-home').length){
if (!readCookie('Sticky_pwa_rejected_install')) {
function triggerPwaInstallIos() {
log('[pwa] Triggering PWA / Add to Home Screen Menu for iOS');
setTimeout(function(){
setTimeout(function(){
function triggerPwaInstallIos() {
log('[pwa] Triggering PWA / Add to Home Screen Menu for iOS');
$('.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) {
$('#menu-welcome-a-okay').click(triggerPwaInstallIos);
} else {
triggerPwaInstallIos();
}
}
var welcomActive = $('#menu-welcome').hasClass('menu-active');
if (welcomActive) {
$('#menu-welcome-a-okay').click(triggerPwaInstallIos);
} else {
triggerPwaInstallIos();
}
},3000);
};
}
}

View File

@@ -3,6 +3,7 @@
header('Content-Type: text/javascript');
require_once(__DIR__ . '/../../server/config.php');
require_once(__DIR__ . '/../../server/version.php');
?>
@@ -13,6 +14,31 @@ 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 +497,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 +534,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 +573,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);
preloader.appendChild(button);
$(button).hide();
}
addConsoleOpenerToPreloader();

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

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