import sys, os
src = os.path.join(os.path.dirname(__file__), '../../frontend/lab.html')
with open(src, 'r', encoding='utf-8') as f:
content = f.read()
# ─────────────────────────────────────────────────────────────────────────────
# PATCH 1: Add animated ray buttons + lens-maker controls to lens panel
# Insert BEFORE the Aberrации section
# ─────────────────────────────────────────────────────────────────────────────
OLD_LENS = (
'
Тащи стрелку-предмет или фокус мышью
\n'
' \n'
'
Аберрации
'
)
NEW_LENS = (
'
Тащи стрелку-предмет или фокус мышью
\n'
' \n'
' \n'
'
\n'
' \n'
' \n'
'
\n'
' \n'
'
\n'
' \n'
'
\n'
' \n'
'
\n'
'
\n'
' \n'
' \n'
'
\n'
'
\n'
' \n'
' \n'
'
\n'
'
\n'
' \n'
' \n'
'
\n'
'
f = 1/((n-1)*(1/R1 - 1/R2))
\n'
'
\n'
' \n'
'
Аберрации
'
)
if OLD_LENS not in content:
print('ERROR: lens panel marker not found'); exit(1)
content = content.replace(OLD_LENS, NEW_LENS, 1)
# ─────────────────────────────────────────────────────────────────────────────
# PATCH 2: Add R slider + parabolic toggle to mirror panel
# Insert BEFORE the "Отображение" section
# ─────────────────────────────────────────────────────────────────────────────
OLD_MIRROR = (
'
Отображение
'
)
NEW_MIRROR = (
' \n'
'
\n'
' \n'
'
\n'
'
\n'
' \n'
' \n'
'
\n'
'
\n'
' \n'
'
\n'
'
Отображение
'
)
if OLD_MIRROR not in content:
print('ERROR: mirror panel Отображение marker not found'); exit(1)
content = content.replace(OLD_MIRROR, NEW_MIRROR, 1)
with open(src, 'w', encoding='utf-8') as f:
f.write(content)
print('OK')