fix(textbooks): Физика 9 — STATE collision, KaTeX escape, авто-init симуляций

Три бага из жалобы пользователя:

1) phys9_legacy.js упал с 'Identifier STATE has already been declared' —
   const STATE в монолите конфликтовал с const STATE в chapter inline JS.
   Скрипт extract_phys9_legacy.cjs теперь оборачивает извлечённый код в IIFE
   и явно экспортит через window 70 функций (upd*/draw*/init*/start*/lab*/
   check*/toggle*/render*/show*/...) + 7 const-массивов (TASKS_PN, PUZ_PN).

2) В боковой панели формулы рендерились как 'Delta vecr' вместо Δr⃗ —
   мой переход на JSON.stringify в gen_phys9_ch.js добавил лишний слой
   escape backslash. Уменьшил \\ → \ в SIDEBAR_ROWS, TIPS_HTML,
   PARA_SUBS, LR_SUBS (90 строк). Цепочка теперь: source \Delta → string
   \Delta → JSON "\\Delta" → HTML JS \Delta → runtime \Delta →
   KaTeX \Delta ✓.

3) 'не работают симуляции' — функции из legacy.js были доступны, но
   chapter goTo(id) их не вызывал. Добавлен авто-вызов upd<N>(),
   startAnim<N>(), init<N>(), draw<N>() при переключении на параграф,
   и updLab<N>(), drawLab<N>() — для ЛР.
This commit is contained in:
Maxim Dolgolyov
2026-05-30 09:06:20 +03:00
parent c26423b7d4
commit 66bd7ac1f4
8 changed files with 412 additions and 194 deletions
+64 -7
View File
@@ -1,6 +1,7 @@
// Auto-extracted from frontend/textbooks/physics_9.html (legacy monolith).
// Wrapped in IIFE — avoids collisions with chapter inline JS (STATE, PARAS, etc.).
// Onclick handlers and TASKS_PN arrays explicitly attached to window at end.
// All upd*/draw*/init*/start*/lab*/check*/toggle* functions + TASKS_PN arrays
// are explicitly attached to window at the end.
// eslint-disable
(function(){
@@ -5864,24 +5865,80 @@ if (window.ResizeObserver) {
} catch(e) { console.warn("phys9_legacy setup skipped:", e.message); }
// === Expose onclick handlers + task pools to global scope ===
// === Expose handlers + task pools to global scope ===
try { if (typeof setParaTab !== "undefined") window.setParaTab = setParaTab; } catch(e) {}
try { if (typeof renderNav !== "undefined") window.renderNav = renderNav; } catch(e) {}
try { if (typeof goToTask !== "undefined") window.goToTask = goToTask; } catch(e) {}
try { if (typeof renderTask !== "undefined") window.renderTask = renderTask; } catch(e) {}
try { if (typeof selectMcq !== "undefined") window.selectMcq = selectMcq; } catch(e) {}
try { if (typeof checkNum !== "undefined") window.checkNum = checkNum; } catch(e) {}
try { if (typeof check !== "undefined") window.check = check; } catch(e) {}
try { if (typeof startAnim1 !== "undefined") window.startAnim1 = startAnim1; } catch(e) {}
try { if (typeof upd2 !== "undefined") window.upd2 = upd2; } catch(e) {}
try { if (typeof upd3 !== "undefined") window.upd3 = upd3; } catch(e) {}
try { if (typeof drawArrow3 !== "undefined") window.drawArrow3 = drawArrow3; } catch(e) {}
try { if (typeof upd4 !== "undefined") window.upd4 = upd4; } catch(e) {}
try { if (typeof upd5 !== "undefined") window.upd5 = upd5; } catch(e) {}
try { if (typeof upd6 !== "undefined") window.upd6 = upd6; } catch(e) {}
try { if (typeof upd7 !== "undefined") window.upd7 = upd7; } catch(e) {}
try { if (typeof upd8 !== "undefined") window.upd8 = upd8; } catch(e) {}
try { if (typeof upd9 !== "undefined") window.upd9 = upd9; } catch(e) {}
try { if (typeof upd10 !== "undefined") window.upd10 = upd10; } catch(e) {}
try { if (typeof upd11 !== "undefined") window.upd11 = upd11; } catch(e) {}
try { if (typeof upd12 !== "undefined") window.upd12 = upd12; } catch(e) {}
try { if (typeof upd13 !== "undefined") window.upd13 = upd13; } catch(e) {}
try { if (typeof upd14 !== "undefined") window.upd14 = upd14; } catch(e) {}
try { if (typeof upd16 !== "undefined") window.upd16 = upd16; } catch(e) {}
try { if (typeof upd17 !== "undefined") window.upd17 = upd17; } catch(e) {}
try { if (typeof upd19 !== "undefined") window.upd19 = upd19; } catch(e) {}
try { if (typeof upd20 !== "undefined") window.upd20 = upd20; } catch(e) {}
try { if (typeof upd21 !== "undefined") window.upd21 = upd21; } catch(e) {}
try { if (typeof upd22 !== "undefined") window.upd22 = upd22; } catch(e) {}
try { if (typeof drawAngularThrow22 !== "undefined") window.drawAngularThrow22 = drawAngularThrow22; } catch(e) {}
try { if (typeof upd23 !== "undefined") window.upd23 = upd23; } catch(e) {}
try { if (typeof drawGravity23 !== "undefined") window.drawGravity23 = drawGravity23; } catch(e) {}
try { if (typeof upd24 !== "undefined") window.upd24 = upd24; } catch(e) {}
try { if (typeof drawElevator24 !== "undefined") window.drawElevator24 = drawElevator24; } catch(e) {}
try { if (typeof upd25 !== "undefined") window.upd25 = upd25; } catch(e) {}
try { if (typeof drawSeesaw25 !== "undefined") window.drawSeesaw25 = drawSeesaw25; } catch(e) {}
try { if (typeof upd26 !== "undefined") window.upd26 = upd26; } catch(e) {}
try { if (typeof drawLever26 !== "undefined") window.drawLever26 = drawLever26; } catch(e) {}
try { if (typeof upd27 !== "undefined") window.upd27 = upd27; } catch(e) {}
try { if (typeof upd27mu !== "undefined") window.upd27mu = upd27mu; } catch(e) {}
try { if (typeof drawIncline27 !== "undefined") window.drawIncline27 = drawIncline27; } catch(e) {}
try { if (typeof drawEfficiency27 !== "undefined") window.drawEfficiency27 = drawEfficiency27; } catch(e) {}
try { if (typeof startAnim15 !== "undefined") window.startAnim15 = startAnim15; } catch(e) {}
try { if (typeof initPlanetGrid16 !== "undefined") window.initPlanetGrid16 = initPlanetGrid16; } catch(e) {}
try { if (typeof startAnim17 !== "undefined") window.startAnim17 = startAnim17; } catch(e) {}
try { if (typeof startAnim18 !== "undefined") window.startAnim18 = startAnim18; } catch(e) {}
try { if (typeof drawSpring19 !== "undefined") window.drawSpring19 = drawSpring19; } catch(e) {}
try { if (typeof drawFriction20 !== "undefined") window.drawFriction20 = drawFriction20; } catch(e) {}
try { if (typeof startAnim21 !== "undefined") window.startAnim21 = startAnim21; } catch(e) {}
try { if (typeof upd28 !== "undefined") window.upd28 = upd28; } catch(e) {}
try { if (typeof drawEquilibrium28 !== "undefined") window.drawEquilibrium28 = drawEquilibrium28; } catch(e) {}
try { if (typeof upd29 !== "undefined") window.upd29 = upd29; } catch(e) {}
try { if (typeof drawArchimedes29 !== "undefined") window.drawArchimedes29 = drawArchimedes29; } catch(e) {}
try { if (typeof upd30 !== "undefined") window.upd30 = upd30; } catch(e) {}
try { if (typeof drawShip30 !== "undefined") window.drawShip30 = drawShip30; } catch(e) {}
try { if (typeof upd31 !== "undefined") window.upd31 = upd31; } catch(e) {}
try { if (typeof upd33 !== "undefined") window.upd33 = upd33; } catch(e) {}
try { if (typeof upd34zero !== "undefined") window.upd34zero = upd34zero; } catch(e) {}
try { if (typeof upd34 !== "undefined") window.upd34 = upd34; } catch(e) {}
try { if (typeof upd35 !== "undefined") window.upd35 = upd35; } catch(e) {}
try { if (typeof togglePend36 !== "undefined") window.togglePend36 = togglePend36; } catch(e) {}
try { if (typeof nextTask !== "undefined") window.nextTask = nextTask; } catch(e) {}
try { if (typeof resetTasks !== "undefined") window.resetTasks = resetTasks; } catch(e) {}
try { if (typeof updateScoreBar !== "undefined") window.updateScoreBar = updateScoreBar; } catch(e) {}
try { if (typeof showSummary !== "undefined") window.showSummary = showSummary; } catch(e) {}
try { if (typeof updLab11 !== "undefined") window.updLab11 = updLab11; } catch(e) {}
try { if (typeof drawLab11 !== "undefined") window.drawLab11 = drawLab11; } catch(e) {}
try { if (typeof lab11add !== "undefined") window.lab11add = lab11add; } catch(e) {}
try { if (typeof lab11all !== "undefined") window.lab11all = lab11all; } catch(e) {}
try { if (typeof lab11reset !== "undefined") window.lab11reset = lab11reset; } catch(e) {}
try { if (typeof toggleSuperAns !== "undefined") window.toggleSuperAns = toggleSuperAns; } catch(e) {}
try { if (typeof setParaTab !== "undefined") window.setParaTab = setParaTab; } catch(e) {}
try { if (typeof resetTasks !== "undefined") window.resetTasks = resetTasks; } catch(e) {}
try { if (typeof nextTask !== "undefined") window.nextTask = nextTask; } catch(e) {}
try { if (typeof goToTask !== "undefined") window.goToTask = goToTask; } catch(e) {}
try { if (typeof checkNum !== "undefined") window.checkNum = checkNum; } catch(e) {}
try { if (typeof TASKS_P31 !== "undefined") window.TASKS_P31 = TASKS_P31; } catch(e) {}
try { if (typeof TASKS_P32 !== "undefined") window.TASKS_P32 = TASKS_P32; } catch(e) {}
try { if (typeof TASKS_HARD !== "undefined") window.TASKS_HARD = TASKS_HARD; } catch(e) {}
try { if (typeof TASKS_P33 !== "undefined") window.TASKS_P33 = TASKS_P33; } catch(e) {}
try { if (typeof TASKS_P34 !== "undefined") window.TASKS_P34 = TASKS_P34; } catch(e) {}
try { if (typeof TASKS_P35 !== "undefined") window.TASKS_P35 = TASKS_P35; } catch(e) {}