vercors.me : modes d'étiquette, curseur du temps, coupe altitude, mentions légales, Lans sans capteur vent/pluie

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Cette révision appartient à :
Théo GastineletClaude Sonnet 5.5 a révisé 2026-11-04 10:05:20 +01:00
1 Parent ff42faca16
révision d40201d089
15 fichiers modifiés
+781 -61

Aucun fichier ne correspond à votre recherche

+64
Voir le fichier
@@ -0,0 +1,64 @@
p='modele.html'; s=open(p,encoding='utf-8').read()
def sub(a,b):
global s
assert s.count(a)==1, a[:50]; s=s.replace(a,b)
sub(' <button type="button" id="retour">',' <p class="compte">Compte Gastinel · <span>bientôt</span></p>\n <button type="button" id="retour">')
sub('<section class="liste" id="stations">','''<section class="liste coupe" id="coupe">
<h2>La coupe du massif</h2>
<p id="coupe-txt">Chaque carré est une station : plus il est haut, plus la station est en altitude ; plus il est à gauche, plus il fait froid.</p>
<div id="coupe-svg"></div>
<p class="coupe-lect" id="coupe-lect" aria-live="polite">Survole ou touche une station.</p>
</section>
<section class="liste" id="stations">''')
sub('/* ---------- sous la carte ---------- */','''.compte{margin:10px 0 0;font-size:12px;color:var(--gris)}
.compte span{color:var(--sapin);font-weight:600}
.coupe{padding-bottom:8px}
#coupe-svg svg{width:100%;height:auto;display:block;background:#faf9f5;border:1px solid var(--roche)}
#coupe-svg text{font-family:var(--texte);font-size:11px;fill:var(--gris)}
#coupe-svg .st{cursor:pointer}
#coupe-svg .st rect{stroke:#fff;stroke-width:1.5}
#coupe-svg .st:hover rect,#coupe-svg .st:focus rect,#coupe-svg .st.on rect{stroke:var(--roche);stroke-width:2}
#coupe-svg .st text{fill:var(--roche);font-size:11px;font-weight:600}
.coupe-lect{min-height:1.5em;font-size:14px;color:var(--roche)}
.puce.mis > button{outline:2px solid var(--roche);outline-offset:2px}
/* ---------- sous la carte ---------- */''')
sub("listeStations();\nconst triBtn",'''function coupe(){
const L = Object.entries(STATIONS).filter(([, x]) => x.t != null).map(([id, x]) => ({id, ...x}));
const cible = document.getElementById('coupe-svg');
if (L.length < 3) { cible.innerHTML = ''; return; }
const W = 720, H = 380, g = 52, d = 18, b = 34, h = 14;
const tMin = Math.floor(Math.min(...L.map(x => x.t)) - 1), tMax = Math.ceil(Math.max(...L.map(x => x.t)) + 1);
const aMin = Math.floor(Math.min(...L.map(x => x.alt)) / 250) * 250 - 100, aMax = Math.ceil(Math.max(...L.map(x => x.alt)) / 250) * 250 + 100;
const X = t => g + (t - tMin) / (tMax - tMin) * (W - g - d), Y = a => H - b - (a - aMin) / (aMax - aMin) * (H - b - h);
const pas = (tMax - tMin) > 14 ? 5 : 2;
let o = '';
for (let t = Math.ceil(tMin / pas) * pas; t <= tMax; t += pas) o += `<line x1="${X(t)}" x2="${X(t)}" y1="${h}" y2="${H - b}" stroke="#e4e0d6"/><text x="${X(t)}" y="${H - b + 16}" text-anchor="middle">${t}°</text>`;
for (let a = Math.ceil(aMin / 500) * 500; a <= aMax; a += 500) o += `<line x1="${g}" x2="${W - d}" y1="${Y(a)}" y2="${Y(a)}" stroke="#e4e0d6"/><text x="${g - 6}" y="${Y(a) + 4}" text-anchor="end">${a} m</text>`;
// atmosphère standard : −0,65 °C par 100 m, depuis la station la plus basse
const bas = L.reduce((a, c) => c.alt < a.alt ? c : a);
const tAt = a => bas.t - 0.0065 * (a - bas.alt);
o += `<line x1="${X(tAt(aMin))}" y1="${Y(aMin)}" x2="${X(tAt(aMax))}" y2="${Y(aMax)}" stroke="#6f8f5c" stroke-width="1.5" stroke-dasharray="5 4"/><text x="${X(tAt(aMax)) + 6}" y="${Y(aMax) + 12}" style="fill:#6f8f5c">refroidissement normal</text>`;
const ext = new Set([L.reduce((a, c) => c.t < a.t ? c : a).id, L.reduce((a, c) => c.t > a.t ? c : a).id, L.reduce((a, c) => c.alt > a.alt ? c : a).id, bas.id]);
L.sort((a, c) => a.alt - c.alt).forEach(x => {
o += `<g class="st" tabindex="0" data-id="${x.id}" role="button" aria-label="${x.nom}, ${x.alt} mètres, ${fmt(x.t)}"><rect x="${X(x.t) - 6}" y="${Y(x.alt) - 6}" width="12" height="12" fill="${couleur(x.t)}"/>${ext.has(x.id) ? `<text x="${X(x.t) + 10}" y="${Y(x.alt) + 4}">${NOMS[x.id] || court(x.nom)}</text>` : ''}</g>`;
});
cible.innerHTML = `<svg viewBox="0 0 ${W} ${H}" role="img" aria-label="Température des stations selon l'altitude">${o}</svg>`;
// inversion : corrélation entre altitude et température
const n = L.length, ma = L.reduce((a, c) => a + c.alt, 0) / n, mt = L.reduce((a, c) => a + c.t, 0) / n;
const pente = L.reduce((a, c) => a + (c.alt - ma) * (c.t - mt), 0) / L.reduce((a, c) => a + (c.alt - ma) ** 2, 0) * 100;
document.getElementById('coupe-txt').textContent = pente > 0
? `Inversion : en ce moment, il fait plus chaud en altitude (${nb1(pente)} °C de plus tous les 100 m en moyenne). Les combes sont les plus froides.`
: `Ce matin, la température baisse de ${nb1(-pente)} °C tous les 100 m en moyenne ; la ligne verte montre le refroidissement normal (0,65 °C).`;
}
function surlignerCarte(id, oui){ puces.forEach(q => q.m.classList.toggle('mis', oui && q.ids.includes(id))); }
const coupeSvg = document.getElementById('coupe-svg'), coupeLect = document.getElementById('coupe-lect');
const lectureCoupe = id => { const x = STATIONS[id]; coupeLect.textContent = `${x.nom} · ${x.alt} m · ${fmt(x.t)}`; };
coupeSvg.addEventListener('mouseover', ev => { const g = ev.target.closest('.st'); if (g) { lectureCoupe(g.dataset.id); surlignerCarte(g.dataset.id, true); } });
coupeSvg.addEventListener('mouseout', ev => { if (ev.target.closest('.st')) surlignerCarte('', false); });
coupeSvg.addEventListener('focusin', ev => { const g = ev.target.closest('.st'); if (g) { lectureCoupe(g.dataset.id); surlignerCarte(g.dataset.id, true); } });
coupeSvg.addEventListener('focusout', () => surlignerCarte('', false));
coupeSvg.addEventListener('click', ev => { const g = ev.target.closest('.st'); if (g) { lectureCoupe(g.dataset.id); ouvrirPlein([g.dataset.id], g.dataset.id); } });
listeStations();
const triBtn''')
sub("phraseDuJour(); listeStations(); disposer();","phraseDuJour(); listeStations(); coupe(); disposer();")
open(p,'w',encoding='utf-8').write(s)