From 3ffe4ff560e72201d71de01e1dabd619c7f36c43 Mon Sep 17 00:00:00 2001 From: Maxim Dolgolyov Date: Sun, 31 May 2026 11:53:48 +0300 Subject: [PATCH] =?UTF-8?q?feat(profile):=20=D1=80=D0=B5=D0=B9=D1=82=D0=B8?= =?UTF-8?q?=D0=BD=D0=B3=20(leaderboard)=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BD?= =?UTF-8?q?=D0=B5=D1=81=D1=91=D0=BD=20=D0=B2=20=D1=82=D0=B0=D0=B1=20=C2=AB?= =?UTF-8?q?=D0=94=D0=BE=D1=81=D1=82=D0=B8=D0=B6=D0=B5=D0=BD=D0=B8=D1=8F?= =?UTF-8?q?=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Карточка рейтинга с табами Неделя/Всё время, /api/gamification/leaderboard, самодостаточный JS (свой esc). Рейтинг убран с дашборда ранее. Co-Authored-By: Claude Opus 4.8 --- frontend/profile.html | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/frontend/profile.html b/frontend/profile.html index 9516506..0dc8fe1 100644 --- a/frontend/profile.html +++ b/frontend/profile.html @@ -1981,7 +1981,42 @@ loadFrames(); loadBookmarks(); + /* ── Рейтинг (leaderboard) ── */ + const _lbEsc = s => String(s == null ? '' : s).replace(/[&<>"']/g, c => ({ '&':'&','<':'<','>':'>','"':'"',"'":''' }[c])); + let _lbPeriod = 'week'; + function setLbPeriod(p, btn) { + _lbPeriod = p; + document.querySelectorAll('.lb-tab').forEach(t => t.classList.remove('active')); + if (btn) btn.classList.add('active'); + loadLeaderboard(); + } + window.setLbPeriod = setLbPeriod; + async function loadLeaderboard() { + const section = document.getElementById('lb-section'); + const list = document.getElementById('lb-list'); + if (!section || !list) return; + try { + const data = await LS.api('/api/gamification/leaderboard?period=' + encodeURIComponent(_lbPeriod)); + if (!data || !data.length) { section.style.display = 'none'; return; } + list.innerHTML = data.map((u, i) => { + const rank = i + 1; + const medal = rank === 1 ? '#FFD700' : rank === 2 ? '#C0C0C0' : rank === 3 ? '#CD7F32' : 'transparent'; + const meClass = u.is_me ? ' lb-row-me' : ''; + return ` +
+
${rank}
+
${u.avatar ? `` : _lbEsc((u.name || '?')[0])}
+
${_lbEsc(u.name || 'Ученик')}
+
${u.sort_xp || u.xp || 0} XP
+
`; + }).join(''); + section.style.display = ''; + if (window.lucide) lucide.createIcons(); + } catch { section.style.display = 'none'; } + } + loadProfile(); + loadLeaderboard(); if (window.lucide) lucide.createIcons(); /* ── Настройки (prefs tab) ── */