diff --git a/frontend/js/phys9_legacy.js b/frontend/js/phys9_legacy.js
index be4a32e..d75d4f1 100644
--- a/frontend/js/phys9_legacy.js
+++ b/frontend/js/phys9_legacy.js
@@ -1,9 +1,10 @@
// Auto-extracted from frontend/textbooks/physics_9.html (legacy monolith).
-// Provides global onclick handlers (startAnim1, lab11add, checkNum, etc.).
-// Top-level setup at end of file expects monolith DOM and will throw silently
-// in chapter pages — that is intentional and harmless.
+// Wrapped in IIFE — avoids collisions with chapter inline JS (STATE, PARAS, etc.).
+// Onclick handlers and TASKS_PN arrays explicitly attached to window at end.
// eslint-disable
+(function(){
+"use strict";
// ══════════════════════════════════════════════
// ПУЛЫ ЗАДАЧ
@@ -5807,14 +5808,16 @@ function toggleSuperAns() {
// ТЕМА (день/ночь)
// ══════════════════════════════════════════════
const themeBtn = document.getElementById('themeBtn');
-themeBtn.addEventListener('click', () => {
- const d = document.body.classList.toggle('dark');
- themeBtn.innerHTML = d ? '' : '';
- localStorage.setItem('phys9_theme', d ? '1' : '');
-});
-if (localStorage.getItem('phys9_theme') === '1') {
- document.body.classList.add('dark');
- themeBtn.innerHTML = '';
+if (themeBtn) {
+ themeBtn.addEventListener('click', () => {
+ const d = document.body.classList.toggle('dark');
+ themeBtn.innerHTML = d ? '' : '';
+ localStorage.setItem('phys9_theme', d ? '1' : '');
+ });
+ if (localStorage.getItem('phys9_theme') === '1') {
+ document.body.classList.add('dark');
+ themeBtn.innerHTML = '';
+ }
}
// ══════════════════════════════════════════════
@@ -5822,10 +5825,12 @@ if (localStorage.getItem('phys9_theme') === '1') {
// ══════════════════════════════════════════════
const refToggle = document.getElementById('refToggle');
const refPanel = document.getElementById('refPanel');
-refToggle.addEventListener('click', e => { e.stopPropagation(); refPanel.classList.toggle('show'); });
-document.addEventListener('click', e => {
- if (!refPanel.contains(e.target) && e.target !== refToggle) refPanel.classList.remove('show');
-});
+if (refToggle && refPanel) {
+ refToggle.addEventListener('click', e => { e.stopPropagation(); refPanel.classList.toggle('show'); });
+ document.addEventListener('click', e => {
+ if (!refPanel.contains(e.target) && e.target !== refToggle) refPanel.classList.remove('show');
+ });
+}
// ══════════════════════════════════════════════
// ИНИЦИАЛИЗАЦИЯ
@@ -5856,4 +5861,29 @@ if (window.ResizeObserver) {
if (_cv11) _ro11.observe(_cv11);
}
-} catch(e) { console.warn("phys9_legacy: monolith setup skipped (expected in chapter pages):", e.message); }
+} catch(e) { console.warn("phys9_legacy setup skipped:", e.message); }
+
+
+// === Expose onclick handlers + task pools to global scope ===
+try { if (typeof startAnim1 !== "undefined") window.startAnim1 = startAnim1; } catch(e) {}
+try { if (typeof startAnim15 !== "undefined") window.startAnim15 = startAnim15; } 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 startAnim21 !== "undefined") window.startAnim21 = startAnim21; } catch(e) {}
+try { if (typeof togglePend36 !== "undefined") window.togglePend36 = togglePend36; } 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_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) {}
+try { if (typeof TASKS_P36 !== "undefined") window.TASKS_P36 = TASKS_P36; } catch(e) {}
+})();