1// Register service worker to control making site work offline 2if ('serviceWorker' in navigator && (window.innerWidth < 767)) { 3 navigator.serviceWorker 4 .register('/a2hs-sw.js') 5 .then(() => { console.log('Service Worker Registered'); }); 6} else { 7 if (document.querySelector(".add-to-home") != null) { 8 document.querySelector(".add-to-home").remove(); 9 } 10} 11 12// Code to handle install prompt on desktop 13 14let deferredPrompt; 15const a2hSection = document.querySelector('.add-to-home'); 16if (a2hSection != null) { 17 a2hSection.style.display = 'none'; 18} 19 20window.addEventListener('beforeinstallprompt', (e) => { 21 // Prevent Chrome 67 and earlier from automatically showing the prompt 22 e.preventDefault(); 23 // Stash the event so it can be triggered later. 24 deferredPrompt = e; 25 // Update UI to notify the user they can add to home screen 26 27 28 const addBtnH2 = document.querySelector('.add-to-home h2'); 29 30 if (a2hSection != null && addBtnH2 != null) { 31 setTimeout(function () { 32 a2hSection.style.display = 'flex'; 33 34 addBtnH2.addEventListener('click', () => { 35 // hide our user interface that shows our A2HS button 36 a2hSection.style.display = 'none'; 37 // Show the prompt 38 deferredPrompt.prompt(); 39 // Wait for the user to respond to the prompt 40 deferredPrompt.userChoice.then((choiceResult) => { 41 if (choiceResult.outcome === 'accepted') { 42 console.log('User accepted the A2HS prompt'); 43 } else { 44 console.log('User dismissed the A2HS prompt'); 45 } 46 deferredPrompt = null; 47 }); 48 }); 49 50 }, 15 * 1000); 51 } 52});
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.