1// Execute the script only when the DOM is ready. 2ready = (callback) => { 3 if (document.readyState !== 'loading') { 4 callback() 5 } else { 6 document.addEventListener('DOMContentLoaded', callback) 7 } 8} 9 10// Get value of localStorage and remove it if expery time > 11const getLS = (keyName) => { 12 const data = localStorage.getItem(keyName); 13 if (!data) { // if no value exists associated with the key, return null 14 return null; 15 } 16 17 const item = JSON.parse(data); 18 19 // If TTL has expired, remove the item from localStorage and return null 20 if (Date.now() > item.ttl) { 21 localStorage.removeItem(keyName); 22 return null; 23 } 24 25 // return data if not expired 26 return item.value; 27} 28 29// Set localeStorage value and his expiry time 30const setLS = (keyName, keyValue, ttl) => { 31 const data = { 32 value: keyValue, // store the value within this object 33 ttl: Date.now() + (ttl * 1000), // store the TTL (time to live) 34 } 35 36 // store data in LocalStorage 37 localStorage.setItem(keyName, JSON.stringify(data)); 38} 39 40 41// Check on cookies 42ready(() => { 43 44 const $window = document.getElementById('informationWindow') 45 46 if ($window) { 47 //let $closeBTN = $window.querySelector('.close') 48 let infowindowClose = $window.getElementsByClassName('infowindow__close'); 49 let timestamp = $window.getAttribute('data-timestamp') 50 51 let informationWindow = getLS('informationWindow'); 52 let URLParams = new URLSearchParams(window.location.search) 53 54 let body = document.body 55 let infoBanner = document.querySelector('.js-infowindow_banner') 56 57 if (URLParams.get('preview') === 'informationWindow') { 58 $window.classList.remove('hide') 59 localStorage.removeItem('informationWindow') 60 61 if (infoBanner) { 62 body.classList.add('js-info-window-banner-active') 63 } 64 } 65 66 if (!informationWindow || informationWindow !== timestamp) { 67 $window.classList.remove('hide') 68 setLS('informationWindow', timestamp, 2630000); 69 70 if (infoBanner) { 71 body.classList.add('js-info-window-banner-active') 72 } 73 } 74 75 for (i = 0; i < infowindowClose.length; i++) { 76 infowindowClose[i].addEventListener('click', function () { 77 $window.classList.add('hideX'); 78 79 if (infoBanner) { 80 body.classList.remove('js-info-window-banner-active') 81 } 82 }, false); 83 } 84 85 if (infoBanner) { 86 let infoBannerInfos = infoBanner.querySelector('.js-infowindow_banner_infos') 87 body.style.setProperty('--infowindow-banner-height', infoBanner.offsetHeight + "px"); 88 body.style.setProperty('--infowindow-banner-infos-height', infoBannerInfos.offsetHeight + "px"); 89 } 90 91 } 92})
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.