1//Aux variables 2var auxNumberShow = 0; 3var auxTotalOfResults = 0; 4var auxLastQuery = ""; 5var searchQueryTextAux = ""; 6var textAux = ""; 7var facetcreated = false; 8var vueFacets = ""; 9var facettemplate = ""; 10 11//Function to Fill the Forms with the Results 12function FillSearchSite(comingfromFacet, newQuery, comingfromLoadButton, comingFromSearch, comingFromPageLoad) { 13 let auxNumberOfResults; 14 15 //Remove the Alert Msg from Site Search Page 16 $("#divMsgAlertFindSearchSite").css("display", "none"); 17 $(".js-module-search").blur(); 18 19 if (comingFromSearch && facetcreated) { 20 let getAllDiv = $("#all")[0]; 21 22 if (getAllDiv) { 23 CallSearchFacet(getAllDiv, true); 24 } 25 } 26 27 if (!comingfromFacet && !comingFromSearch) 28 auxNumberOfResults = totalNumberToShow + auxNumberShow; 29 else { 30 auxNumberOfResults = totalNumberToShow; 31 auxNumberShow = totalNumberToShow; 32 } 33 34 CreateQueryFindSite(comingfromLoadButton, comingFromSearch, newQuery); 35 36 //Creating the searchQuery 37 var searchQuery = { Query: auxQuery, Page: 1, NumberOfResults: auxNumberOfResults, FacetField: "_templatedisplayname", Sort: "item_name_s asc", Keyword: searchQueryTextAux, Source: "sitesearch" }; 38 39 //If coming from Facet, we do not want to Load More Results 40 if (!comingfromFacet && !comingFromSearch) { 41 auxNumberShow = auxNumberShow + totalNumberToShow; 42 } 43 44 //Get the template (markup) 45 var template = $('#results').html(); 46 //name of the Div that we want to populate 47 var resultDivName = "results"; 48 //name of the script tag, necessary to JsRender work 49 var theTmpl = "theTmpl"; 50 51 if ($('#' + theTmpl).children().length > 0) { 52 template = $('#' + theTmpl).html(); 53 } 54 55 //Call the Api by Rendering.js 56 Rendering(searchQuery, template, resultDivName, theTmpl).then(function (result) { 57 var results = JSON.parse(result); 58 auxTotalOfResults = results.TotalNumberOfResults; 59 60 //Create the Message Result 61 let resultTextMessage; 62 if (!comingfromFacet) { 63 resultTextMessage = FillResultMessage(auxNumberShow, auxTotalOfResults, $("#searchText").val()); 64 } 65 else { 66 resultTextMessage = FillResultMessage(10, auxTotalOfResults, $("#searchText").val()); 67 } 68 69 $('#resultFoundText').html(resultTextMessage); 70 $('#resultFoundText').css("display", ""); 71 72 if (auxTotalOfResults < auxNumberShow) { 73 $("#loadMoreResult").css("display", "none"); 74 } 75 76 if (comingFromSearch || !facetcreated) { 77 CreateFacetSiteSearch(results); 78 } 79 80 //scroll down 81 if (comingFromSearch) { 82 if ($("#resultFoundText").length) { 83 $('html, body').animate({ scrollTop: $('#resultFoundText').offset().top - 50 }, 'slow'); 84 } 85 86 } 87 88 if (comingFromPageLoad) { 89 const urlParams = new URLSearchParams(window.location.search); 90 const myParamFacets = urlParams.get('facets'); 91 FillFacetByQueryParameter(myParamFacets); 92 } 93 94 dataLayer.push({ event: "siteSearchResultLoaded" }); 95 }); 96 setTimeout(function () { 97 $('#results').css("display", ""); 98 $('#facets').css("display", ""); 99 }, 300); 100} 101 102function CreateQueryFindSite(comingfromLoadButton, comingFromSearch, newQuery) { 103 //default query 104 //we have to clean all query, and add again 105 var createAllParameter = true; 106 107 processAjaxDataSite($("#searchText").val(), true, "q"); 108 109 if ($("#searchText").val()) { 110 createAllParameter = false; 111 processAjaxDataSite($("#searchText").val(), false, "q"); 112 } 113 114 //If the click is coming from Load Button, we need to use the last used Query. 115 if (comingfromLoadButton) { 116 auxQuery = auxLastQuery; 117 } 118 119 //If the click is coming from Load Button, we need to use the last used Query. 120 else if (comingFromSearch) { 121 auxQuery = queryFindSite; 122 textAux = $("#searchText").val(); 123 searchQueryTextAux = textAux; 124 auxLastQuery = auxQuery; 125 } 126 //Query is coming from Facets 127 else if (typeof newQuery !== "undefined") { 128 auxQuery = newQuery; 129 auxLastQuery = auxQuery; 130 } 131 //Comming from facet but user clicked on ALL 132 else { 133 auxQuery = queryFindSite; 134 auxLastQuery = auxQuery; 135 } 136 137 if (createAllParameter) {
138 processAjaxDataSite(true, false, "all"); 139 } 140 else { 141 processAjaxDataSite(true, true, "all"); 142 } 143} 144 145function processAjaxDataSite(urlPath, clean, typeparameter) { 146 var fullURL = window.location.href; //get current address 147 var urlWithoutParams = fullURL.replace(window.location.search, "").replace("?", ""); //url without queryparameters 148 var queryParameters = new URLSearchParams(window.location.search); //get query parameters 149 150 if (clean) { 151 queryParameters.delete(typeparameter); 152 window.history.pushState("object or string", "", urlWithoutParams + "?" + queryParameters); 153 } 154 else { 155 queryParameters.set(typeparameter, urlPath); 156 window.history.pushState("object or string", "", urlWithoutParams + "?" + queryParameters); 157 } 158} 159 160function CreateFacetSiteSearch(resultfacets) { 161 var facetdiv = $("#searchfacetcontainer"); 162 facetdiv.css("display", "none"); 163 if (facettemplate) { 164 if (facetdiv.length > 0) { 165 facetdiv[0].innerHTML = facettemplate; 166 } 167 } 168 else { 169 if (facetdiv.length > 0) { 170 facettemplate = facetdiv[0].innerHTML; 171 } 172 } 173 174 if (resultfacets.TotalNumberOfResults > 0) { 175 vueFacets = new Vue({ 176 el: '#facets', 177 178 data: function () { 179 return { 180 facets: resultfacets.Facets, 181 totalresults: resultfacets.TotalNumberOfResults 182 }; 183 } 184 }); 185 facetdiv.css("display", ""); 186 } 187 188 facetcreated = true; 189} 190 191//Function that comes from common links 192function fromCommonLinksFindSiteSearch(textclicked) { 193 194 textclickedaux = textclicked[0].text; 195 196 $("#searchText").val(textclickedaux); 197 198 FillSearchSite(false, false, false, true); 199 200}
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.