« get me outta code hell

client, css: "you are here" indicator - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/static/js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-05-06 17:37:42 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-05-31 12:11:51 -0300
commit0dd27ef9bbe41370d859ae48dcecd5c87303d567 (patch)
tree580375cb4f67a9f93a0c06e1de1ea4f63988eadd /src/static/js
parentc760d9400cf02e830c33749eed3894165b760432 (diff)
client, css: "you are here" indicator
Diffstat (limited to 'src/static/js')
-rw-r--r--src/static/js/client.js25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/static/js/client.js b/src/static/js/client.js
index 1b98137a..de90285c 100644
--- a/src/static/js/client.js
+++ b/src/static/js/client.js
@@ -3580,6 +3580,7 @@ const sidebarSearchInfo = initInfo('sidebarSearchInfo', {
   results: null,
 
   noResultsString: null,
+  currentResultString: null,
 
   state: {
     stoppedTypingTimeout: null,
@@ -3605,6 +3606,9 @@ function getSidebarSearchReferences() {
 
   info.noResultsString =
     info.searchBox.querySelector('.wiki-search-no-results-string');
+
+  info.currentResultString =
+    info.searchBox.querySelector('.wiki-search-current-result-string');
 }
 
 function mutateSidebarSearchContent() {
@@ -3803,6 +3807,8 @@ function getSearchResultImageSource(result) {
 }
 
 function generateSidebarSearchResultTemplate(slots) {
+  const info = sidebarSearchInfo;
+
   const link = document.createElement('a');
   link.classList.add('wiki-search-result');
 
@@ -3832,13 +3838,30 @@ function generateSidebarSearchResultTemplate(slots) {
     link.appendChild(placeholder);
   }
 
+  const text = document.createElement('span');
+  text.classList.add('wiki-search-result-text-area');
+
   if (slots.name) {
     const span = document.createElement('span');
     span.classList.add('wiki-search-result-name');
     span.appendChild(document.createTextNode(slots.name));
-    link.appendChild(span);
+    text.appendChild(span);
+  }
+
+  if (link.href) {
+    const here = location.href.replace(/\/$/, '');
+    const there = link.href.replace(/\/$/, '');
+    if (here === there) {
+      const span = document.createElement('span');
+      span.classList.add('wiki-search-current-result-text');
+      span.appendChild(templateContent(info.currentResultString));
+      text.appendChild(document.createTextNode(' '));
+      text.appendChild(span);
+    }
   }
 
+  link.appendChild(text);
+
   return link;
 }