1const installBannerButton = document.querySelector('#jwc-install-banner > .jwc-install-banner__install-button'); 2const closeBannerButton = document.querySelector('#jwc-install-banner > .jwc-install-banner__close-button'); 3const dismissedInfo = JSON.parse(localStorage.getItem('installBanner')); 4let deferredPrompt; 5 6if (!dismissedInfo?.dismissed) { 7 window.addEventListener('beforeinstallprompt', e => { 8 e.preventDefault(); 9 deferredPrompt = e; 10 11 document.documentElement.setAttribute('data-install-banner', 'visible'); 12 13 if (installBannerButton) { 14 installBannerButton.addEventListener('click', (e) => { 15 document.documentElement.removeAttribute('data-install-banner'); 16 17 deferredPrompt.prompt(); 18 deferredPrompt.userChoice.then(choiceResult => { 19 if (choiceResult.outcome === 'accepted') { 20 console.log('User accepted the A2HS prompt'); 21 } else { 22 console.log('User dismissed the A2HS prompt'); 23 } 24 25 deferredPrompt = null; 26 dismissBanner(); 27 }); 28 }) 29 } 30 31 if (closeBannerButton) { 32 closeBannerButton.addEventListener('click', (e) => { 33 e.preventDefault(); 34 dismissBanner(); 35 }) 36 } 37 }); 38} 39 40 41function dismissBanner () { 42 document.documentElement.removeAttribute('data-install-banner'); 43 44 const dismissedInfoObject = { dismissed: true, timestamp: Date.now() }; 45 46 localStorage.setItem('installBanner', JSON.stringify(dismissedInfoObject)); 47}
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.