184 lines
6.3 KiB
HTML
184 lines
6.3 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: 1000px;
|
|
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> ({{ week_start }} → {{ week_end }})</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>
|
|
|
|
<div class="card" style="margin-top:0.8rem;">
|
|
<h2 style="font-size:0.95rem;color:#aaa;margin-bottom:0.5rem;">Debug</h2>
|
|
<pre id="debug" style="white-space:pre-wrap;font-family:monospace;font-size:0.85rem;color:#ddd;background:#0b0b0b;border-radius:6px;padding:0.6rem;">
|
|
LATEST_SUNDAY={{ latest_sunday }}
|
|
PREVIOUS_SUNDAY={{ previous_sunday }}
|
|
JELLYFIN_HOST={{ config.JELLYFIN_HOST }}
|
|
JELLYFIN_USER_ID={{ config.JELLYFIN_USER_ID }}
|
|
TOTAL_EPISODES={{ config.TOTAL_EPISODES }}
|
|
DB_PATH={{ config.DB_PATH }}
|
|
|
|
(Report output will appear here after Generate Report is clicked)
|
|
</pre>
|
|
</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) {
|
|
if (data.debug) {
|
|
$('debug').textContent += '\n\n' + data.debug;
|
|
}
|
|
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');
|
|
}
|
|
|
|
const debugLines = [];
|
|
if (data.debug) {
|
|
debugLines.push('\n' + data.debug);
|
|
}
|
|
debugLines.push('');
|
|
debugLines.push('✓ Fetched report from /api/report');
|
|
debugLines.push(`✓ Latest Sunday (UTC): ${data.latest_sunday}`);
|
|
debugLines.push(`✓ Previous Sunday (UTC): ${data.previous_sunday}`);
|
|
debugLines.push(`✓ Activity cutoff: before ${data.latest_sunday}`);
|
|
debugLines.push(`✓ Found: "${data.media_name}"`);
|
|
debugLines.push(`✓ Extracted episode: ${data.latest_episode}`);
|
|
debugLines.push(`✓ Previous week episode: ${data.previous_episode}`);
|
|
debugLines.push(`✓ Episodes watched: ${data.watched_this_week}`);
|
|
debugLines.push(`✓ Total episodes in series: ${data.total_episodes}`);
|
|
debugLines.push(`✓ Saved to DB: week_start=${data.week_start}, week_end=${data.week_end}`);
|
|
debugLines.push('');
|
|
debugLines.push('Final report:');
|
|
debugLines.push(data.report);
|
|
$('debug').textContent += debugLines.join('\n');
|
|
|
|
$('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>
|
|
|