PageSourceSearch

https://www.fiserv.com/etc.clientlibs/fiserv-com/clientlibs/predic…-bb314a16aafda447b037e1c98ccc50ec-lc.min.js

js fiserv.com collected 2026-10-01 07:46:57 UTC 4,722 bytes, 131 lines download raw bytes

1function predictiveSearch(searchInput, actionUrl) {
2  let currentFocus;
3  actionUrl = actionUrl.replace(/#/g, '');
4
5  searchInput.addEventListener('input', async function(e) {
6    let predictiveResultList,
7      predictiveSearchResultElements,
8      predictiveSearchResultArr = [],
9      predictiveSearchValue = this.value;
10
11    closeAllLists(searchInput);
12
13    if (!predictiveSearchValue) {
14      return false;
15    }
16
17    currentFocus = -1;
18
19    let searchApiUrl =
20      'https://search.onpointsuite.ca/api/search-suggest/?search_engine=a99f868b-9344-4287-9153-5409a3013f51&url_filter=&url_exclude_filter=&callback=loadSuggestions&q=';
21    searchApiUrl += this.value.toLowerCase();
22
23    if (this.value.toLowerCase().length >= 3) {
24      predictiveResultList = document.createElement('div');
25      predictiveResultList.setAttribute('id', this.id + '-predictive-result__list');
26      predictiveResultList.setAttribute('class', 'predictive-result__items');
27      let searchResultElement = this.parentNode;
28
29      predictiveSearchResultArr = await predictiveAPIResultFetch(searchApiUrl);
30
31      predictiveSearchResultArr?.map(suggestion => {
32        if (suggestion.substr(0, predictiveSearchValue.length).toUpperCase() == predictiveSearchValue.toUpperCase()) {
33          $('.predictive-result__items').remove();
34          searchResultElement.appendChild(predictiveResultList);
35          predictiveSearchResultElements = document.createElement('div');
36          predictiveSearchResultElements.innerHTML = `<strong>${suggestion.substr(0, predictiveSearchValue.length)}</strong>${suggestion.substr(predictiveSearchValue.length)}`;
37          predictiveSearchResultElements.innerHTML += `<input type="hidden" value="${suggestion}" />`;
38          predictiveSearchResultElements.addEventListener('click', function(e) {
39            searchInput.value = this.getElementsByTagName('input')[0].value;
40            currentFocus = -1;
41            closeAllLists(searchInput);
42            getSearchResults(actionUrl, searchInput.value);
43          });
44          predictiveResultList.appendChild(predictiveSearchResultElements);
45        }
46      });
47    }
48  });
49
50  searchInput.addEventListener('keydown', function(event) {
51    let autoCompleteListElement = document.getElementById(`${this.id}-predictive-result__list`);
52    if (autoCompleteListElement) autoCompleteListElement = autoCompleteListElement.getElementsByTagName('div');
53    if (event.keyCode === 40) {
54      //Down Arrow Key
55      currentFocus++;
56      addActive(autoCompleteListElement);
57    } else if (event.keyCode === 38) {
58      //Up Arrow Key
59      currentFocus--;
60      addActive(autoCompleteListElement);
61    } else if (event.keyCode === 13) {
62      //Enter Key
63      if (currentFocus > -1) {
64        event.preventDefault();
65        if (autoCompleteListElement) {
66          // autoCompleteListElement[currentFocus].click();
67          let searchResultVal = autoCompleteListElement[currentFocus].getElementsByTagName('input')[0].value;
68
69          searchInput.value = searchResultVal;
70
71          closeAllLists(searchResultVal);
72          searchInput.focus();
73        } else {
74          getSearchResults(actionUrl, searchInput.value);
75        }
76      }
77    }
78  });
79
80  document.addEventListener('click', function(e) {
81    closeAllLists(e.target, searchInput);
82  });
83
84  function addActive(elementsArr) {
85    if (!elementsArr) return false;
86  
87    removeActive(elementsArr);
88    if (currentFocus >= elementsArr.length) currentFocus = 0;
89    if (currentFocus < 0) currentFocus = elementsArr.length - 1;
90
91    elementsArr[currentFocus].classList.add('predictive-result__active');
92  }
93  
94  function removeActive(elementsArr) {
95    for (var i = 0; i < elementsArr.length; i++) {
96      elementsArr[i].classList.remove('predictive-result__active');
97    }
98  }
99  
100  function closeAllLists(element, searchInput) {
101    let autoCompleteItems = document.getElementsByClassName('predictive-result__items');
102    for (let i = 0; i < autoCompleteItems.length; i++) {
103      if (element != autoCompleteItems[i] && element != searchInput) {
104        autoCompleteItems[i].parentNode.removeChild(autoCompleteItems[i]);
105      }
106    }
107  }
108}
109
110async function predictiveAPIResultFetch(ApiURL) {
111  let fetchedJSONResponse = [];
112
113  await $.ajax({
114    dataType: 'jsonp',
115    url: encodeURI(ApiURL),
116    success: function(data) {
117      fetchedJSONResponse = data.suggestions.map(suggestion => {
118        return suggestion.term;
119      });
120    },
121  });
122
123  return fetchedJSONResponse.sort();
124}
125
126function getSearchResults(actionUrl, searchTerm) {
127  var locationStr = actionUrl.split('?')[0],
128  newLocation = [locationStr, '?q=', searchTerm, '&f_filter=all&start=0&rows=10'].join('');
129
130  location.replace(newLocation);
131}

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.