diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-05-13 09:25:21 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-05-31 12:11:52 -0300 |
commit | 05f4385dc72df17eea850fd27b4b77d7b4f6f840 (patch) | |
tree | 5787342367fd570ac0735df5aecb758daceccc8e /src/static | |
parent | 685cbad73cab59210f7f8842e4399d0550f03905 (diff) |
client: search result kind accent
Diffstat (limited to 'src/static')
-rw-r--r-- | src/static/css/site.css | 3 | ||||
-rw-r--r-- | src/static/js/client.js | 31 |
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; |