Improved, refactored, added options, prompts, jekyll website

This commit is contained in:
AjaySi
2023-10-24 19:49:31 +05:30
parent 2860345aaf
commit eb87847124
78 changed files with 14455 additions and 106 deletions

43
pseo_website/_site/app.js Normal file
View File

@@ -0,0 +1,43 @@
const $notification = $('#notification');
const $btnRefresh = $('#notification .toast-body>button');
if ('serviceWorker' in navigator) {
/* Registering Service Worker */
navigator.serviceWorker.register('/sw.js')
.then(registration => {
/* in case the user ignores the notification */
if (registration.waiting) {
$notification.toast('show');
}
registration.addEventListener('updatefound', () => {
registration.installing.addEventListener('statechange', () => {
if (registration.waiting) {
if (navigator.serviceWorker.controller) {
$notification.toast('show');
}
}
});
});
$btnRefresh.click(() => {
if (registration.waiting) {
registration.waiting.postMessage('SKIP_WAITING');
}
$notification.toast('hide');
});
});
let refreshing = false;
/* Detect controller change and refresh all the opened tabs */
navigator.serviceWorker.addEventListener('controllerchange', () => {
if (!refreshing) {
window.location.reload();
refreshing = true;
}
});
}