taggart

Simple golang tagging filesystem webapp
Log | Files | Refs

commit c5e7929180b92337272612555a4cd4c3ae14c959
parent c4816d597ecc3ed9e68df952c201dc9c1b76901c
Author: breadcat <breadcat@users.noreply.github.com>
Date:   Mon,  5 Jan 2026 16:15:05 +0000

Allow rotation to be applied to images too

Diffstat:
Mstatic/timestamps.js | 19+++++++++++++------
Mtemplates/file.html | 3++-
2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/static/timestamps.js b/static/timestamps.js @@ -7,9 +7,10 @@ function parseTimestamp(ts) { return seconds; } -function makeTimestampsClickable(containerId, videoId) { +function makeTimestampsClickable(containerId, videoId, imageId) { const container = document.getElementById(containerId); const video = document.getElementById(videoId); + const image = document.getElementById(imageId); // Regex for timestamps: [h:mm:ss] or [mm:ss] or [ss] const timestampRegex = /\[(\d{1,2}(?::\d{2}){0,2})\]/g; @@ -32,18 +33,24 @@ function makeTimestampsClickable(containerId, videoId) { if (e.target.classList.contains("timestamp")) { e.preventDefault(); const time = Number(e.target.dataset.time); - video.currentTime = time; - video.play(); + if (video) { + video.currentTime = time; + video.play(); + } } else if (e.target.classList.contains("rotate")) { e.preventDefault(); const angle = Number(e.target.dataset.angle); - video.style.transform = `rotate(${angle}deg)`; - video.style.transformOrigin = "center center"; + // Apply rotation to whichever element exists + const target = video || image; + if (target) { + target.style.transform = `rotate(${angle}deg)`; + target.style.transformOrigin = "center center"; + } } }); } // Run it document.addEventListener("DOMContentLoaded", () => { - makeTimestampsClickable("current-description", "videoPlayer"); + makeTimestampsClickable("current-description", "videoPlayer", "imageViewer"); }); \ No newline at end of file diff --git a/templates/file.html b/templates/file.html @@ -59,7 +59,8 @@ <div class="file-content"> {{if hasAnySuffix .Data.File.Filename ".jpg" ".jpeg" ".png" ".gif" ".webp"}} - <a href="/uploads/{{.Data.EscapedFilename}}" target="_blank"><img src="/uploads/{{.Data.EscapedFilename}}" class="file-content-image"></a><br> + <a href="/uploads/{{.Data.EscapedFilename}}" target="_blank"><img src="/uploads/{{.Data.EscapedFilename}}" id="imageViewer" class="file-content-image"></a><br> + <script src="/static/timestamps.js" defer></script> {{else if hasAnySuffix .Data.File.Filename ".mp4" ".webm" ".mov" ".m4v"}} <video id="videoPlayer" controls loop muted width="600"> <source src="/uploads/{{.Data.EscapedFilename}}">