1function elasticSearch() { 2 const url = "/bin/astra/search"; 3 const pagePath = document.querySelector('.pagePath')?.value; 4 5 if(typeof pagePath !== 'undefined') { 6 const headers = new Headers(); 7 headers.append("pagePath", pagePath); 8 9 fetch(url, { 10 method: "GET", 11 headers: headers, 12 }) 13 .then(response => response.json()) // Parse the response as JSON 14 .then(responseObj => { 15 if (responseObj && Object.keys(responseObj).length > 0) { 16 for (const [key, value] of Object.entries(responseObj)) { 17 sessionStorage.setItem(key, value); 18 } 19 } 20 }) 21 .catch(error => { 22 console.error("There was a problem with the fetch operation from elastic api:", error); 23 }); 24 } 25} 26 27function initializeSearch() { 28 const components = document.querySelectorAll('.elasticsearch'); 29 elasticSearch(); 30 31 components.forEach(component => { 32 const searchIcon = component.querySelector('.search-icon'); 33 const overlay = component.querySelector('.elastic-search-overlay'); 34 const searchInput = component.querySelector('.input-medium.search-query'); 35 const closeBtn = component.querySelector('.elastic-search-close'); 36 37 if (!searchIcon || component.dataset.elasticSearchInit === 'true') { 38 return; 39 } 40 component.dataset.elasticSearchInit = 'true'; 41 42 function openOverlay() { 43 if (!overlay) { 44 return; 45 } 46 overlay.style.display = 'block'; 47 overlay.classList.add('elastic-modal-open'); 48 searchInput?.focus(); 49 } 50 51 function closeOverlay() { 52 if (!overlay) { 53 return; 54 } 55 overlay.style.display = 'none'; 56 overlay.classList.remove('elastic-modal-open'); 57 } 58 59 function toggleOverlay() { 60 if (overlay?.classList.contains('elastic-modal-open')) { 61 closeOverlay(); 62 } else { 63 openOverlay(); 64 } 65 } 66 searchIcon.addEventListener('click', e => { 67 e.preventDefault(); 68 toggleOverlay(); 69 }); 70 71 closeBtn?.addEventListener('click', closeOverlay); 72 73 document.addEventListener('keydown', e => { 74 if (e.key === 'Escape') { 75 closeOverlay(); 76 } 77 }); 78 }); 79} 80 81// Elastic Search Overlay Js. 82if (document.readyState === 'loading') { 83 document.addEventListener('DOMContentLoaded', initializeSearch); 84} else { 85 initializeSearch() 86}
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.