commit 471defa78a952175ec01a6fe0eb4cb52057527b8
parent 343e430561922225de26740beba36f08bb54eace
Author: JayVii <jayvii[AT]posteo[DOT]de>
Date: Fri, 18 Oct 2024 00:10:29 +0200
fixup! feat: implement proper "Default" category
Diffstat:
2 files changed, 29 insertions(+), 23 deletions(-)
diff --git a/assets/css/custom.css b/assets/css/custom.css
@@ -78,11 +78,6 @@ article.selected {
background-color: var(--hlaccent);
}
-/* Add Text-Marker for selected search engines */
-article.selected > mark {
- display: initial !important;
-}
-
/* prevent wrapping within marks */
p > mark {
display: inline-block;
diff --git a/index.php b/index.php
@@ -241,17 +241,21 @@
</a>
</h3>
<p><?php echo $search["description"]; ?></p>
- <!-- Insert "Default" Marker for all search engines
- Hide Default Marker initially -->
- <mark style="display: none;">#Default</mark>
- <?php
- foreach ($search["categories"] as $catid) {
- $cat_name = $categories[$catid]["name"];
- ?>
- <mark><?php echo "#" . $categories[$catid]["name"]; ?></mark>
- <?php
- }
- ?>
+ <div class="categories">
+ <?php
+ if ($searchid == $default_search) {
+ ?>
+ <mark id="default_category">#Default</mark>
+ <?php
+ }
+ foreach ($search["categories"] as $catid) {
+ $cat_name = $categories[$catid]["name"];
+ ?>
+ <mark><?php echo "#" . $categories[$catid]["name"]; ?></mark>
+ <?php
+ }
+ ?>
+ </div>
<br>
<strong>Keywords: </strong>
<code>
@@ -411,11 +415,21 @@
"SameSite=Strict;";
// Set value in searchbar
document.getElementById("default_search").value = selection;
- // Update Search Engines list
+ // Gather Entries of Search Engines list
var entries = document.querySelectorAll("article")
+ // Remove pre-existing "Default" Markers
+ document.querySelectorAll("#default_category").forEach(
+ function(obj){ obj.remove(); }
+ );
+ // Create "Default" Marker
+ let marker = document.createElement("mark");
+ marker.id = "default_category";
+ marker.innerText = "#Default";
+ // Update Search Engines List
for (let i = 0; i < entries.length; i++) {
if (entries[i].id == selection) {
entries[i].classList.add("selected");
+ entries[i].querySelector(".categories").prepend(marker);
} else {
entries[i].classList.remove("selected");
}
@@ -448,12 +462,9 @@
var pat = document.getElementById(bar).value.toLowerCase();
// Compare text in article objects with text in search bar
// Mark those hidden that do not match
- var entries = document.querySelectorAll("article")
+ var entries = document.querySelectorAll("article");
for (let i = 0; i < entries.length; i++) {
- if (
- !(entries[i].classList.contains("hidden")) &&
- entries[i].innerText.toLowerCase().match(pat) == null
- ) {
+ if (entries[i].innerText.toLowerCase().match(pat) === null) {
entries[i].classList.add("hidden");
} else {
entries[i].classList.remove("hidden");
@@ -470,7 +481,7 @@
// collapse category summary
document.getElementById("categories").open = false;
// filter through search engines list
- setTimeout(search_engines("engines_searchbar"), 500);
+ search_engines("engines_searchbar");
// Scroll back to search bar
setTimeout(scroll_to("engines"), 500);
}