refactor: distribute lab-init.js into 34 engine files
lab-init.js: 4098 -> 543 lines (infrastructure + THEORY only) Each sim's _open*() + UI helpers moved to its engine file: graph.js, projectile.js, collision.js, magnetic.js, triangle.js, geometry.js, trigcircle.js, gas.js (molphys), coulomb.js, circuit.js, reactions.js (chemistry), newton.js (dynamics), chemsandbox.js, celldivision.js, photosynthesis.js, angrybirds.js, quadratic.js, normaldist.js, graphtransform.js, pendulum.js, equilibrium.js, thinlens.js, mirror.js, isoprocess.js, titration.js, refraction.js, probability.js, bohratom.js, electrolysis.js, waves.js, crystal.js, orbitals.js, stereo.js, hydrostatics.js All 34 engine files syntax-checked OK.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
'use strict';
|
||||
'use strict';
|
||||
/* ══════════════════════════════════════════════════════════════
|
||||
QuadraticSim — interactive quadratic equation explorer
|
||||
y = ax² + bx + c · discriminant, roots, vertex
|
||||
@@ -432,3 +432,43 @@ class QuadraticSim {
|
||||
cv.addEventListener('touchend', () => { t0 = null; });
|
||||
}
|
||||
}
|
||||
|
||||
/* ─── lab UI init ─────────────────────────────────── */
|
||||
function _openQuadratic() {
|
||||
document.getElementById('sim-topbar-title').textContent = 'Корни квадратного уравнения';
|
||||
_simShow('sim-quadratic');
|
||||
_registerSimState('quadratic', () => quadSim?.getParams(), st => quadSim?.setParams(st));
|
||||
if (_embedMode) _startStateEmit('quadratic');
|
||||
requestAnimationFrame(() => requestAnimationFrame(() => {
|
||||
if (!quadSim) {
|
||||
quadSim = new QuadraticSim(document.getElementById('quadratic-canvas'));
|
||||
quadSim.onUpdate = _quadUpdateUI;
|
||||
}
|
||||
quadSim.fit();
|
||||
quadSim.draw();
|
||||
quadSim._emit();
|
||||
}));
|
||||
}
|
||||
|
||||
function quadParam(name, val) {
|
||||
const v = parseFloat(val);
|
||||
document.getElementById('quad-' + name + '-val').textContent = v % 1 === 0 ? v : v.toFixed(1);
|
||||
if (quadSim) quadSim.setParams({ [name]: v });
|
||||
}
|
||||
|
||||
function quadPreset(a, b, c) {
|
||||
document.getElementById('sl-quad-a').value = a; document.getElementById('quad-a-val').textContent = a;
|
||||
document.getElementById('sl-quad-b').value = b; document.getElementById('quad-b-val').textContent = b;
|
||||
document.getElementById('sl-quad-c').value = c; document.getElementById('quad-c-val').textContent = c;
|
||||
if (quadSim) quadSim.setParams({ a, b, c });
|
||||
}
|
||||
|
||||
function _quadUpdateUI(info) {
|
||||
const v = (id, val) => { const el = document.getElementById(id); if (el) el.textContent = val; };
|
||||
v('qbar-v1', 'D = ' + info.D);
|
||||
v('qbar-v2', info.roots);
|
||||
v('qbar-v3', info.vertex);
|
||||
v('qbar-v4', info.equation);
|
||||
}
|
||||
|
||||
/* ── normal distribution ── */
|
||||
|
||||
Reference in New Issue
Block a user