|
1 | | -(function (global, doc) { |
| 1 | +(function(global, doc) { |
2 | 2 | let match; |
3 | 3 | const search_query = (match = doc.location.search.match(/sq=(.*?)(&|$)/)) ? match[1] : ''; |
4 | 4 | const parsed_search_query = decodeURI(search_query.replaceAll('+', ' ')); |
|
16 | 16 | initialUiState: { |
17 | 17 | ezplatform: { |
18 | 18 | query: parsed_search_query, |
19 | | - refinementList: {version: [version]}, |
| 19 | + refinementList: { version: [version] }, |
20 | 20 | page: parsed_search_page, |
21 | 21 | }, |
22 | 22 | }, |
|
35 | 35 | const searchInputElements = document.getElementsByClassName('ais-SearchBox-input'); |
36 | 36 | const text = searchInputElements[0].value.trim(); |
37 | 37 | const selectedPaginationItemElements = doc.getElementsByClassName('ais-Pagination-item--selected'); |
38 | | - const page = selectedPaginationItemElements.length ? parseInt(selectedPaginationItemElements[0].innerText) : 1 |
| 38 | + const page = selectedPaginationItemElements.length ? parseInt(selectedPaginationItemElements[0].innerText) : 1; |
39 | 39 | const url = new URL(window.location); |
40 | 40 | url.searchParams.set('sq', text); |
41 | 41 | url.searchParams.set('p', page); |
|
45 | 45 | let idleTimer; |
46 | 46 | const startIdleTimer = (url) => { |
47 | 47 | stopIdleTimer(); |
48 | | - idleTimer = window.setTimeout(()=>{ |
| 48 | + idleTimer = window.setTimeout(() => { |
49 | 49 | window.history.pushState({}, '', url); |
50 | 50 | }, 1500); |
51 | 51 | }; |
52 | 52 | const stopIdleTimer = () => { |
53 | 53 | window.clearTimeout(idleTimer); |
54 | | - } |
| 54 | + }; |
55 | 55 |
|
56 | | - doc.getElementById('searchbox').addEventListener('keyup', function (event) { |
| 56 | + doc.getElementById('searchbox').addEventListener('keyup', function(event) { |
57 | 57 | const url = getNextSearchURL(); |
58 | 58 | if (url.searchParams.get('sq') != (new URL(window.location)).searchParams.get('sq')) { |
59 | 59 | url.searchParams.set('p', 1); |
60 | 60 | startIdleTimer(url); |
61 | 61 | } |
62 | | - }) |
| 62 | + }); |
63 | 63 |
|
64 | | - doc.getElementById('pagination').addEventListener('click', function (event) { |
| 64 | + doc.getElementById('pagination').addEventListener('click', function(event) { |
65 | 65 | stopIdleTimer(); |
66 | 66 | const url = getNextSearchURL(); |
67 | 67 | window.history.pushState({}, '', url); |
68 | | - }) |
| 68 | + }); |
69 | 69 |
|
70 | 70 | window.onpopstate = (event) => { |
71 | 71 | window.location.reload(); |
|
96 | 96 |
|
97 | 97 | const headerHTML = `<h3 class="instantsearch__entry-header"> |
98 | 98 | ${instantsearch.highlight({ |
99 | | - attribute: `hierarchy.${entryNameKey}`, |
100 | | - highlightedTagName: 'mark', |
101 | | - hit: hit |
102 | | - })} |
| 99 | + attribute: `hierarchy.${entryNameKey}`, |
| 100 | + highlightedTagName: 'mark', |
| 101 | + hit: hit, |
| 102 | + })} |
103 | 103 | </h3>`; |
104 | 104 |
|
105 | 105 | let breadcrumbsHTML = ''; |
|
108 | 108 | if (hit.content && hit._highlightResult.content.matchedWords.length && (!hit._highlightResult.content.fullyHighlighted || 1 < hit._highlightResult.content.matchedWords.length)) { |
109 | 109 | contentHTML = `<div class="instantsearch__entry-content"> |
110 | 110 | ${instantsearch.highlight({ |
111 | | - attribute: `content`, |
112 | | - highlightedTagName: 'mark', |
113 | | - hit: hit |
114 | | - }).replaceAll('&', '&')} |
| 111 | + attribute: `content`, |
| 112 | + highlightedTagName: 'mark', |
| 113 | + hit: hit, |
| 114 | + }).replaceAll('&', '&')} |
115 | 115 | </div>`; |
116 | 116 | } |
117 | 117 |
|
118 | 118 | breadcrumbsKeys?.forEach((breadcrumbKey) => { |
119 | 119 | breadcrumbsHTML += `<span class="instantsearch__entry-breadcrumbs-item"> |
120 | 120 | ${instantsearch.highlight({ |
121 | | - attribute: `hierarchy.${breadcrumbKey}`, |
122 | | - highlightedTagName: 'mark', |
123 | | - hit: hit |
124 | | - })} |
125 | | - </span>` |
| 121 | + attribute: `hierarchy.${breadcrumbKey}`, |
| 122 | + highlightedTagName: 'mark', |
| 123 | + hit: hit, |
| 124 | + })} |
| 125 | + </span>`; |
126 | 126 | }); |
127 | 127 |
|
128 | 128 | return resultHTML = `<a class="instantsearch__entry" href="${hit.url}"> |
|
0 commit comments