1var autocomplete=angular.module("wpdsearchAutocomplete",[]); 2autocomplete.service("wpdsearchAutoComplete",["$loading","$requester","$q",function($loading,$requester,$q){var _json=$requester({"autoComplete":"SearchFront.autoComplete","promotedResults":"SearchFront.promotedSearchResultsAutoComplete"}),_loader={load:function(){},clear:function(){}},_searchTerm=null,_successCb=[],_errorCb=angular.noop,_timeout=null;_json.setLoader(_loader);var callRefresh=function(){var deferred=$q.defer();_json.autoComplete({searchTerm:_searchTerm},function(response){deferred.resolve({data:response})}.bind(this), 3deferred.reject);return deferred.promise};var promotedResultsSearch=function(){var deferred=$q.defer();_json.promotedResults({searchTerm:_searchTerm},function(response){deferred.resolve({success:true,data:response})}.bind(this),deferred.reject);return deferred.promise};this.refresh=function(){$q.all({searchData:callRefresh(),promotedData:promotedResultsSearch()}).then(beforeSuccess).catch(_errorCb)};this.setSearchTerm=function(searchTerm){_searchTerm=searchTerm;if(_timeout!==null)clearTimeout(_timeout); 4_timeout=setTimeout(this.refresh,250)};this.onSuccess=function(successCallback){_successCb.push(successCallback);return this};this.onFailure=function(errorCallback){_errorCb=errorCallback;return this};var beforeSuccess=function(searchResult){var result={};if(searchResult&&searchResult.promotedData.data.promotedResults){var promotedResults=JSON.parse(searchResult.promotedData.data.promotedResults);var uniquePromotedResults=[];if(Array.isArray(promotedResults)&&Array.isArray(searchResult.searchData.data.options)){promotedResults.forEach(function(promotedResult){if(!doesArrayContainPromotedResult(uniquePromotedResults, 5promotedResult))uniquePromotedResults.push(promotedResult)});uniquePromotedResults.forEach(function(pr){pr.text=pr.title});result.promotedData=uniquePromotedResults}}if(searchResult&&searchResult.searchData.data.options)result.searchData=searchResult.searchData.data.options;_successCb.forEach(function(fn){fn(result)})};function doesArrayContainPromotedResult(uniqueArray,item){return uniqueArray.filter(function(uniqueItem){return uniqueItem.id===item.id&&uniqueItem.className===item.className}).length> 60}}]);
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.