diff --git a/frontend/course.html b/frontend/course.html index 8348452..9bc0aff 100644 --- a/frontend/course.html +++ b/frontend/course.html @@ -448,70 +448,6 @@ - - - - - - - - - - - diff --git a/frontend/dashboard.html b/frontend/dashboard.html index 8a32314..0e81729 100644 --- a/frontend/dashboard.html +++ b/frontend/dashboard.html @@ -1526,45 +1526,8 @@ - - - - - - + + @@ -2801,12 +2764,19 @@ /* ══ УВЕДОМЛЕНИЯ — handled by notifications.js ══ */ /* ══ JOIN MODAL ════════════════════════════════════════════════════════ */ + let _joinModal = null; function openJoinModal(code) { - document.getElementById('join-code').value = code || ''; - document.getElementById('join-modal').classList.add('open'); - setTimeout(() => document.getElementById('join-code').focus(), 50); + const body = ` + +
Попросите учителя поделиться кодом или ссылкой
`; + _joinModal = LS.modal({ + title: 'Вступить в класс', content: body, size: 'sm', + actions: [ + { label: 'Отмена', onClick: () => _joinModal.close() }, + { label: 'Вступить', primary: true, id: 'btn-do-join', onClick: doJoin }, + ], + }); } - function closeJoinModal() { document.getElementById('join-modal').classList.remove('open'); } async function doJoin() { const code = document.getElementById('join-code').value.trim(); if (!code) return; @@ -2814,11 +2784,10 @@ btn.disabled = true; try { const r = await LS.joinClass(code); - closeJoinModal(); + _joinModal?.close(); LS.toast(`Вы вступили в класс «${r.class_name}»!`, 'success'); loadAssignments(); - } catch (e) { LS.toast('Ошибка: ' + e.message, 'error'); } - finally { btn.disabled = false; } + } catch (e) { LS.toast('Ошибка: ' + e.message, 'error'); btn.disabled = false; } } /* ══ SUBMISSIONS (student) ════════════════════════════════════════════ */ @@ -3439,33 +3408,59 @@ /* ══ B1: QUICK-START MODAL ═════════════════════════════════════════ */ let _qsSlug = null; + let _qsModal = null; async function openQuickStart(slug) { _qsSlug = slug || null; + let subjectsHtml = ''; try { const subjects = await LS.getSubjects(); - document.getElementById('qs-subjects').innerHTML = subjects.map(s => { + subjectsHtml = subjects.map(s => { const color = SUBJ_COLORS[s.slug] || '#9B5DE5'; const active = s.slug === _qsSlug ? ' active' : ''; - return ``; }).join(''); - reIcons(); } catch {} - document.getElementById('qs-modal').classList.add('open'); + const body = ` +
${subjectsHtml}
+
+
+ Режим + +
+
+ Вопросов + +
+
`; + _qsModal = LS.modal({ + title: 'Быстрый тест', content: body, size: 'sm', + actions: [ + { label: 'Отмена', onClick: () => _qsModal.close() }, + { label: 'Начать', primary: true, onClick: doQuickStart }, + ], + }); + reIcons(); + // Wire subject selection within modal + _qsModal.body.querySelectorAll('.qs-subj-btn').forEach(btn => { + btn.addEventListener('click', () => { + _qsSlug = btn.dataset.slug; + _qsModal.body.querySelectorAll('.qs-subj-btn').forEach(b => b.classList.remove('active')); + btn.classList.add('active'); + }); + }); } - function selectQsSubject(slug, btn) { - _qsSlug = slug; - document.querySelectorAll('.qs-subj-btn').forEach(b => b.classList.remove('active')); - btn.classList.add('active'); - } - function closeQuickStart() { document.getElementById('qs-modal').classList.remove('open'); } function doQuickStart() { if (!_qsSlug) { LS.toast('Выберите предмет', 'warn'); return; } const mode = document.getElementById('qs-mode').value; const count = parseInt(document.getElementById('qs-count').value) || 25; - closeQuickStart(); + _qsModal?.close(); window.location.href = `/test-run?subject=${_qsSlug}&mode=${mode}&count=${count}`; } diff --git a/frontend/theory.html b/frontend/theory.html index e121078..d933c31 100644 --- a/frontend/theory.html +++ b/frontend/theory.html @@ -340,37 +340,6 @@ - - @@ -559,15 +528,39 @@ loadContinue(); /* ── modal ── */ + let _newCourseModal = null; function openNewCourseModal() { - document.getElementById('nc-title').value = ''; - document.getElementById('nc-desc').value = ''; - document.getElementById('nc-emoji').value = ''; - document.getElementById('new-course-modal').classList.add('open'); - setTimeout(() => document.getElementById('nc-title').focus(), 50); - } - function closeNewCourseModal() { - document.getElementById('new-course-modal').classList.remove('open'); + const body = ` +
+ + +
+
+ + +
+
+ + +
+
+ + +
`; + _newCourseModal = LS.modal({ + title: 'Новый курс', content: body, size: 'sm', + actions: [ + { label: 'Отмена', onClick: () => _newCourseModal.close() }, + { label: 'Создать', primary: true, id: 'btn-do-create', onClick: doCreateCourse }, + ], + }); + const titleEl = _newCourseModal.body.querySelector('#nc-title'); + titleEl.addEventListener('keydown', e => { if (e.key === 'Enter') doCreateCourse(); }); } async function doCreateCourse() { const title = document.getElementById('nc-title').value.trim(); @@ -585,15 +578,13 @@ coverEmoji: document.getElementById('nc-emoji').value.trim() || '', }), }); - closeNewCourseModal(); + _newCourseModal?.close(); location.href = '/course?id=' + res.id; } catch (e) { LS.toast(e.message || 'Ошибка', 'error'); - } finally { btn.disabled = false; } + btn.disabled = false; + } } - document.getElementById('nc-title').addEventListener('keydown', e => { - if (e.key === 'Enter') doCreateCourse(); - }); /* ══════════════════════════════════════════════════════════════════ TEMPLATE BROWSER