Files
media-episode-viewer/templates/index.html
T
2026-02-22 15:39:50 +08:00

155 lines
5.1 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>One Piece Progress Report</title>
<style>
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: system-ui, sans-serif;
background: #0f0f0f;
color: #e8e8e8;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
padding: 2.5rem 1rem;
}
h1 { font-size: 1.5rem; margin-bottom: 0.4rem; color: #f97316; }
.week-label { font-size: 0.9rem; color: #888; margin-bottom: 1.8rem; }
.card {
background: #1c1c1c;
border: 1px solid #2e2e2e;
border-radius: 10px;
padding: 1.4rem;
width: 100%;
max-width: 500px;
margin-bottom: 1rem;
}
button {
width: 100%;
padding: 0.7rem 1rem;
border: none;
border-radius: 6px;
font-size: 1rem;
cursor: pointer;
transition: opacity 0.15s;
}
button:disabled { opacity: 0.45; cursor: not-allowed; }
#btn-report { background: #f97316; color: #fff; font-weight: 600; }
#btn-report:not(:disabled):hover { opacity: 0.85; }
.detail-grid {
display: grid;
grid-template-columns: auto 1fr;
gap: 0.5rem 1.2rem;
font-size: 0.9rem;
margin-bottom: 1rem;
}
.detail-grid .lbl { color: #888; white-space: nowrap; }
.detail-grid .val { color: #fff; font-weight: 600; }
#report-box {
width: 100%;
background: #111;
border: 1px solid #2e2e2e;
border-radius: 6px;
padding: 0.8rem 1rem;
color: #f0f0f0;
font-family: monospace;
font-size: 0.95rem;
white-space: pre-wrap;
min-height: 72px;
}
#copy-btn {
margin-top: 0.7rem;
background: #16a34a;
color: #fff;
}
#copy-btn:not(:disabled):hover { opacity: 0.85; }
.status { font-size: 0.85rem; color: #f59e0b; min-height: 1.2rem; margin-top: 0.6rem; text-align: center; }
.error { color: #f87171; }
.hidden { display: none; }
.media-name { font-size: 0.78rem; color: #666; margin-top: 0.8rem; word-break: break-word; }
</style>
</head>
<body>
<h1>🏴‍☠️ One Piece Progress Reporter</h1>
<div class="week-label">Week: <strong>{{ date_range }}</strong> &nbsp;({{ week_start }} → {{ week_end }})</div>
<div class="card" style="margin-top:0.8rem;">
<h2 style="font-size:0.95rem;color:#aaa;margin-bottom:0.5rem;">Environment</h2>
<pre id="env" style="white-space:pre-wrap;font-family:monospace;font-size:0.85rem;color:#ddd;background:#0b0b0b;border-radius:6px;padding:0.6rem;">
JELLYFIN_HOST={{ config.JELLYFIN_HOST }}
JELLYFIN_API_KEY={{ config.JELLYFIN_API_KEY }}
JELLYFIN_USER_ID={{ config.JELLYFIN_USER_ID }}
TOTAL_EPISODES={{ config.TOTAL_EPISODES }}
DB_PATH={{ config.DB_PATH }}
</pre>
</div>
<div class="card">
<button id="btn-report">Generate Report</button>
<div id="status" class="status"></div>
</div>
<div class="card hidden" id="details-card">
<div class="detail-grid">
<span class="lbl">Last episode watched</span><span class="val" id="d-latest">—</span>
<span class="lbl">Previous week ended at</span><span class="val" id="d-previous">—</span>
<span class="lbl">Watched this week</span><span class="val" id="d-watched">—</span>
<span class="lbl">Total in series</span><span class="val" id="d-total">—</span>
</div>
<div id="report-box"></div>
<button id="copy-btn">📋 Copy to Clipboard</button>
<div id="media-name" class="media-name hidden"></div>
</div>
<script>
const $ = id => document.getElementById(id);
function setStatus(msg, isError = false) {
const el = $('status');
el.textContent = msg;
el.classList.toggle('error', isError);
}
$('btn-report').addEventListener('click', async () => {
$('btn-report').disabled = true;
setStatus('Fetching from Jellyfin…');
$('details-card').classList.add('hidden');
try {
const resp = await fetch('/api/report');
const data = await resp.json();
if (data.error) throw new Error(data.error);
$('d-latest').textContent = data.latest_episode;
$('d-previous').textContent = data.previous_episode;
$('d-watched').textContent = data.watched_this_week;
$('d-total').textContent = data.total_episodes;
$('report-box').textContent = data.report;
if (data.media_name) {
$('media-name').textContent = '📁 ' + data.media_name;
$('media-name').classList.remove('hidden');
}
$('details-card').classList.remove('hidden');
setStatus('');
} catch (e) {
setStatus(e.message, true);
} finally {
$('btn-report').disabled = false;
}
});
$('copy-btn').addEventListener('click', () => {
navigator.clipboard.writeText($('report-box').textContent)
.then(() => setStatus('Copied to clipboard!'))
.catch(() => setStatus('Copy failed — select text manually', true));
});
</script>
</body>
</html>