|
236 | 236 | footer p { |
237 | 237 | margin: 0 0 8px 0; |
238 | 238 | } |
| 239 | +
|
| 240 | + .search-container { |
| 241 | + display: flex; |
| 242 | + justify-content: space-evenly; |
| 243 | + } |
| 244 | + |
| 245 | + .column { |
| 246 | + display: flex; |
| 247 | + flex-direction: column; |
| 248 | + } |
| 249 | +
|
| 250 | + .search-base { |
| 251 | + display: flex; |
| 252 | + padding: 8px; |
| 253 | + font-size: 1rem; |
| 254 | + font-weight: 400; |
| 255 | + line-height: 1.5; |
| 256 | + background-color: transparent; |
| 257 | + background-clip: padding-box; |
| 258 | + -webkit-appearance: none; |
| 259 | + -moz-appearance: none; |
| 260 | + appearance: none; |
| 261 | + border-top: 2px solid #ff4c4c; |
| 262 | + border-bottom: 2px solid #ff4c4c; |
| 263 | + transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out; |
| 264 | + transition: box-shadow .15s ease-in-out, box-shadow .15s ease-in-out; |
| 265 | + } |
| 266 | +
|
| 267 | + .search-base:focus { |
| 268 | + outline: none; |
| 269 | + box-shadow: 0 0 0 .25rem rgba(236, 90, 84, .25); |
| 270 | + transition: box-shadow .15s ease-in-out, box-shadow .15s ease-in-out; |
| 271 | + } |
| 272 | +
|
| 273 | + .search-bar { |
| 274 | + border-right: 1px solid #ff4c4c; |
| 275 | + border-top-left-radius: 8px; |
| 276 | + border-bottom-left-radius: 8px; |
| 277 | + border-left: 2px solid #ff4c4c; |
| 278 | + width: 75%; |
| 279 | + max-width: 928px; |
| 280 | + } |
| 281 | +
|
| 282 | + .search-sort { |
| 283 | + border-left: 1px solid #ff4c4c; |
| 284 | + border-radius: 0px; |
| 285 | + border-top-right-radius: 8px; |
| 286 | + border-bottom-right-radius: 8px; |
| 287 | + border-right: 2px solid #ff4c4c; |
| 288 | + width: 25%; |
| 289 | + display: flex; |
| 290 | + } |
| 291 | +
|
239 | 292 | </style> |
240 | 293 | </head> |
241 | 294 |
|
|
319 | 372 | extension.dataset.samplesOpen = extension.dataset.samplesOpen !== 'true'; |
320 | 373 | } |
321 | 374 | }); |
| 375 | +
|
| 376 | + window.addEventListener("load", () => { |
| 377 | + const extensionElements = document.querySelectorAll(".extension"); |
| 378 | + const container = document.querySelector(".extensions"); |
| 379 | + const sort = document.getElementById("search-sort"); |
| 380 | +
|
| 381 | + document.getElementById("search-bar").addEventListener("input", function (evt) { |
| 382 | + const searchQuery = evt.srcElement.value.toLowerCase(); |
| 383 | +
|
| 384 | + extensionElements.forEach(extension => { |
| 385 | + const h2 = extension.querySelector("h2").textContent.toLowerCase(); |
| 386 | + const p = extension.querySelector("p").textContent.toLowerCase(); |
| 387 | + if (h2.includes(searchQuery) || p.includes(searchQuery)) { |
| 388 | + extension.style.removeProperty("display"); |
| 389 | + } else { |
| 390 | + extension.style.display = "none"; |
| 391 | + } |
| 392 | + }); |
| 393 | +
|
| 394 | + switch (sort.value) { |
| 395 | + case "original": |
| 396 | + originalOrder.forEach(div => container.appendChild(div)); |
| 397 | + break; |
| 398 | + case "abc": |
| 399 | + divs.sort((a, b) => a.textContent.localeCompare(b.textContent)); |
| 400 | + divs.forEach(div => container.appendChild(div)); |
| 401 | + break; |
| 402 | + case "zxy": |
| 403 | + divs.sort((a, b) => b.textContent.localeCompare(a.textContent)); |
| 404 | + divs.forEach(div => container.appendChild(div)); |
| 405 | + break; |
| 406 | + } |
| 407 | + }); |
| 408 | +
|
| 409 | + const divs = Array.from(extensionElements); |
| 410 | + const originalOrder = [...divs]; |
| 411 | +
|
| 412 | + sort.addEventListener("change", function (evt) { |
| 413 | + switch (evt.srcElement.value) { |
| 414 | + case "original": |
| 415 | + originalOrder.forEach(div => container.appendChild(div)); |
| 416 | + break; |
| 417 | + case "abc": |
| 418 | + divs.sort((a, b) => a.innerText.localeCompare(b.innerText)); |
| 419 | + divs.forEach(div => container.appendChild(div)); |
| 420 | + break; |
| 421 | + case "zxy": |
| 422 | + divs.sort((a, b) => b.innerText.localeCompare(a.innerText)); |
| 423 | + divs.forEach(div => container.appendChild(div)); |
| 424 | + break; |
| 425 | + } |
| 426 | + }); |
| 427 | + }); |
| 428 | +
|
322 | 429 | </script> |
323 | 430 |
|
324 | 431 | <div class="section extensions-outer"> |
| 432 | + <div class="search-container"> |
| 433 | + <input type="text" id="search-bar" class="search-base search-bar" placeholder="Search for extensions..."> |
| 434 | + <select class="search-base search-sort" id="search-sort"> |
| 435 | + <option value="original">Sort: Default</option> |
| 436 | + <!--<option value="option2">Sort: Relevance</option>--> |
| 437 | + <option value="abc">Sort: ABC</option> |
| 438 | + <option value="zxy">Sort: ZXY</option> |
| 439 | + <!--<option value="newest">Sort: Newest</option> |
| 440 | + <option value="oldest">Sort: Oldest</option>--> |
| 441 | + </select> |
| 442 | + </div> |
325 | 443 | <div class="extensions"> |
326 | 444 | <% |
327 | 445 | const peopleToHTML = (people) => { |
|
0 commit comments