30 lines
896 B
Python
30 lines
896 B
Python
import sys
|
|
|
|
path = "/home/slin/enduro-trails/prototype/static/app.js"
|
|
with open(path, 'r') as f:
|
|
content = f.read()
|
|
|
|
# Replace the positioning logic
|
|
old = """const rect = btn.getBoundingClientRect();
|
|
popup.style.top = rect.top + 'px';
|
|
popup.style.right = (window.innerWidth - rect.left + 8) + 'px';"""
|
|
|
|
new = """const rect = btn.getBoundingClientRect();
|
|
popup.style.right = (window.innerWidth - rect.left + 8) + 'px';
|
|
// Position: align bottom of popup with bottom of button, ensure fits in viewport
|
|
const popupHeight = popup.offsetHeight;
|
|
const desiredTop = rect.bottom - popupHeight;
|
|
const minTop = 8;
|
|
popup.style.top = Math.max(minTop, desiredTop) + 'px';"""
|
|
|
|
if old not in content:
|
|
print("ERROR: old text not found")
|
|
sys.exit(1)
|
|
|
|
content = content.replace(old, new)
|
|
|
|
with open(path, 'w') as f:
|
|
f.write(content)
|
|
|
|
print("OK - positioning fixed")
|