Refactor logging implementation and enhance authentication logging

This commit is contained in:
2025-01-30 22:02:35 +01:00
parent 2ebf92a5d5
commit 23a6d9b10f
5 changed files with 38 additions and 27 deletions

View File

@@ -2,31 +2,36 @@ import { checkSession, login, logout } from './auth.js';
import { saveTask } from './tasks.js';
import { saveTags, loadTags } from './tags.js';
navigator.serviceWorker.register('/service-worker.js')
.then(registration => {
console.log('ServiceWorker registration successful with scope: ', registration.scope);
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/service-worker.js')
.then(registration => {
console.log('ServiceWorker registration successful with scope: ', registration.scope);
registration.onupdatefound = () => {
const installingWorker = registration.installing;
installingWorker.onstatechange = () => {
if (installingWorker.state === 'installed') {
if (navigator.serviceWorker.controller) {
// New update available
console.log('New content is available; please refresh.');
if (confirm('New version available. Do you want to update?')) {
window.location.reload();
registration.onupdatefound = () => {
const installingWorker = registration.installing;
installingWorker.onstatechange = () => {
if (installingWorker.state === 'installed') {
if (navigator.serviceWorker.controller) {
// New update available
console.log('New content is available; please refresh.');
if (confirm('New version available. Do you want to update?')) {
window.location.reload();
}
} else {
// Content is cached for offline use
console.log('Content is cached for offline use.');
}
}
} else {
// Content is cached for offline use
console.log('Content is cached for offline use.');
}
}
};
};
})
.catch(error => {
console.log('ServiceWorker registration failed: ', error);
});
};
};
})
.catch(error => {
console.log('ServiceWorker registration failed: ', error);
});
});
}
document.addEventListener('DOMContentLoaded', function() {
const loginForm = document.getElementById('loginForm');