« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/static
diff options
context:
space:
mode:
Diffstat (limited to 'src/static')
-rw-r--r--src/static/css/site.css3
-rw-r--r--src/static/js/client.js31
2 files changed, 28 insertions, 6 deletions
diff --git a/src/static/css/site.css b/src/static/css/site.css
index 766a4010..41d0414b 100644
--- a/src/static/css/site.css
+++ b/src/static/css/site.css
@@ -575,7 +575,8 @@ summary .group-name {
   text-decoration: underline;
 }
 
-.wiki-search-current-result-text {
+.wiki-search-current-result-text,
+.wiki-search-result-kind {
   font-style: oblique;
   opacity: 0.9;
   display: inline-block;
diff --git a/src/static/js/client.js b/src/static/js/client.js
index 31e16aa2..5b762c49 100644
--- a/src/static/js/client.js
+++ b/src/static/js/client.js
@@ -3589,6 +3589,8 @@ const sidebarSearchInfo = initInfo('sidebarSearchInfo', {
   currentResultString: null,
   endSearchString: null,
 
+  artistResultKindString: null,
+
   state: {
     stoppedTypingTimeout: null,
   },
@@ -3627,6 +3629,9 @@ function getSidebarSearchReferences() {
 
   info.endSearchString =
     findString('end-search');
+
+  info.artistResultKindString =
+    findString('artist-result-kind');
 }
 
 function mutateSidebarSearchContent() {
@@ -3820,6 +3825,8 @@ function showSidebarSearchResults(results) {
 }
 
 function generateSidebarSearchResult(result) {
+  const info = sidebarSearchInfo;
+
   const preparedSlots = {
     color:
       result.data.color ?? null,
@@ -3836,6 +3843,9 @@ function generateSidebarSearchResult(result) {
       preparedSlots.href =
         openArtist(result.directory);
 
+      preparedSlots.kindString =
+        info.artistResultKindString;
+
       break;
     }
 
@@ -3920,18 +3930,29 @@ function generateSidebarSearchResultTemplate(slots) {
     text.appendChild(span);
   }
 
+  let accentSpan = null;
+
   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);
+      accentSpan = document.createElement('span');
+      accentSpan.classList.add('wiki-search-current-result-text');
+      accentSpan.appendChild(templateContent(info.currentResultString));
     }
   }
 
+  if (!accentSpan && slots.kindString) {
+    accentSpan = document.createElement('span');
+    accentSpan.classList.add('wiki-search-result-kind');
+    accentSpan.appendChild(templateContent(slots.kindString));
+  }
+
+  if (accentSpan) {
+    text.appendChild(document.createTextNode(' '));
+    text.appendChild(accentSpan);
+  }
+
   link.appendChild(text);
 
   return link;