|
205 | 205 | searchResultDataset.appendChild(createSearchResultItem(doc, sectionTitle, item, highlightingResult, query)) |
206 | 206 | }) |
207 | 207 | } |
208 | | - |
| 208 | + |
209 | 209 |
|
210 | 210 | function createSearchResultItem (doc, sectionTitle, item, highlightingResult, query) { |
211 | 211 | console.log("createSearchResultItem"); |
|
225 | 225 | const documentHit = document.createElement('div') |
226 | 226 | documentHit.classList.add('search-result-document-hit') |
227 | 227 | const documentHitLink = document.createElement('a') |
228 | | - |
| 228 | + |
229 | 229 | //documentHitLink.href = siteRootPath + doc.url + (sectionTitle ? '#' + sectionTitle.hash : '') |
230 | 230 | //set query param to search query |
231 | 231 | let url = new URL(siteRootPath + doc.url, window.location.href) |
|
234 | 234 | } |
235 | 235 | url.searchParams.set('q', query) |
236 | 236 | documentHitLink.href = url.href |
237 | | - |
| 237 | + |
238 | 238 | documentHit.appendChild(documentHitLink) |
239 | 239 | if (highlightingResult.sectionTitleNodes.length > 0) { |
240 | 240 | const documentSectionTitle = document.createElement('div') |
|
275 | 275 | url.searchParams.set('q', node.text) |
276 | 276 | documentHitLink.href = url.href |
277 | 277 | } |
278 | | - |
| 278 | + |
279 | 279 | documentHitLink.appendChild(element) |
280 | 280 | }) |
281 | 281 | const searchResultItem = document.createElement('div') |
|
309 | 309 | const componentFilter = componentFilterInput && componentFilterInput.checked && componentFilterInput.dataset.componentFilter; |
310 | 310 | const versionFilter = versionFilterInput && versionFilterInput.checked && versionFilterInput.dataset.versionFilter; |
311 | 311 | if (componentFilter || versionFilter) { |
312 | | - |
| 312 | + |
313 | 313 | return result.filter((item) => { |
314 | 314 | const ids = item.ref.split('-'); |
315 | 315 | const docId = ids[0]; |
|
453 | 453 | } |
454 | 454 |
|
455 | 455 |
|
456 | | - |
| 456 | + |
457 | 457 |
|
458 | 458 | function highliteMatches () { |
459 | 459 | const params = new URLSearchParams(window.location.search.slice(1)) |
460 | | - |
| 460 | + |
461 | 461 | const query = params.get('q') |
462 | 462 | if (query == undefined || query == null) return |
463 | 463 | searchWord(query) |
464 | 464 | } |
465 | | - |
| 465 | + |
466 | 466 | function searchWord(searchText) { |
467 | 467 | let cont = document.querySelector("article"); |
468 | 468 | let pattern = new RegExp("(" + searchText + ")", "gi"); |
|
473 | 473 | hrefs.push(links[i].href) |
474 | 474 | } |
475 | 475 | cont.innerHTML = cont.innerHTML.replace(pattern, "<mark>$1</mark>"); |
476 | | - |
| 476 | + |
477 | 477 | let new_links = document.querySelectorAll(".xref"); |
478 | 478 | for (var i = 0; i < links.length; i++) { |
479 | 479 | new_links[i].href = hrefs[i] |
480 | 480 | } |
481 | | - |
| 481 | + |
482 | 482 | let scrollPos = document.querySelector("mark").offsetTop - 200; |
483 | 483 | window.scroll({ top: scrollPos, behavior: "auto" }); |
484 | 484 | } |
|
509 | 509 | componentFilterInput.addEventListener('change', (e) => toggleFilter(e, index)); |
510 | 510 | } |
511 | 511 | document.documentElement.addEventListener('click', clearSearchResults); |
512 | | - |
| 512 | + |
513 | 513 | highliteMatches() |
514 | | - |
515 | | - |
| 514 | + |
| 515 | + |
516 | 516 | } |
517 | 517 |
|
518 | 518 | // disable the search input until the index is loaded |
|
0 commit comments