From e56136f4fc5ac12735f332f1cde8f3748103ef1d Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 17 May 2026 15:16:44 +0300 Subject: Add in-progress frontend actions --- web/js/views/media-info.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'web/js/views/media-info.js') diff --git a/web/js/views/media-info.js b/web/js/views/media-info.js index 51e576c..bbb1f98 100644 --- a/web/js/views/media-info.js +++ b/web/js/views/media-info.js @@ -3,13 +3,29 @@ import { fmtDateTime, fmtSize } from '../dom.js'; import { escapeHtml, fmtDur, toast } from '../utils.js'; import { selectedMediaId } from './media-actions.js'; -export function initMediaInfo() { +let callbacks = {}; + +export function initMediaInfo(options = {}) { + callbacks = options; const modal = document.getElementById('media-info-modal'); const closeBtn = document.getElementById('media-info-close'); closeBtn?.addEventListener('click', closeMediaInfo); modal?.addEventListener('click', (e) => { if (e.target === modal) closeMediaInfo(); }); + modal?.addEventListener('click', async (e) => { + const button = e.target.closest('[data-media-info-action]'); + if (!button) return; + const id = button.dataset.mediaId; + if (!id) return; + let updated = false; + if (button.dataset.mediaInfoAction === 'mark-finished') { + updated = await callbacks.markAsFinished?.(id); + } else if (button.dataset.mediaInfoAction === 'mark-not-started') { + updated = await callbacks.markAsNotStarted?.(id); + } + if (updated) await openMediaInfo(id); + }); } export function closeMediaInfo() { @@ -113,6 +129,10 @@ function renderMediaInfo(detail) { .join(''); const raw = escapeHtml(JSON.stringify(detail || {}, null, 2)); return ` +
+ + +
${table}
Raw API detail -- cgit v1.2.3