dowlnoad link on about page

This commit is contained in:
2024-10-16 08:57:42 +02:00
parent c3add695d2
commit cd868ab4f6
4 changed files with 54 additions and 1 deletions

View File

@@ -96,6 +96,7 @@
document.body.style.background = "transparent";
}
</script>
<script src="install_pwa.js" defer></script>
<!-- Splash screen -->
<!-- <script>
var dartPdfJsBaseUrl = "https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.2.146/";

View File

@@ -0,0 +1,33 @@
let deferredPrompt;
// add to homescreen
window.addEventListener("beforeinstallprompt", (e) => {
// Prevent Chrome 67 and earlier from automatically showing the prompt
e.preventDefault();
// Stash the event so it can be triggered later.
deferredPrompt = e;
});
function isDeferredNotNull() {
return deferredPrompt != null;
}
function presentAddToHome() {
if (deferredPrompt != null) {
// Update UI to notify the user they can add to home screen
// Show the prompt
deferredPrompt.prompt();
// Wait for the user to respond to the prompt
deferredPrompt.userChoice.then((choiceResult) => {
if (choiceResult.outcome === "accepted") {
console.log("User accepted the A2HS prompt");
} else {
console.log("User dismissed the A2HS prompt");
}
deferredPrompt = null;
});
} else {
console.log("deferredPrompt is null");
return null;
}
}