fix(phys7 ch1): §7 формула цены деления не рендерилась — \dfrac был разорван между $-спанами (единый KaTeX + ре-рендер)

This commit is contained in:
Maxim Dolgolyov
2026-06-01 11:35:00 +03:00
parent c6835cf30c
commit 1a6d4a76c3
+8 -7
View File
@@ -898,8 +898,8 @@ function add_p7(){
+ '<label style="display:block;font-size:.86rem;color:#475569;background:#fff;padding:8px 12px;border-radius:8px;border:1px solid #bae6fd">$N$ (делений): <b id="p7-N" style="color:#0c4a6e;font-family:JetBrains Mono,monospace">10</b><input type="range" id="p7-N-r" min="2" max="50" step="1" value="10" style="display:block;width:100%;margin-top:6px;accent-color:#0284c7"></label>'
+ '</div>'
+ '<div style="background:#e0f2fe;border-radius:9px;padding:12px 14px;font-size:.94rem;line-height:1.7">'
+ 'Цена деления: $C = \\dfrac{X_2 - X_1}{N} = \\dfrac{$<span id="p7-cd2-x2">10</span>$ - $<span id="p7-cd2-x1">0</span>$}{$<span id="p7-cd2-N">10</span>$} = $ <b id="p7-cd2" style="color:#0c4a6e;font-family:JetBrains Mono,monospace">1</b>'
+ '<br>Погрешность: $\\Delta X = C/2 = $ <b id="p7-dx" style="color:#dc2626;font-family:JetBrains Mono,monospace">0,5</b>'
+ 'Цена деления: <span id="p7-cd2-eq" style="color:#0c4a6e"></span>'
+ '<br>Погрешность: <span id="p7-dx-eq" style="color:#dc2626"></span>'
+ '</div>');
/* IV-3: DnD — соедини прибор с подходящей ценой деления */
@@ -981,11 +981,12 @@ function add_p7(){
document.getElementById('p7-x2').textContent = x2;
document.getElementById('p7-N').textContent = N;
const C = (x2 - x1) / N;
document.getElementById('p7-cd2-x1').textContent = x1;
document.getElementById('p7-cd2-x2').textContent = x2;
document.getElementById('p7-cd2-N').textContent = N;
document.getElementById('p7-cd2').textContent = (+C.toPrecision(4)).toString().replace('.', ',');
document.getElementById('p7-dx').textContent = (+(C/2).toPrecision(4)).toString().replace('.', ',');
const Cltx = (+C.toPrecision(4)).toString().replace('.', '{,}');
const dxLtx = (+(C / 2).toPrecision(4)).toString().replace('.', '{,}');
const cdEq = document.getElementById('p7-cd2-eq');
const dxEq = document.getElementById('p7-dx-eq');
if(cdEq){ cdEq.textContent = '$C = \\dfrac{X_2 - X_1}{N} = \\dfrac{' + x2 + ' - ' + x1 + '}{' + N + '} = ' + Cltx + '$'; renderMath(cdEq); }
if(dxEq){ dxEq.textContent = '$\\Delta X = C/2 = ' + dxLtx + '$'; renderMath(dxEq); }
};
['p7-x1-r','p7-x2-r','p7-N-r'].forEach(id => document.getElementById(id).addEventListener('input', updCalc));
updCalc();