auto-sync: 2026-05-13 16:30:01

This commit is contained in:
Stream
2026-05-13 16:30:03 +03:00
parent 03840d3400
commit 7a7ca34609
6 changed files with 173 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 390 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 393 KiB

View File

@@ -0,0 +1,35 @@
#!/bin/bash
set -e
STATIC="/home/slin/enduro-trails/prototype/static"
echo '=== Patching index.html ==='
# 1. Replace terrain button: rename title, change icon to motorcycle wheel
sed -i 's|<button class="map-btn" id="terrain-toggle" onclick="toggleTerrainPopup()" title="Рельеф">|<button class="map-btn" id="terrain-toggle" onclick="toggleTerrainPopup()" title="Эндуро">|' $STATIC/index.html
# 2. Replace mountain icon with motorcycle/enduro icon (simple wheel with spokes)
sed -i 's|<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 20h18"/><path d="m7 20-4-8 5-3 4 6 3-4 5 9"/></svg>|<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="9"/><circle cx="12" cy="12" r="3"/><path d="M12 3v6M12 15v6M3 12h6M15 12h6M5.6 5.6l4.3 4.3M14.1 14.1l4.3 4.3M5.6 18.4l4.3-4.3M14.1 9.9l4.3-4.3"/></svg>|' $STATIC/index.html
# 3. Replace popup title
sed -i 's|<div class="terrain-popup-title">.*</div>|<div class="terrain-popup-title">Эндуро</div>|' $STATIC/index.html
# 4. Add checkboxes for trails before closing </div> of terrain-popup
# First find the line with terrain-tri-cb closing label and add after it
sed -i '/<\/label>/{
# Only do this after terrain-tri-cb
/terrain-tri-cb/!b
a\ <hr style="margin:6px 0;border-color:rgba(128,128,128,0.3)">
a\ <label class="terrain-checkbox">
a\ <input type="checkbox" id="trails-track-cb" onchange="onTrailsCheckbox()" checked>
a\ <span>Грунтовки</span>
a\ </label>
a\ <label class="terrain-checkbox">
a\ <input type="checkbox" id="trails-path-cb" onchange="onTrailsCheckbox()" checked>
a\ <span>Тропы</span>
a\ </label>
}' $STATIC/index.html
echo 'index.html patched'
echo '=== Verifying ==='
sed -n '36,60p' $STATIC/index.html

View File

@@ -0,0 +1,29 @@
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")

View File

@@ -0,0 +1,26 @@
import sys
path = "/home/slin/enduro-trails/prototype/static/index.html"
with open(path, 'r') as f:
lines = f.readlines()
# Insert after line 46 (0-indexed: 45) which is </label> for terrain-tri
insert_after = 45
new_lines = [
' <hr style="margin:6px 0;border-color:rgba(128,128,128,0.3)">\n',
' <label class="terrain-checkbox">\n',
' <input type="checkbox" id="trails-track-cb" onchange="onTrailsCheckbox()" checked>\n',
' <span>Грунтовки</span>\n',
' </label>\n',
' <label class="terrain-checkbox">\n',
' <input type="checkbox" id="trails-path-cb" onchange="onTrailsCheckbox()" checked>\n',
' <span>Тропы</span>\n',
' </label>\n',
]
lines = lines[:insert_after+1] + new_lines + lines[insert_after+1:]
with open(path, 'w') as f:
f.writelines(lines)
print("OK - inserted trails checkboxes")

View File

@@ -0,0 +1,83 @@
import sys
path = "/home/slin/enduro-trails/prototype/static/app.js"
with open(path, 'r') as f:
content = f.read()
# Add onTrailsCheckbox function after onTerrainCheckbox function
js_code = """
function onTrailsCheckbox() {
const map = window._map;
if (!map) return;
const trackChecked = document.getElementById('trails-track-cb').checked;
const pathChecked = document.getElementById('trails-path-cb').checked;
// Save state
localStorage.setItem('trails-track', trackChecked ? '1' : '0');
localStorage.setItem('trails-path', pathChecked ? '1' : '0');
// Toggle layer visibility
if (map.getLayer('trails-track')) {
map.setLayoutProperty('trails-track', 'visibility', trackChecked ? 'visible' : 'none');
}
if (map.getLayer('trails-path-bridleway')) {
map.setLayoutProperty('trails-path-bridleway', 'visibility', pathChecked ? 'visible' : 'none');
}
}
function restoreTrailsState() {
const trackState = localStorage.getItem('trails-track');
const pathState = localStorage.getItem('trails-path');
// Default: both checked (visible)
const trackOn = trackState === null || trackState === '1';
const pathOn = pathState === null || pathState === '1';
const trackCb = document.getElementById('trails-track-cb');
const pathCb = document.getElementById('trails-path-cb');
if (trackCb) trackCb.checked = trackOn;
if (pathCb) pathCb.checked = pathOn;
const map = window._map;
if (map) {
if (map.getLayer('trails-track')) {
map.setLayoutProperty('trails-track', 'visibility', trackOn ? 'visible' : 'none');
}
if (map.getLayer('trails-path-bridleway')) {
map.setLayoutProperty('trails-path-bridleway', 'visibility', pathOn ? 'visible' : 'none');
}
}
}
"""
# Insert after onTerrainCheckbox function (find the closing brace after applyTerrainLayer calls)
# Look for "function applyTerrainLayer" and insert before it
marker = "function applyTerrainLayer("
idx = content.find(marker)
if idx == -1:
print("ERROR: marker not found")
sys.exit(1)
content = content[:idx] + js_code + "\n" + content[idx:]
# Also add restoreTrailsState() call in restoreTerrainState or initTerrain
# Find restoreTerrainState call and add restoreTrailsState after it
restore_marker = "restoreTerrainState();"
# Find the last occurrence (in initTerrain)
last_idx = content.rfind(restore_marker)
if last_idx != -1:
insert_pos = last_idx + len(restore_marker)
content = content[:insert_pos] + "\n restoreTrailsState();" + content[insert_pos:]
# Also after style.load restoreTerrainState
first_idx = content.find(restore_marker)
if first_idx != -1 and first_idx != last_idx:
insert_pos = first_idx + len(restore_marker)
content = content[:insert_pos] + "\n restoreTrailsState();" + content[insert_pos:]
with open(path, 'w') as f:
f.write(content)
print("OK - JS patched")