Rafraîchir le conseil au changement de carburant

This commit is contained in:
Hermes Agent
2026-09-12 19:51:34 +02:00
parent 0c16962725
commit 48ab7af525

5
app.py
View File

@@ -68,8 +68,9 @@ INDEX_HTML = """<!doctype html>
<div class="card" id="result"><div class="muted">Aucun calcul pour l’instant.</div></div>
</section><div class="footer">Données : prix-carburants.gouv.fr, flux marché/RSS best-effort, aucune position persistée côté navigateur.</div>
</main><script>
const fuels = %FUEL_TYPES%; const fuelSel=document.getElementById('fuel'); fuels.forEach(f=>{const o=document.createElement('option');o.value=f;o.textContent=f; if(f==='%DEFAULT_FUEL%') o.selected=true; fuelSel.appendChild(o)});
const fuels = %FUEL_TYPES%; const fuelSel=document.getElementById('fuel'); let lastCoords=null; fuels.forEach(f=>{const o=document.createElement('option');o.value=f;o.textContent=f; if(f==='%DEFAULT_FUEL%') o.selected=true; fuelSel.appendChild(o)});
async function advise(lat, lon){
lastCoords={lat,lon};
document.getElementById('place').value = lat.toFixed(4)+', '+lon.toFixed(4);
const radius=document.getElementById('radius').value || 15, fuel=fuelSel.value;
document.getElementById('status').textContent='Collecte des prix et calcul en cours…';
@@ -95,6 +96,8 @@ async function geocode(){
document.getElementById('locate').onclick=()=>navigator.geolocation.getCurrentPosition(p=>advise(p.coords.latitude,p.coords.longitude),e=>document.getElementById('status').textContent='Géolocalisation refusée/HTTP non sécurisé. Saisis une ville ou adresse puis clique Chercher adresse.',{enableHighAccuracy:true,timeout:12000});
document.getElementById('search').onclick=geocode;
document.getElementById('place').addEventListener('keydown', e=>{if(e.key==='Enter') geocode()});
fuelSel.addEventListener('change', ()=>{ if(lastCoords) advise(lastCoords.lat,lastCoords.lon); });
document.getElementById('radius').addEventListener('change', ()=>{ if(lastCoords) advise(lastCoords.lat,lastCoords.lon); });
document.getElementById('demo').onclick=()=>advise(48.8566,2.3522);
</script></body></html>"""