taggart

Simple golang tagging filesystem webapp
Log | Files | Refs

commit dbd7e508df1fb3b21437ff7467f58fb285704b77
parent f3bf69ba29163ee34a07e533782d45ce7fa9e1aa
Author: breadcat <breadcat@users.noreply.github.com>
Date:   Fri, 17 Oct 2025 09:45:48 +0100

Allow clickable [file/123] links in description fields

Diffstat:
Mstatic/description.js | 24++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/static/description.js b/static/description.js @@ -26,6 +26,9 @@ function cancelDescriptionEdit() { displayDiv.style.display = 'block'; editDiv.style.display = 'none'; + + // Re-run conversion so any [file/123] becomes clickable again + convertFileRefs(); } // Auto-resize textarea as content changes @@ -40,4 +43,22 @@ document.addEventListener('DOMContentLoaded', function() { this.style.height = Math.max(minHeight, this.scrollHeight) + 'px'; }); } -}); -\ No newline at end of file +}); + +// Allow [file/123] and [/file/123] links to become clickable +function convertFileRefs() { + const el = document.getElementById("current-description"); + if (!el) return; + const text = el.textContent || ""; + const pattern = /\[\/?file\/(\d+)\]/g; + const converted = text.replace(pattern, (_, id) => { + return `<a href="/file/${id}" class="file-link">file/${id}</a>`; + }); + + el.innerHTML = converted; +} + +document.addEventListener("DOMContentLoaded", function() { + convertFileRefs(); +}); +