brendmanager/public/market.html
2026-11-16 10:51:07 +05:00

25 lines
2.1 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

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">
<title>Рынок</title>
<style>
body{font:15px system-ui,sans-serif;max-width:1100px;margin:auto;padding:16px;color:#222}
h1{font-size:20px}h2{font-size:16px;margin-top:24px}
table{border-collapse:collapse;width:100%}td,th{border:1px solid #ddd;padding:4px 8px;text-align:left;vertical-align:top}
</style></head><body>
<p><a href="/">← На главную</a></p>
<h1>Рынок</h1>
<p>Тренды, конкуренты и гипотезы ниш из отчёта по нише. Данные демонстрационные; источник каждой записи указан в таблице.</p>
<div id="out">Загружаем…</div>
<script>
const esc=s=>String(s??"").replace(/[&<>"]/g,c=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"}[c]));
const SEC=[["trend","Тренды"],["competitor","Конкуренты"],["hypothesis","Гипотезы ниш"]];
fetch("/api/market").then(r=>r.json()).then(({items})=>{
document.getElementById("out").innerHTML=SEC.map(([k,name])=>{
const rows=items.filter(i=>i.kind===k);
const extra=k==="competitor"?i=>i.profileUrl?`<a href="${esc(i.profileUrl)}" rel="noopener">профиль</a>`:"":k==="hypothesis"?i=>esc((i.status||"")+(i.score!=null?", оценка "+i.score:"")):()=>"";
const head=k==="trend"?"":`<th>${k==="competitor"?"Профиль":"Статус"}</th>`;
return `<h2>${name} (${rows.length})</h2>`+(rows.length?`<table><tr><th>Название</th><th>Описание</th><th>Источник</th><th>Дата сбора</th><th>Уверенность</th>${head}</tr>`+rows.map(i=>`<tr><td>${esc(i.title)}</td><td>${esc(i.summary)}</td><td>${esc(i.source)}</td><td>${esc(i.collectedAt)}</td><td>${esc(i.confidence)}</td>${k==="trend"?"":`<td>${extra(i)}</td>`}</tr>`).join("")+"</table>":"<p>Пока нет записей.</p>");
}).join("");
}).catch(()=>{document.getElementById("out").textContent="Не удалось загрузить данные. Обновите страницу."});
</script></body></html>