1var base_url; 2 3if(/staging\.mordorintelligence/gmi.test(window.location.href)) 4base_url = "https://staging.mordorintelligence.com" 5 6else if(/mordorlabs/gmi.test(window.location.href)) 7base_url = "https://www.mordorlabs.com"; 8 9else if(/mordorintelligence/gmi.test(window.location.href)) 10base_url = "https://www.mordorintelligence.com"; 11 12else if (/mordorintelligence\.online/gmi.test(window.location.href) || /localhost/gmi.test(window.location.href)) 13base_url = "http://localhost:8080"; 14 15const spinner = document.getElementById("spinner"); 16let abortController = new AbortController(); 17 18function searchReports(search_query){ 19 const myNode = document.getElementsByClassName("search-results-wrapper"); 20 document.getElementsByClassName('opacity-toggle')[0].style.opacity = 0.3; 21 myNode.innerHTML = ""; 22 spinner.removeAttribute('hidden'); 23 abortController.abort(); // Cancel the previous request 24 abortController = new AbortController(); 25 if(search_query){ 26 fetch(`${base_url}/api/reports/search?q=${search_query}`,{ signal: abortController.signal }) 27 .then(function (res) { 28 if(!res.ok) throw new Error(res.status); 29 else return res.json(); 30 }).then(function(res) { 31 spinner.setAttribute('hidden', ''); 32 document.getElementsByClassName('opacity-toggle')[0].style.opacity = 1; 33 res.map((item)=>{ 34 const div = document.createElement("div"); 35 div.classList.add("search-report-title"); 36 const link = document.createElement('a'); 37 div.style.width = "100%"; 38 div.style.height = "auto"; 39 div.style.borderLeft = "1px solid rgb(230, 232, 243)"; 40 div.style.borderRight = "1px solid rgb(230, 232, 243)"; 41 div.style.borderBottom = "1px solid rgb(230, 232, 243)"; 42 link.style.color = "rgb(90, 94, 112)"; 43 div.style.display = "block"; 44 div.style.textDecoration = "none"; 45 div.style.padding= "10px 20px"; 46 div.style.fontFamily= "regular_medium"; 47 div.style.transition= "all 0.2s ease-out 0s"; 48 link.href = `/industry-reports/${item.slug}`; 49 link.target='_blank'; 50 link.innerText = item.title; 51 div.appendChild(link); 52 document.getElementsByClassName("search-results-wrapper")[0].appendChild(div); 53 }) 54 }) 55 .catch(error => { 56 spinner.setAttribute('hidden', ''); 57 document.getElementsByClassName('opacity-toggle')[0].style.opacity = 1; 58 if (error.name === 'AbortError') { 59 return; // Continuation logic has already been skipped, so return normally 60 } else { 61 var removeSearchTitleDivs = document.getElementsByClassName("search-report-title"); 62 for (var i = removeSearchTitleDivs.length-1; i >= 0; i--) { 63 removeSearchTitleDivs[i].remove(); 64 } 65 var removeDataNotFounddivs = document.getElementsByClassName("data-not-found"); 66 for (var i = removeDataNotFounddivs.length-1; i >= 0; i--) { 67 removeDataNotFounddivs[i].remove(); 68 } 69 if(search_query){ 70 const div = document.createElement("div"); 71 div.classList.add("data-not-found"); 72 div.style.textAlign = "center"; 73 div.style.padding = "10px 20px"; 74 div.style.border = '1px solid rgb(230, 232, 243)'; 75 div.innerHTML += 'DATA NOT FOUND'; 76 document.getElementsByClassName("search-results-wrapper")[0].appendChild(div); 77 } 78 } 79 }) 80} 81} 82 83// const searchInput = document.getElementById("search-input"); 84// const searchIcon = document.getElementById("search-icon"); 85// const searchResultItems = document.querySelector(".search-result-items"); 86 87// let isSearchActive = false; 88 89// // Define a debounce function 90// function debounce(func, delay) { 91// let timer; 92// return function (...args) { 93// clearTimeout(timer); 94// timer = setTimeout(() => { 95// func.apply(this, args); 96// }, delay); 97// }; 98// } 99 100// if (searchIcon) { 101// searchIcon.addEventListener("click", function () { 102// if (isSearchActive) { 103// searchInput.value = ""; 104// searchResultItems.innerHTML = ""; 105// searchIcon.classList.remove("fa-times"); 106// searchIcon.classList.add("fa-search"); 107// isSearchActive = false; 108// } else { 109// searchInput.value = ""; 110// searchResultItems.innerHTML = ""; 111// searchIcon.classList.remove("fa-search"); 112// searchIcon.classList.add("fa-times"); 113// isSearchActive = true; 114// } 115// }); 116// } 117 118// if (searchInput) { 119// searchInput.addEventListener( 120// "input", 121// debounce(function (event) { 122// const searchQuery = event.target.value.trim(); 123// if (searchQuery.length > 0) { 124// searchIcon.classList.remove("fa-search"); 125// searchIcon.classList.add("fa-times"); 126// isSearchActive = true; 127// } else { 128// searchResultItems.innerHTML = ""; 129// searchIcon.classList.remove("fa-times"); 130// searchIcon.classList.add("fa-search"); 131// isSearchActive = false; 132// } 133// searchInputReports(searchQuery);
134// }, 800) // Adjust the delay as needed 135// ); 136// } 137 138// function searchInputReports(searchQuery) { 139// const spinner = document.getElementById("input-spinner"); 140// searchResultItems.innerHTML = ""; 141// if (searchQuery) { 142// spinner.removeAttribute("hidden"); 143// abortController.abort(); // Cancel the previous request 144// abortController = new AbortController(); 145// fetch(`${base_url}/api/reports/search?q=${searchQuery}`, { signal: abortController.signal }) 146// .then(function (res) { 147// if (!res.ok) throw new Error(res.status); 148// else return res.json(); 149// }) 150// .then(function (res) { 151// spinner.setAttribute("hidden", ""); 152// res.map((item) => { 153// const div = document.createElement("div"); 154// div.classList.add("search-report-title"); 155// const link = document.createElement('a'); 156// div.style.width = "100%"; 157// div.style.height = "auto"; 158// div.style.borderLeft = "1px solid rgb(230, 232, 243)"; 159// div.style.borderRight = "1px solid rgb(230, 232, 243)"; 160// div.style.borderBottom = "1px solid rgb(230, 232, 243)"; 161// link.style.color = "rgb(90, 94, 112)"; 162// div.style.display = "block"; 163// div.style.textDecoration = "none"; 164// div.style.padding= "10px 20px"; 165// div.style.fontFamily= "regular_medium"; 166// div.style.transition= "all 0.2s ease-out 0s"; 167// link.href = `/industry-reports/${item.slug}`; 168// link.target='_blank'; 169// link.innerText = item.title; 170// div.appendChild(link); 171// searchResultItems.appendChild(div); 172// }); 173// }) 174// .catch((error) => { 175// spinner.setAttribute("hidden", ""); 176// if (error.name === "AbortError") { 177// return; 178// } else { 179// const div = document.createElement("div"); 180// div.classList.add("no-data-found"); 181// div.style.textAlign = "center"; 182// div.style.padding = "8px 20px"; 183// div.innerHTML += 'DATA NOT FOUND'; 184// searchResultItems.appendChild(div); 185// } 186// }); 187// } 188// } 189 190 191 192
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.