feat(sim-builder): фаза 7 — custom-sim на доске онлайн-урока (синхрон параметров классу, аннотации)

This commit is contained in:
Maxim Dolgolyov
2026-06-13 13:25:24 +03:00
parent 5c01a5c7ed
commit f26b522207
7 changed files with 192 additions and 26 deletions
+26 -5
View File
@@ -7056,14 +7056,32 @@
const CAT_LABELS = { math:'Математика', phys:'Физика', chem:'Химия', bio:'Биология', game:'Игра' };
let _simPickerCat = 'all'; // active filter in picker
// Конструктор симуляций (Фаза 7): свои + published custom-симуляции для доски.
let _crCustomSims = null; // [{ id, cat, title, _custom:true }] — кэш списка
function crOpenSimPicker() {
async function _crLoadCustomSims() {
if (_crCustomSims) return _crCustomSims;
try {
const data = await LS.customSimsList();
const rows = (data && data.sims) || [];
_crCustomSims = rows.map(s => ({
id: 'custom:' + s.id,
cat: s.cat || 'phys',
title: s.title || ('Симуляция #' + s.id),
_custom: true,
}));
} catch (e) { _crCustomSims = []; }
return _crCustomSims;
}
async function crOpenSimPicker() {
if (_simActive) {
// If sim already open — clicking "Симуляция" closes it (teacher action)
crTeacherCloseSim();
return;
}
_simPickerCat = 'all';
await _crLoadCustomSims();
_crRenderSimGrid('all');
const overlay = document.getElementById('cr-sim-picker-overlay');
overlay.classList.add('open');
@@ -7084,11 +7102,14 @@
function _crRenderSimGrid(cat) {
const grid = document.getElementById('cr-sim-picker-grid');
const sims = cat === 'all' ? CR_SIMS : CR_SIMS.filter(s => s.cat === cat);
// Конструктор симуляций (Фаза 7): встроенные + свои/published custom-sims.
const all = CR_SIMS.concat(_crCustomSims || []);
const sims = cat === 'all' ? all : all.filter(s => s.cat === cat);
const esc = v => String(v == null ? '' : v).replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/"/g,'&quot;');
grid.innerHTML = sims.map(s => `
<div class="cr-sim-picker-card" onclick="crPickSim('${s.id}','${s.title.replace(/'/g,'\\\'')}')" title="${s.title}">
<span class="cr-sim-picker-card-cat ${s.cat}">${CAT_LABELS[s.cat] || s.cat}</span>
<span class="cr-sim-picker-card-title">${s.title}</span>
<div class="cr-sim-picker-card" onclick="crPickSim('${String(s.id).replace(/'/g,"\\'")}','${esc(s.title).replace(/'/g,"\\'")}')" title="${esc(s.title)}">
<span class="cr-sim-picker-card-cat ${s.cat}">${s._custom ? 'Моя' : (CAT_LABELS[s.cat] || s.cat)}</span>
<span class="cr-sim-picker-card-title">${esc(s.title)}</span>
</div>
`).join('');
}