1let deferredPrompt; 2 3const isIos = () => { 4 const userAgent = window.navigator.userAgent.toLowerCase(); 5 return /iphone|ipad|ipod/.test(userAgent); 6} 7const isInStandaloneMode = () => ('standalone' in window.navigator) && (window.navigator.standalone); 8window.addEventListener('load', function () { 9 if (isIos() && !isInStandaloneMode()) { 10 showInstallButton(); 11 } 12 if (!isIos()) { 13 window.addEventListener('beforeinstallprompt', (event) => { 14 // Prevent the default prompt 15 event.preventDefault(); 16 // Save the event for later use 17 deferredPrompt = event; 18 // Display your custom "Install App" button 19 showInstallButton(); 20 }); 21 } 22}); 23function showInstallButton() { 24 const installButton = document.querySelector('.pwa-install'); 25 const installButtonUninstall = document.querySelector('.pwa-uninstall'); 26 installButton.style.display = 'none'; 27 installButtonUninstall.style.display = 'block'; 28} 29 30function install() { 31 32 if (deferredPrompt) { 33 deferredPrompt.prompt(); 34 deferredPrompt.userChoice.then((choiceResult) => { 35 if (choiceResult.outcome === 'accepted') { 36 console.log('User accepted the install prompt'); 37 } else { 38 console.log('User dismissed the install prompt'); 39 } 40 41 deferredPrompt = null; 42 }); 43 }else if (isIos()) { 44 45 var modal = document.getElementById("myModalPWA"); 46 var span = document.querySelector("#myModalPWA .close"); 47 48 modal.style.display = "block"; 49 span.onclick = function() { 50 modal.style.display = "none"; 51 } 52 } 53}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.