-
Notifications
You must be signed in to change notification settings - Fork 507
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
8e125f5
commit bdf9ec5
Showing
4 changed files
with
349 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,195 @@ | ||
--- | ||
layout: table_wrappers | ||
--- | ||
|
||
<!DOCTYPE html> | ||
|
||
<html lang="{{ site.lang | default: 'en-US' }}"> | ||
{% include head.html %} | ||
<body> | ||
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;"> | ||
<symbol id="svg-arrow-right" viewBox="0 0 24 24"> | ||
<title>Expand</title> | ||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-right"> | ||
<polyline points="9 18 15 12 9 6"></polyline> | ||
</svg> | ||
</symbol> | ||
</svg> | ||
|
||
{% include header.html %} | ||
|
||
<div class="main-content-wrap-home"> | ||
<div id="main-content" class="main-content" role="main"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Results Page Head from layout</title> | ||
</head> | ||
<div class="search-page"> | ||
<aside class="search-page--sidebar"> | ||
<h2>Filter results</h2> | ||
<div class="version-selector-wrapper" id="version-panel"> | ||
<version-selector selected="{{ site.data.versions.current }}"></version-selector> | ||
</div> | ||
<form class="search-page--sidebar--category-filter"> | ||
<div class="search-page--sidebar--category-filter--checkbox"> | ||
<div> | ||
<input type="checkbox" id="categoryAll" name="categoryGroup" value="All" class="category-checkbox" checked> | ||
<label for="categoryAll">All</label> | ||
</div> | ||
<div class="search-page--sidebar--category-filter--checkbox-child"> | ||
<input type="checkbox" id="categoryDocumentation" name="categoryGroup" value="Documentation" class="category-checkbox"> | ||
<label for="categoryDocumentation">Documentation</label> | ||
</div> | ||
<div class="search-page--sidebar--category-filter--checkbox-child"> | ||
<input type="checkbox" id="categoryNews" name="categoryGroup" value="News" class="category-checkbox"> | ||
<label for="categoryNews">News</label> | ||
</div> | ||
</div> | ||
</form> | ||
</aside> | ||
<div class="search-page--results"> | ||
<div class="search-page--results--input"> | ||
<input type="text" class="search-page--results--input-box" id="searchPageInput" placeholder="Search for anything" aria-label="Search {{ site.title }}" autocomplete="off"> | ||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" class="search-page--results--input-icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-search"> | ||
<circle cx="11" cy="11" r="8"></circle> | ||
<line x1="21" y1="21" x2="16.65" y2="16.65"></line> | ||
</svg> | ||
</div> | ||
<main class="search-page--results--diplay"> | ||
<h1 class="search-page--results--diplay--header" id="searchPageResultsHeader"></h1> | ||
<div class="search-page--results--diplay--container" id="searchPageResultsContainer"> | ||
<!-- API results will be displayed here --> | ||
</div> | ||
</main> | ||
</div> | ||
</div> | ||
<a class="top-link" href="#top"> | ||
<svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg> | ||
</a> | ||
</div> | ||
</div> | ||
|
||
{% include footer.html %} | ||
<script src="{{ '/assets/js/search.js' | relative_url }}"></script> | ||
<script src="{{ '/assets/js/home-listener.js' | relative_url }}"></script> | ||
<script> | ||
function truncateSentence(sentence, maxLength) { | ||
if (sentence.length <= maxLength) return sentence; | ||
let words = sentence.split(' '); | ||
let truncatedSentence = ''; | ||
|
||
for (let i = 0; i < words.length; i++) { | ||
if (truncatedSentence.length + words[i].length + 1 > maxLength) { | ||
break; | ||
} | ||
if (i > 0) { | ||
truncatedSentence += ' '; | ||
} | ||
truncatedSentence += words[i]; | ||
} | ||
return truncatedSentence + (truncatedSentence.length < sentence.length ? '...' : ''); | ||
} | ||
</script> | ||
<script> | ||
const searchInput = document.getElementById('searchPageInput'); | ||
const checkboxes = document.querySelectorAll('.category-checkbox'); | ||
|
||
function getSelectedCategory() { | ||
const allCheckbox = document.getElementById('categoryAll'); | ||
if (allCheckbox.checked) { | ||
return "All"; | ||
} | ||
return document.querySelector('input[name="categoryGroup"]:checked'); | ||
} | ||
|
||
function triggerSearch(query) { | ||
const searchResultsHeader = document.getElementById('searchPageResultsHeader'); | ||
|
||
if (query) { | ||
trucatedQuery = truncateSentence(query, 20); | ||
if (getSelectedCategory() == null) { | ||
searchResultsHeader.textContent = 'Select the result type for your search.'; | ||
document.getElementById('searchPageResultsContainer').innerHTML = ''; | ||
return; | ||
} | ||
const selectedCategory = getSelectedCategory().value; | ||
const searchType = selectedCategory == ("Documentation") ? "docs" : selectedCategory == ("News") ? "proj" : "all"; | ||
const urlPath = window.location.pathname; | ||
const versionMatch = urlPath.match(/(\d+\.\d+)/); | ||
const docsVersion = versionMatch ? versionMatch[1] : "latest"; | ||
|
||
searchResultsHeader.textContent = `Search results for "${trucatedQuery}"`; | ||
doResultsPageSearch(query, searchType, docsVersion); | ||
} else { | ||
searchResultsHeader.textContent = 'Please input a Query for searching.'; | ||
document.getElementById('searchPageResultsContainer').innerHTML = ''; | ||
} | ||
} | ||
|
||
searchInput.addEventListener('keydown', function(event) { | ||
if (event.key === 'Enter') { | ||
event.preventDefault(); | ||
triggerSearch(searchInput.value.trim()); | ||
} | ||
}); | ||
|
||
</script> | ||
<script> | ||
document.addEventListener('DOMContentLoaded', function() { | ||
const categoryAll = document.getElementById('categoryAll'); | ||
const categoryDocumentation = document.getElementById('categoryDocumentation'); | ||
const categoryNews = document.getElementById('categoryNews'); | ||
const searchInput = document.getElementById('searchPageInput'); | ||
|
||
function updateAllCheckbox() { | ||
if (categoryDocumentation.checked && categoryNews.checked) { | ||
categoryAll.checked = true; | ||
} else { | ||
categoryAll.checked = false; | ||
} | ||
} | ||
|
||
function updateChildCheckboxes() { | ||
if (categoryAll.checked) { | ||
categoryDocumentation.checked = true; | ||
categoryNews.checked = true; | ||
} else { | ||
categoryDocumentation.checked = false; | ||
categoryNews.checked = false; | ||
} | ||
} | ||
|
||
categoryAll.addEventListener('change', () => { | ||
updateChildCheckboxes(); | ||
triggerSearch(searchInput.value.trim()); | ||
}); | ||
categoryDocumentation.addEventListener('change', () => { | ||
updateAllCheckbox(); | ||
triggerSearch(searchInput.value.trim()); | ||
}); | ||
categoryNews.addEventListener('change', () => { | ||
updateAllCheckbox(); | ||
triggerSearch(searchInput.value.trim()); | ||
}); | ||
}); | ||
</script> | ||
<script> | ||
document.addEventListener('DOMContentLoaded', () => { | ||
const searchInput = document.getElementById('searchPageInput'); | ||
|
||
const getQueryParam = (param) => { | ||
const urlParams = new URLSearchParams(window.location.search); | ||
return urlParams.get(param); | ||
}; | ||
|
||
const searchQuery = getQueryParam('q'); | ||
|
||
if (searchQuery) { | ||
searchInput.value = decodeURIComponent(searchQuery); | ||
triggerSearch(searchInput.value.trim()); | ||
} | ||
}); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
layout: search_layout | ||
title: OpenSearch Documentation Search Results Page | ||
nav_order: 1 | ||
has_children: false | ||
nav_exclude: true | ||
permalink: /search.html | ||
--- | ||
|
||
{% include banner.html %} | ||
|
||
{% include cards.html %} |