Files

83 lines
4.2 KiB
HTML
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!doctype html>
<html lang="ru">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="robots" content="noindex">
<title>Загрузка практики СудАкта</title>
<!-- Локальная страница загрузки: открывается как файл из .agent/maintenance/practice/status/.
Каждые 5 с подгружает status.js рядом с собой; его раз в минуту пишет
eunomia/practice.py publish. Скрипт, а не fetch: из file:// браузеры fetch запрещают. -->
<style>
:root { --text: #202824; --accent: #244B40; --track: #EDF4F0; --muted: #5B6660; --warn: #8A4B00; }
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #fff;
color: var(--text); font: 17px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
main { width: 100%; max-width: 560px; }
h1 { margin: 0; font-size: 17px; font-weight: 600; color: var(--muted); }
#pct { margin: 8px 0 24px; font: 400 clamp(72px, 22vw, 128px)/1 Georgia, "Times New Roman", serif;
letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
progress { display: block; width: 100%; height: 16px; border: 0; border-radius: 8px; overflow: hidden;
background: var(--track); -webkit-appearance: none; appearance: none; }
progress::-webkit-progress-bar { background: var(--track); }
progress::-webkit-progress-value { background: var(--accent); }
progress::-moz-progress-bar { background: var(--accent); }
p { margin: 16px 0 0; }
.muted { color: var(--muted); }
.stale { color: var(--warn); }
</style>
</head>
<body>
<main>
<h1>Загрузка практики СудАкта</h1>
<p id="pct">—</p>
<progress id="bar" max="100" value="0" aria-label="Скачано, процентов"></progress>
<p id="count"></p>
<p id="pace" class="muted"></p>
<p id="time" class="stale">Нет свежих данных</p>
</main>
<script>
const STALE_MS = 3 * 60 * 1000
const $ = (id) => document.getElementById(id)
const num = (n) => n.toLocaleString('ru-RU')
const acts = (n) => (n % 10 === 1 && n % 100 !== 11 ? 'акта' : 'актов') // «из 96 101 акта», «из 96 097 актов»
const left = (m) => (m < 60 ? `${m} мин` : `${Math.floor(m / 60)} ч ${m % 60} мин`)
let last = null
function render() {
if (!last) return
const s = last
const share = s.total ? Math.min(s.done / s.total, 1) : 0
const pct = (share * 100).toLocaleString('ru-RU', { minimumFractionDigits: 1, maximumFractionDigits: 1 }) + ' %'
$('pct').textContent = pct
document.title = `${pct} · загрузка практики СудАкта`
$('bar').value = share * 100
$('count').textContent = `Скачано ${num(s.done)} из ${num(s.total)} ${acts(s.total)}`
$('pace').textContent = s.total && s.done >= s.total ? 'Загрузка завершена'
: s.per_min > 0 ? `${num(Math.round(s.per_min))} в минуту, осталось около ${left(s.eta_min)}`
: 'Сейчас загрузка стоит'
const at = new Date(s.updated_at)
const fresh = Date.now() - at < STALE_MS
const clock = at.toLocaleString('ru-RU', fresh ? { hour: '2-digit', minute: '2-digit' }
: { day: 'numeric', month: 'long', hour: '2-digit', minute: '2-digit' })
$('time').textContent = fresh ? `Обновлено в ${clock}` : `Нет свежих данных. Последнее обновление: ${clock}`
$('time').className = fresh ? 'muted' : 'stale'
}
function showStatus(s) { last = s } // status.js: showStatus({...})
function load() { // файла нет - остаются прежние числа, через 3 минуты страница скажет, что они устарели
document.getElementById('data')?.remove()
const script = document.createElement('script')
script.id = 'data'
script.src = `status.js?${Date.now()}`
script.onload = script.onerror = render
document.body.append(script)
}
load()
setInterval(load, 5000)
</script>
</body>
</html>