|
| 1 | +--- |
| 2 | +layout: table_wrappers |
| 3 | +--- |
| 4 | + |
| 5 | +<!DOCTYPE html> |
| 6 | + |
| 7 | +<html lang="{{ site.lang | default: 'en-US' }}"> |
| 8 | +{% include head.html %} |
| 9 | +<body> |
| 10 | +<svg xmlns="http://www.w3.org/2000/svg" style="display: none;"> |
| 11 | + <symbol id="svg-arrow-right" viewBox="0 0 24 24"> |
| 12 | + <title>Expand</title> |
| 13 | + <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"> |
| 14 | + <polyline points="9 18 15 12 9 6"></polyline> |
| 15 | + </svg> |
| 16 | + </symbol> |
| 17 | +</svg> |
| 18 | + |
| 19 | +{% include header.html %} |
| 20 | + |
| 21 | +<div class="main-content-wrap-home"> |
| 22 | + <div id="main-content" class="main-content" role="main"> |
| 23 | + <head> |
| 24 | + <meta charset="UTF-8"> |
| 25 | + <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 26 | + <title>Results Page Head from layout</title> |
| 27 | + </head> |
| 28 | + <div class="search-page"> |
| 29 | + <aside class="search-page--sidebar"> |
| 30 | + <h2>Filter results</h2> |
| 31 | + <div class="version-selector-wrapper" id="version-panel"> |
| 32 | + <version-selector selected="{{ site.data.versions.current }}"></version-selector> |
| 33 | + </div> |
| 34 | + <form class="search-page--sidebar--category-filter"> |
| 35 | + <div class="search-page--sidebar--category-filter--checkbox"> |
| 36 | + <div> |
| 37 | + <input type="checkbox" id="categoryAll" name="categoryGroup" value="All" class="category-checkbox" checked> |
| 38 | + <label for="categoryAll">All</label> |
| 39 | + </div> |
| 40 | + <div class="search-page--sidebar--category-filter--checkbox-child"> |
| 41 | + <input type="checkbox" id="categoryDocumentation" name="categoryGroup" value="Documentation" class="category-checkbox"> |
| 42 | + <label for="categoryDocumentation">Documentation</label> |
| 43 | + </div> |
| 44 | + <div class="search-page--sidebar--category-filter--checkbox-child"> |
| 45 | + <input type="checkbox" id="categoryNews" name="categoryGroup" value="News" class="category-checkbox"> |
| 46 | + <label for="categoryNews">News</label> |
| 47 | + </div> |
| 48 | + </div> |
| 49 | + </form> |
| 50 | + </aside> |
| 51 | + <div class="search-page--results"> |
| 52 | + <div class="search-page--results--input"> |
| 53 | + <input type="text" class="search-page--results--input-box" id="searchPageInput" placeholder="Search for anything" aria-label="Search {{ site.title }}" autocomplete="off"> |
| 54 | + <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"> |
| 55 | + <circle cx="11" cy="11" r="8"></circle> |
| 56 | + <line x1="21" y1="21" x2="16.65" y2="16.65"></line> |
| 57 | + </svg> |
| 58 | + </div> |
| 59 | + <main class="search-page--results--diplay"> |
| 60 | + <h1 class="search-page--results--diplay--header" id="searchPageResultsHeader"></h1> |
| 61 | + <div class="search-page--results--diplay--container" id="searchPageResultsContainer"> |
| 62 | + <!-- API results will be displayed here --> |
| 63 | + </div> |
| 64 | + </main> |
| 65 | + </div> |
| 66 | + </div> |
| 67 | + <a class="top-link" href="#top"> |
| 68 | + <svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg> |
| 69 | + </a> |
| 70 | + </div> |
| 71 | +</div> |
| 72 | + |
| 73 | +{% include footer.html %} |
| 74 | +<script src="{{ '/assets/js/search.js' | relative_url }}"></script> |
| 75 | +<script src="{{ '/assets/js/home-listener.js' | relative_url }}"></script> |
| 76 | +<script> |
| 77 | + function truncateSentence(sentence, maxLength) { |
| 78 | + if (sentence.length <= maxLength) return sentence; |
| 79 | + let words = sentence.split(' '); |
| 80 | + let truncatedSentence = ''; |
| 81 | + |
| 82 | + for (let i = 0; i < words.length; i++) { |
| 83 | + if (truncatedSentence.length + words[i].length + 1 > maxLength) { |
| 84 | + break; |
| 85 | + } |
| 86 | + if (i > 0) { |
| 87 | + truncatedSentence += ' '; |
| 88 | + } |
| 89 | + truncatedSentence += words[i]; |
| 90 | + } |
| 91 | + return truncatedSentence + (truncatedSentence.length < sentence.length ? '...' : ''); |
| 92 | +} |
| 93 | +</script> |
| 94 | +<script> |
| 95 | + const searchInput = document.getElementById('searchPageInput'); |
| 96 | + const checkboxes = document.querySelectorAll('.category-checkbox'); |
| 97 | + |
| 98 | + function getSelectedCategory() { |
| 99 | + const allCheckbox = document.getElementById('categoryAll'); |
| 100 | + if (allCheckbox.checked) { |
| 101 | + return "All"; |
| 102 | + } |
| 103 | + return document.querySelector('input[name="categoryGroup"]:checked'); |
| 104 | + } |
| 105 | + |
| 106 | + function triggerSearch(query) { |
| 107 | + const searchResultsHeader = document.getElementById('searchPageResultsHeader'); |
| 108 | + |
| 109 | + if (query) { |
| 110 | + trucatedQuery = truncateSentence(query, 20); |
| 111 | + if (getSelectedCategory() == null) { |
| 112 | + searchResultsHeader.textContent = 'Select the result type for your search.'; |
| 113 | + document.getElementById('searchPageResultsContainer').innerHTML = ''; |
| 114 | + return; |
| 115 | + } |
| 116 | + const selectedCategory = getSelectedCategory().value; |
| 117 | + const searchType = selectedCategory == ("Documentation") ? "docs" : selectedCategory == ("News") ? "proj" : "all"; |
| 118 | + const urlPath = window.location.pathname; |
| 119 | + const versionMatch = urlPath.match(/(\d+\.\d+)/); |
| 120 | + const docsVersion = versionMatch ? versionMatch[1] : "latest"; |
| 121 | + |
| 122 | + searchResultsHeader.textContent = `Search results for "${trucatedQuery}"`; |
| 123 | + doResultsPageSearch(query, searchType, docsVersion); |
| 124 | + } else { |
| 125 | + searchResultsHeader.textContent = 'Please input a Query for searching.'; |
| 126 | + document.getElementById('searchPageResultsContainer').innerHTML = ''; |
| 127 | + } |
| 128 | + } |
| 129 | + |
| 130 | + searchInput.addEventListener('keydown', function(event) { |
| 131 | + if (event.key === 'Enter') { |
| 132 | + event.preventDefault(); |
| 133 | + triggerSearch(searchInput.value.trim()); |
| 134 | + } |
| 135 | + }); |
| 136 | + |
| 137 | +</script> |
| 138 | +<script> |
| 139 | + document.addEventListener('DOMContentLoaded', function() { |
| 140 | + const categoryAll = document.getElementById('categoryAll'); |
| 141 | + const categoryDocumentation = document.getElementById('categoryDocumentation'); |
| 142 | + const categoryNews = document.getElementById('categoryNews'); |
| 143 | + const searchInput = document.getElementById('searchPageInput'); |
| 144 | + |
| 145 | + function updateAllCheckbox() { |
| 146 | + if (categoryDocumentation.checked && categoryNews.checked) { |
| 147 | + categoryAll.checked = true; |
| 148 | + } else { |
| 149 | + categoryAll.checked = false; |
| 150 | + } |
| 151 | + } |
| 152 | + |
| 153 | + function updateChildCheckboxes() { |
| 154 | + if (categoryAll.checked) { |
| 155 | + categoryDocumentation.checked = true; |
| 156 | + categoryNews.checked = true; |
| 157 | + } else { |
| 158 | + categoryDocumentation.checked = false; |
| 159 | + categoryNews.checked = false; |
| 160 | + } |
| 161 | + } |
| 162 | + |
| 163 | + categoryAll.addEventListener('change', () => { |
| 164 | + updateChildCheckboxes(); |
| 165 | + triggerSearch(searchInput.value.trim()); |
| 166 | + }); |
| 167 | + categoryDocumentation.addEventListener('change', () => { |
| 168 | + updateAllCheckbox(); |
| 169 | + triggerSearch(searchInput.value.trim()); |
| 170 | + }); |
| 171 | + categoryNews.addEventListener('change', () => { |
| 172 | + updateAllCheckbox(); |
| 173 | + triggerSearch(searchInput.value.trim()); |
| 174 | + }); |
| 175 | + }); |
| 176 | +</script> |
| 177 | +<script> |
| 178 | + document.addEventListener('DOMContentLoaded', () => { |
| 179 | + const searchInput = document.getElementById('searchPageInput'); |
| 180 | + |
| 181 | + const getQueryParam = (param) => { |
| 182 | + const urlParams = new URLSearchParams(window.location.search); |
| 183 | + return urlParams.get(param); |
| 184 | + }; |
| 185 | + |
| 186 | + const searchQuery = getQueryParam('q'); |
| 187 | + |
| 188 | + if (searchQuery) { |
| 189 | + searchInput.value = decodeURIComponent(searchQuery); |
| 190 | + triggerSearch(searchInput.value.trim()); |
| 191 | + } |
| 192 | + }); |
| 193 | +</script> |
| 194 | +</body> |
| 195 | +</html> |
0 commit comments