110 lines
6.9 KiB
HTML
110 lines
6.9 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="ru">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
<meta name="theme-color" content="#F7C90E">
|
|
<title>Записи занятий</title>
|
|
<style>
|
|
*{margin:0;padding:0;box-sizing:border-box}
|
|
:root{--yellow:#F7C90E;--dark:#211E22;--gray:#9C9C9C;--page:#f6f6f6;--card-bg:#fff;--radius:30px}
|
|
body{font-family:'Segoe UI',system-ui,-apple-system,Roboto,sans-serif;background:var(--page);color:var(--dark);min-height:100dvh}
|
|
.hero{background:var(--yellow);padding:44px 20px 52px;text-align:center;position:relative;overflow:hidden}
|
|
.hero h1{font-size:clamp(1.6rem,4.5vw,2.9rem);font-weight:800;line-height:1.05;letter-spacing:-.02em;color:var(--dark);max-width:900px;margin:0 auto}
|
|
.hero .chips{margin-top:20px;display:flex;gap:10px;justify-content:center;flex-wrap:wrap}
|
|
.hero .chip{background:#fff;color:var(--dark);border-radius:999px;padding:8px 18px;font-size:.88rem;font-weight:600;box-shadow:5px 5px 10px rgba(216,173,0,.25)}
|
|
.wrap{max-width:1200px;margin:0 auto;padding:48px 28px 70px}
|
|
.grid{display:grid;grid-template-columns:repeat(4,1fr);gap:28px}
|
|
.card{background:var(--card-bg);border-radius:var(--radius);padding:10px 10px 14px;box-shadow:0 1px 3px rgba(20,30,40,.06);transition:transform .18s ease,box-shadow .18s ease;display:flex;flex-direction:column}
|
|
.card:hover{transform:translateY(-4px);box-shadow:0 14px 30px rgba(20,30,40,.14)}
|
|
.card .photo{border-radius:24px;overflow:hidden;background:#E7E7E7}
|
|
.card .photo img{width:100%;aspect-ratio:1/1;object-fit:cover;display:block;cursor:zoom-in}
|
|
.card .no-photo{aspect-ratio:1/1;background:#E7E7E7;display:flex;align-items:center;justify-content:center;color:var(--gray)}
|
|
.card .no-photo svg{width:52%;height:52%}
|
|
.card .no-photo svg *{fill:currentColor}
|
|
.card .body{padding:14px 6px 4px;display:flex;flex-direction:column;gap:6px;flex:1}
|
|
.card .name{font-size:1.02rem;font-weight:700;color:var(--dark);letter-spacing:-.01em}
|
|
.card .group{display:inline-block;background:var(--yellow);color:var(--dark);font-size:.72rem;font-weight:700;padding:4px 11px;border-radius:999px;align-self:flex-start}
|
|
.card .desc{font-size:.9rem;line-height:1.45;color:#4a4f5a;white-space:pre-wrap;word-break:break-word}
|
|
.card .files{display:flex;flex-wrap:wrap;gap:6px;margin-top:2px}
|
|
.card .files a{display:inline-flex;align-items:center;gap:4px;background:#F2F2F2;border:1px solid #E6E6E6;color:#3a3f4a;text-decoration:none;border-radius:999px;padding:5px 12px;font-size:.75rem;max-width:200px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;transition:border .15s,color .15s}
|
|
.card .files a:hover{border-color:var(--yellow);color:var(--dark)}
|
|
.card .files a::before{content:'📎'}
|
|
.card .foot{margin-top:auto;padding:8px 6px 2px;font-size:.78rem;color:var(--gray)}
|
|
.empty{grid-column:1/-1;background:#fff;border-radius:var(--radius);padding:48px 24px;text-align:center;color:var(--gray);box-shadow:0 1px 3px rgba(20,30,40,.06)}
|
|
.empty .big{font-size:2rem;margin-bottom:10px}
|
|
.loading{grid-column:1/-1;text-align:center;color:var(--gray);padding:40px}
|
|
.lightbox{position:fixed;inset:0;background:rgba(12,14,20,.92);display:none;align-items:center;justify-content:center;z-index:100;cursor:zoom-out;padding:24px}
|
|
.lightbox.open{display:flex}
|
|
.lightbox img{max-width:100%;max-height:100%;border-radius:12px;box-shadow:0 20px 60px rgba(0,0,0,.5)}
|
|
@media(max-width:1000px){.grid{grid-template-columns:repeat(3,1fr)}}
|
|
@media(max-width:760px){.grid{grid-template-columns:repeat(2,1fr)}}
|
|
@media(max-width:480px){.grid{grid-template-columns:1fr}}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<section class="hero">
|
|
<h1 id="title">Загрузка...</h1>
|
|
<div class="chips" id="chips"></div>
|
|
</section>
|
|
<main class="wrap">
|
|
<div class="grid" id="grid"><div class="loading">Карточки загружаются...</div></div>
|
|
</main>
|
|
<div class="lightbox" id="lightbox" onclick="this.classList.remove('open')"><img id="lightboxImg" alt=""></div>
|
|
|
|
<script>
|
|
function esc(s){return String(s==null?'':s).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"')}
|
|
function fmt(d){return d?d.split('-').reverse().join('.'):'весь период'}
|
|
function showImg(src){document.getElementById('lightboxImg').src=src;document.getElementById('lightbox').classList.add('open')}
|
|
function isImageFile(name){return /\.(jpe?g|png|gif|webp|bmp|avif|svg|ico)$/i.test(name||'')}
|
|
function filesHTML(files){
|
|
if(!files||!files.length)return '';
|
|
return `<div class="files">${files.map(f=>isImageFile(f.name)
|
|
?`<a href="/api/files/${f.token}" target="_blank" title="Открыть">${esc(f.name)}</a>`
|
|
:`<a href="/api/files/${f.token}" download title="Скачать">${esc(f.name)}</a>`
|
|
).join('')}</div>`;
|
|
}
|
|
|
|
(async()=>{
|
|
const token = location.pathname.split('/').filter(Boolean).pop() || '';
|
|
try {
|
|
const res = await fetch('/api/share/' + token);
|
|
if (!res.ok) throw new Error();
|
|
const data = await res.json();
|
|
const heading = data.group_name || data.name || 'Записи занятий';
|
|
document.title = heading;
|
|
document.getElementById('title').textContent = heading;
|
|
const chips = [];
|
|
if (data.group_name) chips.push(`Группа: <b>${esc(data.group_name)}</b>`);
|
|
if (data.date_from || data.date_to) chips.push(`Период: <b>${fmt(data.date_from)}</b> — <b>${fmt(data.date_to)}</b>`);
|
|
document.getElementById('chips').innerHTML = chips.map(c => `<span class="chip">${c}</span>`).join('');
|
|
|
|
const grid = document.getElementById('grid');
|
|
if (!data.entries.length) {
|
|
grid.innerHTML = '<div class="empty"><div class="big">🎈</div>Записей пока нет</div>';
|
|
return;
|
|
}
|
|
grid.innerHTML = data.entries.map(e => `
|
|
<div class="card">
|
|
<div class="photo">
|
|
${e.photo_path
|
|
? `<img src="${e.photo_path}" onclick="showImg('${e.photo_path}')" alt="">`
|
|
: `<div class="no-photo"><svg viewBox="0 0 240 160" preserveAspectRatio="xMidYMid meet" aria-hidden="true"><circle cx="105" cy="48" r="15"/><path d="M74 140 C74 106 88 92 105 92 C122 92 136 106 136 140 Z"/><circle cx="145" cy="58" r="18"/><path d="M108 144 C108 104 124 88 145 88 C166 88 182 104 182 144 Z"/></svg></div>`}
|
|
</div>
|
|
<div class="body">
|
|
<div class="name">${esc(e.student_name)}</div>
|
|
<div>${e.group_name ? `<span class="group">${esc(e.group_name)}</span>` : ''}</div>
|
|
<div class="desc">${esc(e.description)}</div>
|
|
${filesHTML(e.files)}
|
|
</div>
|
|
<div class="foot">${new Date(e.created_at).toLocaleString('ru',{day:'2-digit',month:'2-digit',year:'numeric',hour:'2-digit',minute:'2-digit'})}</div>
|
|
</div>
|
|
`).join('');
|
|
} catch {
|
|
document.getElementById('title').textContent = 'Ссылка не найдена';
|
|
document.getElementById('grid').innerHTML = '<div class="empty"><div class="big">🤔</div>Эта ссылка не существует или была удалена</div>';
|
|
}
|
|
})();
|
|
</script>
|
|
</body>
|
|
</html> |