import { api } from '../api.js'; import { showToast } from '../components/toast.js'; import { esc, hydrateAuthImages } from '../utils.js'; import { t } from '../i18n.js'; // #216: languages offered in the caption/subtitle pickers. Codes are BCP-47 primary tags — // enough for signage; extend as needed. const SUBTITLE_LANGS = [ ['en', 'English'], ['es', 'Español'], ['fr', 'Français'], ['de', 'Deutsch'], ['pt', 'Português'], ['it', 'Italiano'], ['nl', 'Nederlands'], ['ja', '日本語'], ['ko', '한국어'], ['zh', '中文'], ]; function formatFileSize(bytes) { if (!bytes) return '--'; if (bytes >= 1073741824) return `${(bytes / 1073741824).toFixed(1)} GB`; if (bytes >= 1048576) return `${(bytes / 1048576).toFixed(1)} MB`; if (bytes >= 1024) return `${(bytes / 1024).toFixed(0)} KB`; return `${bytes} B`; } // #157: classify a content item's expiry state for the card. `expired` when the server // deactivated it (is_active===0) or its expires_at has passed; `dateLabel` is the local // expiry date/time (present whenever expires_at is set, past or future). function expiryInfo(c) { const hasExpiry = c.expires_at != null && c.expires_at !== ''; const ts = hasExpiry ? Number(c.expires_at) * 1000 : null; const past = ts != null && ts <= Date.now(); const expired = c.is_active === 0 || past; const dateLabel = ts != null ? new Date(ts).toLocaleString([], { year: 'numeric', month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' }) : ''; return { expired, dateLabel }; } // Epoch seconds -> a value in the viewer's LOCAL wall-clock // (YYYY-MM-DDTHH:MM). Empty string for no expiry. function toLocalDatetimeInput(epochSec) { if (epochSec == null || epochSec === '') return ''; const d = new Date(Number(epochSec) * 1000); const p = (n) => String(n).padStart(2, '0'); return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())}T${p(d.getHours())}:${p(d.getMinutes())}`; } export function render(container) { container.innerHTML = `
${state.currentFolderId ? t('content.empty_folder_desc') : t('content.no_content_desc')}
${esc(err.message)}
${t('content.expires_hint')}
${t('content.unstable_connection_hint')}
${t('content.captions_hint')}
${t('content.subtitle_current')}
` : ''}${t('content.subtitle_hint')}
${t('content.replace_file_hint')}