brendmanager/public/channels.html
Peppa c3425cb638
All checks were successful
peppa/lint lint: success за 0с
peppa/test test: success за 0с
ci / checks (pull_request) Successful in 5s
deploy / deploy (pull_request) Successful in 13s
BRM-56: таблица каналов (страница «Каналы», /api/channels, тексты на трёх языках)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-17 01:53:19 +05:00

32 lines
2.4 KiB
HTML

<!doctype html>
<html lang="ru"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title data-t="ui.ch.title"></title>
<style>
body{font:15px/1.45 system-ui,sans-serif;max-width:1300px;margin:auto;padding:16px;color:#222}
h1{font-size:20px}table{border-collapse:collapse;width:100%}td,th{border:1px solid #ddd;padding:4px 8px;text-align:left;vertical-align:top}
.wrap{overflow-x:auto}.todo{color:#555;font-style:italic}.hint{font-size:13px;color:#555}
</style></head><body>
<p><a href="/" data-t="ui.common.home"></a></p>
<h1 data-t="ui.ch.title"></h1>
<p data-t="ui.ch.intro"></p>
<p class="hint" data-t="ui.ch.pri.hint"></p>
<div class="wrap"><table><tr><th data-t="ui.ch.col.channel"></th><th data-t="ui.ch.col.audience"></th><th data-t="ui.ch.col.goal"></th><th data-t="ui.ch.col.role"></th><th data-t="ui.ch.col.access"></th><th data-t="ui.ch.col.auto"></th><th data-t="ui.ch.col.limits"></th><th data-t="ui.ch.col.fallback"></th><th data-t="ui.ch.col.metrics"></th><th data-t="ui.ch.col.status"></th><th data-t="ui.ch.col.priority"></th></tr><tbody id="out"></tbody></table></div>
<p id="err"></p>
<script>
const esc=s=>String(s??"").replace(/[&<>"']/g,c=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"}[c]));
let T={};const t=k=>T[k]??"";
const WANT=new URLSearchParams(location.search).get("lang")||"ru";
const get=u=>fetch(u,{headers:{"x-lang":WANT}}).then(r=>{if(!r.ok)throw 0;return r.json()});
const todo=()=>`<span class="todo">${esc(t("ui.ch.clarify"))}</span>`;
const val=(v,key)=>v?esc(key?t(key):v):todo();
function render({items}){
const row=c=>[`<b>${esc(t("ui.ch.name."+c.id))}</b>`+(c.link?`<br><a href="${esc(c.link)}" target="_blank" rel="noopener noreferrer">${esc(c.link.replace(/^https?:\/\//,""))}</a>`:""),
val(c.audience),val(c.goal),val(c.role),esc(t("ui.ch.access."+c.access)),esc(t("ui.ch.auto."+c.auto)),esc(t("ui.ch.limits."+c.id)),
esc(t("ui.ch.fallback")),val(c.metrics),esc(t("ui.ch.status."+c.status)),val(c.priority)];
document.getElementById("out").innerHTML=items.map(c=>`<tr>${row(c).map(x=>`<td>${x}</td>`).join("")}</tr>`).join("");
}
get("/api/texts").then(d=>{T=d.texts;document.title=t("ui.ch.title");document.documentElement.lang=d.lang;
for(const e of document.querySelectorAll("[data-t]"))e.textContent=t(e.dataset.t);
return get("/api/channels").then(render)}).catch(()=>{document.getElementById("err").textContent=t("ui.ch.loadError")||"⚠"});
</script></body></html>