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 à :
1 Parent
ff42faca16
révision
d40201d089
15 fichiers modifiés
+781
-61
Aucun fichier ne correspond à votre recherche
@@ -130,6 +130,8 @@ a{color:inherit}
|
||||
.plein-onglets button.on{background:var(--roche);color:#fff}
|
||||
.plein-corps{max-width:980px;margin:0 auto;padding:20px 16px 64px}
|
||||
.plein-corps h2{margin:0;font-family:var(--titre);font-weight:600;font-size:26px;line-height:1.15;color:var(--sapin)}
|
||||
.origine{display:inline-flex;flex-direction:column;vertical-align:middle;margin-left:12px;padding:3px 9px;border:1px solid var(--glacier);background:rgba(110,181,189,.14);color:#2f6f78;font-family:var(--texte,inherit);font-size:12px;font-weight:500;line-height:1.25}
|
||||
.origine small{font-size:11px;font-weight:400;color:var(--gris)}
|
||||
.plein-sous{margin:4px 0 0;font-size:13px;color:var(--gris)}
|
||||
.plein-val{display:flex;align-items:baseline;gap:14px;flex-wrap:wrap;margin-top:14px;padding-top:12px;border-top:1px solid var(--pierre)}
|
||||
.plein-val b{font-family:var(--titre);font-weight:600;font-size:52px;line-height:1;letter-spacing:-.01em}
|
||||
@@ -164,7 +166,7 @@ a{color:inherit}
|
||||
.pendule .corde.g{left:18%}.pendule .corde.d{right:18%}
|
||||
.pancarte{display:block;white-space:nowrap;background:#faf9f5;border:1px solid var(--roche);padding:5px 11px 6px;
|
||||
font-size:11px;font-weight:600;letter-spacing:.1em;text-transform:uppercase;color:var(--sapin)}
|
||||
.outils{display:flex;gap:8px;margin-top:12px}
|
||||
.outils{display:flex;flex-wrap:wrap;gap:8px;margin-top:12px}
|
||||
.rech{position:relative;flex:1;min-width:0}
|
||||
#rech{width:100%;font:inherit;font-size:13.5px;color:var(--roche);background:#fff;border:1px solid var(--roche);border-radius:0;padding:7px 9px;-webkit-appearance:none;appearance:none}
|
||||
#rech::placeholder{color:#8a8f88}
|
||||
@@ -173,11 +175,22 @@ a{color:inherit}
|
||||
#rech-res li:first-child{border-top:0}
|
||||
#rech-res li.on,#rech-res li:hover{background:#eef2ea}
|
||||
#rech-res small{color:var(--gris);margin-left:6px}
|
||||
#filtre{font:inherit;font-size:11.5px;font-weight:600;letter-spacing:.08em;text-transform:uppercase;color:var(--sapin);background:#fff;border:1px solid var(--sapin);border-radius:0;padding:7px 9px;cursor:pointer;white-space:nowrap}
|
||||
#filtre[aria-pressed=true]{background:var(--sapin);color:#fff}
|
||||
.carte.filtre .puce > button.sans{opacity:.2}
|
||||
.reglages{max-width:1080px;margin:0 auto;padding:10px 28px 0;display:flex;flex-wrap:wrap;gap:10px 22px;align-items:center}
|
||||
.modes{display:flex;flex:0 0 auto}
|
||||
.aide{flex:0 0 100%;margin:0;font-size:11.5px;color:var(--gris)}
|
||||
.temps{flex:1 1 300px;display:flex;align-items:center;gap:10px;min-width:0}
|
||||
.temps button{font:inherit;font-size:13px;color:var(--sapin);background:#fff;border:1px solid var(--sapin);border-radius:0;width:34px;height:31px;cursor:pointer;padding:0}
|
||||
.temps button:disabled{opacity:.4;cursor:default}
|
||||
.temps input{flex:1;min-width:0;accent-color:var(--sapin);height:24px}
|
||||
.temps output{font-size:12.5px;color:var(--gris);min-width:112px;text-align:right}
|
||||
.temps.passe output{color:var(--chaud);font-weight:600}
|
||||
@media (max-width:719px){.reglages{padding:10px 16px 0}.temps{flex:1 1 100%;flex-wrap:wrap}.temps input{flex:1 1 140px}.temps output{min-width:0;flex:0 0 100%;text-align:left;order:3}}
|
||||
.modes button{flex:none;font:inherit;font-size:11.5px;font-weight:600;letter-spacing:.08em;text-transform:uppercase;color:var(--sapin);background:#fff;border:1px solid var(--sapin);border-radius:0;margin-left:-1px;padding:7px 14px;cursor:pointer;white-space:nowrap}
|
||||
.modes button:first-child{margin-left:0}
|
||||
.modes button[aria-pressed=true]{background:var(--sapin);color:#fff}
|
||||
.modes button[data-tri="2"][aria-pressed=true]{background:#000;border-color:#000}
|
||||
.puce.horsmode{display:none}
|
||||
.puce .ics{display:none;margin-left:6px;vertical-align:1px}
|
||||
.carte.filtre .puce .ics{display:inline}
|
||||
a:focus-visible,button:focus-visible,input:focus-visible{outline:2px solid var(--sapin);outline-offset:2px}
|
||||
.vieux{color:var(--chaud)!important}
|
||||
#retour{display:none;margin-top:12px;font:inherit;font-size:12px;font-weight:600;letter-spacing:.1em;text-transform:uppercase;background:var(--sapin);color:#fff;border:0;border-radius:0;padding:7px 10px;cursor:pointer}
|
||||
@@ -200,6 +213,18 @@ a:focus-visible,button:focus-visible,input:focus-visible{outline:2px solid var(-
|
||||
background-repeat:no-repeat;-webkit-backdrop-filter:blur(8px) saturate(1.2);backdrop-filter:blur(8px) saturate(1.2);transition:background-color .15s}
|
||||
.suite:hover{background-color:rgba(255,255,255,.75)}
|
||||
|
||||
.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)}
|
||||
@media (max-width:719px){#coupe-svg text{font-size:10.5px}}
|
||||
#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 ---------- */
|
||||
.liste{max-width:1080px;margin:0 auto;padding:56px 28px 32px}
|
||||
.liste h2{font-family:var(--titre);font-weight:600;font-size:28px;margin:0 0 4px;color:var(--sapin)}
|
||||
@@ -244,6 +269,12 @@ a:focus-visible,button:focus-visible,input:focus-visible{outline:2px solid var(-
|
||||
.pied{padding:18px 16px 36px}
|
||||
.sous-carte{padding:8px 16px 0}
|
||||
}
|
||||
.sanscookie{position:fixed;left:16px;bottom:16px;z-index:60;max-width:340px;padding:10px 34px 10px 14px;background:var(--calcaire);border:1px solid var(--sapin);box-shadow:0 0 0 3px var(--calcaire),0 0 0 4px var(--pierre);color:var(--roche);font-family:var(--texte);transition:opacity .5s}
|
||||
.sanscookie.parti{opacity:0;pointer-events:none}
|
||||
.sanscookie b{display:block;font-family:var(--titre);font-weight:600;font-size:15px;color:var(--sapin)}
|
||||
.sanscookie span{font-size:12.5px;color:var(--gris)}
|
||||
.sanscookie button{position:absolute;top:2px;right:4px;border:0;background:none;font-size:20px;line-height:1;color:var(--gris);cursor:pointer;padding:4px 6px}
|
||||
@media (prefers-reduced-motion:reduce){.sanscookie{transition:none}}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -261,8 +292,9 @@ a:focus-visible,button:focus-visible,input:focus-visible{outline:2px solid var(-
|
||||
<p class="reseau" id="reseau"></p>
|
||||
<div class="outils" id="outils">
|
||||
<div class="rech"><input type="search" id="rech" placeholder="Une station, un village…" autocomplete="off" aria-label="Chercher une station ou un village"><ul id="rech-res" hidden></ul></div>
|
||||
<button type="button" id="filtre" aria-pressed="false" title="Montrer les stations qui mesurent le vent ou la pluie">Vent · pluie</button>
|
||||
|
||||
</div>
|
||||
<p class="compte">Compte Gastinel · <span>bientôt</span></p>
|
||||
<button type="button" id="retour">← Tout le massif</button>
|
||||
<div class="pendule" id="pendule" aria-live="polite"><i class="corde g"></i><i class="corde d"></i>
|
||||
<span class="pancarte" id="direct">Relevés en cours…</span></div>
|
||||
@@ -276,6 +308,16 @@ a:focus-visible,button:focus-visible,input:focus-visible{outline:2px solid var(-
|
||||
</main>
|
||||
|
||||
<p class="sous-carte">Courbes de niveau tous les 100 m · molette sur le Parc ou deux doigts pour zoomer</p>
|
||||
<div class="reglages" id="reglages"><div class="modes" id="modes" role="group" aria-label="Valeur affichée sur les étiquettes"><button type="button" data-mode="t" aria-pressed="true">Temp</button><button type="button" data-mode="alt" aria-pressed="false" title="Classe la liste par altitude : un clic croissant, un deuxième clic décroissant">Alt</button><button type="button" data-mode="vent" aria-pressed="false" title="Seules les stations qui mesurent le vent">Vent</button><button type="button" data-mode="pluie" aria-pressed="false" title="Seules les stations qui mesurent la pluie">Pluie</button></div>
|
||||
<div class="temps" id="temps"><button type="button" id="lecture" aria-label="Rejouer les dernières 24 heures" disabled>▶</button><input type="range" id="curseur" min="0" max="0" step="1" value="0" disabled aria-label="Remonter le temps, sept jours"><output id="temps-txt" for="curseur">Maintenant</output></div>
|
||||
<p class="aide">Ces choix valent aussi pour la liste des stations, plus bas.</p>
|
||||
</div>
|
||||
<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">
|
||||
<h2>Les stations</h2>
|
||||
<p>Toutes les stations du massif, du nord au sud. Sur la carte : une valeur par village ou par site ; le détail ici.</p>
|
||||
@@ -336,6 +378,17 @@ const GROUPES = [
|
||||
{nom:'Marignac', st:['marignac'], sect:'Diois'},
|
||||
{nom:'Solaure', st:['solaure'], sect:'Diois'},
|
||||
];
|
||||
// Propriétaire des stations « de chez nous » ; 'dispo' = où l'on retrouve aussi la station (jamais Infoclimat en premier)
|
||||
const PROPRIO = {lans:'Station Gastinel', moucherolle:'Station Gastinel',
|
||||
geve:'Station Richard Gastinel', allieres:'Station Richard Gastinel', bruyeres:'Station Richard Gastinel',
|
||||
darbounouse:'Station Richard Gastinel', oscence:'Station Richard Gastinel'};
|
||||
const DISPO = ['WeatherLink', 'ROMMA', 'Infoclimat'];
|
||||
function origine(id){
|
||||
const s = STATIONS[id], p = PROPRIO[id];
|
||||
if (p) return {titre: p, aussi: 'Aussi consultable sur ' + DISPO.join(' · ')};
|
||||
const src = s.src || '';
|
||||
return {titre: src ? 'Vient ' + (/^[AEIOUÉ]/i.test(src) ? "d'" : 'de ') + src : '', aussi: ''};
|
||||
}
|
||||
const MASSIF = [5.06, 45.305, 5.835, 44.635]; // ouest, nord, est, sud : tout le Parc (limite IGN)
|
||||
// Une puce par station : la 1re station d'un groupe porte le nom du village et passe en priorité ;
|
||||
// les autres viennent après, elles rejoignent la puce du village tant que la place manque.
|
||||
@@ -424,14 +477,22 @@ document.addEventListener('click', fermer);
|
||||
carte.addEventListener('touchmove', ev => { if (ev.touches.length > 1) ev.preventDefault(); }, {passive: false});
|
||||
carte.addEventListener('gesturestart', ev => ev.preventDefault());
|
||||
|
||||
let MODE = 't'; // t, alt, vent, pluie
|
||||
function valMode(r){
|
||||
return MODE === 'alt' ? [`${r.alt} m`, 'var(--sapin)']
|
||||
: MODE === 'vent' ? [r.vent == null ? '—' : `${Math.round(r.vent)} km/h`, '#3d6f8e']
|
||||
: MODE === 'pluie' ? [r.pluie == null ? '—' : `${nb1(r.pluie)} mm`, '#3d6f8e'] : [fmt(r.t), couleur(r.t)];
|
||||
}
|
||||
const capteur = (id, m) => m === 'vent' ? !!(SEM[id] && SEM[id].vent) : m === 'pluie' ? !!(SEM[id] && SEM[id].pluie) : true;
|
||||
const nb1 = v => v == null ? '—' : String(Math.round(v * 10) / 10).replace('.', ',');
|
||||
// contenu d'une puce : ses stations propres + celles qu'elle a absorbées faute de place
|
||||
function remplir(p){
|
||||
const st = p.ids.map(id => ({id, ...STATIONS[id]})), r = st.find(x => x.t != null) || st[0];
|
||||
const st = p.ids.map(id => ({id, ...STATIONS[id]})), pool = st.filter(x => capteur(x.id, MODE)), r = pool.find(x => x.t != null) || pool[0] || st.find(x => x.t != null) || st[0];
|
||||
const autres = st.length - 1;
|
||||
p.b.classList.toggle('ex', !!r.exemple); p.b.classList.toggle('hl', !!r.horsLigne);
|
||||
const cap = st.some(x => SEM[x.id] && SEM[x.id].pluie), vent = st.some(x => SEM[x.id] && SEM[x.id].vent);
|
||||
p.b.classList.toggle('sans', !cap && !vent);
|
||||
const hb = `<span class="val" style="color:${couleur(r.t)}">${fmt(r.t)}</span>${autres ? `<span class="n">+${autres}</span>` : ''}<span class="nom">${p.titre}<span class="ics">${cap ? IC_GOUTTE : ''}${vent ? IC_EOLIENNE : ''}</span></span>`;
|
||||
const vm = valMode(r);
|
||||
const hb = `<span class="val" style="color:${vm[1]}">${vm[0]}</span>${autres ? `<span class="n">+${autres}</span>` : ''}<span class="nom">${p.titre}<span class="ics">${cap ? IC_GOUTTE : ''}${vent ? IC_EOLIENNE : ''}</span></span>`;
|
||||
const hf = `<h3>${p.titre}${p.absorbe ? ' et alentours' : ''}</h3><ul>${st.map((s, i) => `<li style="--i:${i}"><span>${s.nom}</span><b style="color:${couleur(s.t)}">${fmt(s.t)}</b>
|
||||
<em>${icones(s.id)}${s.alt} m · ${s.src}${s.licence ? ` (${s.licence})` : ''}${s.exemple ? ' · pas de données en direct' : s.horsLigne ? ' · hors ligne' : ''}${s.mn != null ? ` · 24 h : ${fmt(s.mn)} / ${fmt(s.mx)}` : ''}</em></li>`).join('')}</ul>` +
|
||||
`<div class="actions"><button type="button" class="pleinbtn">Ouvrir en plein écran →</button>${p.mini ? '' : '<button type="button" class="zoom">Zoomer sur ce secteur →</button>'}</div>`;
|
||||
@@ -682,19 +743,28 @@ function disposer(){
|
||||
const extremes = new Set(vivantes.length ? [
|
||||
vivantes.reduce((a, b) => STATIONS[a.g.st[0]].t <= STATIONS[b.g.st[0]].t ? a : b),
|
||||
vivantes.reduce((a, b) => STATIONS[a.g.st[0]].t >= STATIONS[b.g.st[0]].t ? a : b)] : []);
|
||||
const pointsAutres = puces.filter(q => !q.force && (MODE === 't' || MODE === 'alt' || q.ids.some(id => capteur(id, MODE)))).map(q => {
|
||||
const [px, py] = ecran(q.xy);
|
||||
return {p: q, r: {left: r0.left + px - 6, right: r0.left + px + 6, top: r0.top + py - 6, bottom: r0.top + py + 6}};
|
||||
});
|
||||
[...extremes, ...puces.filter(p => !extremes.has(p))].forEach(p => {
|
||||
const [x, y] = ecran(p.xy);
|
||||
p.x = x; p.y = y;
|
||||
p.m.style.left = x + 'px'; p.m.style.top = y + 'px';
|
||||
if (MODE === 'vent' || MODE === 'pluie') { if (!p.ids.some(id => capteur(id, MODE))) { p.m.classList.add('cache'); return; } p.m.classList.remove('cache'); }
|
||||
if (p.force) { p.etat = 'dans'; p.dans = p.force; p.m.classList.add('cache'); return; }
|
||||
remplir(p);
|
||||
const bw = p.b.offsetWidth, bh = p.b.offsetHeight;
|
||||
const essais = [[-bw / 2, -bh - 12], [-bw / 2, 12], [14, -bh / 2], [-bw - 14, -bh / 2], [12, -bh - 8], [-bw - 12, -bh - 8]];
|
||||
let choix = null;
|
||||
for (const [dx, dy] of essais) {
|
||||
const r = {left: r0.left + x + dx, top: r0.top + y + dy, right: r0.left + x + dx + bw, bottom: r0.top + y + dy + bh};
|
||||
const m = {left: r.left - 3, right: r.right + 3, top: r.top - 3, bottom: r.bottom + 3}; // 3 px d'air entre étiquettes
|
||||
if (dedans(r) && !interdits.some(z => chevauche(m, z)) && !posees.some(q => chevauche(m, q.r))) { choix = {dx, dy, r}; break; }
|
||||
for (const strict of [true, false]) {
|
||||
for (const [dx, dy] of essais) {
|
||||
const r = {left: r0.left + x + dx, top: r0.top + y + dy, right: r0.left + x + dx + bw, bottom: r0.top + y + dy + bh};
|
||||
const m = {left: r.left - 3, right: r.right + 3, top: r.top - 3, bottom: r.bottom + 3}; // 3 px d'air entre étiquettes
|
||||
if (dedans(r) && !interdits.some(z => chevauche(m, z)) && !posees.some(q => chevauche(m, q.r))
|
||||
&& !(strict && pointsAutres.some(z => z.p !== p && chevauche(r, z.r)))) { choix = {dx, dy, r}; break; }
|
||||
}
|
||||
if (choix) break;
|
||||
}
|
||||
if (!choix) {
|
||||
// pas de place : la station rejoint la puce posée la plus proche
|
||||
@@ -764,15 +834,60 @@ function disposer(){
|
||||
}
|
||||
|
||||
// liste sous la carte, par secteur
|
||||
let TRI = 0; // 0 par secteur, 1 altitude croissante, 2 décroissante
|
||||
function listeStations(){
|
||||
const carteCase = id => {
|
||||
const s = STATIONS[id], vm = valMode(s);
|
||||
return `<button type="button" class="case${s.exemple ? ' ex' : ''}" data-id="${id}"><small>${s.alt} m · ${s.src}${s.exemple ? ' · pas de données' : s.horsLigne ? ' · hors ligne' : ''}</small><strong>${s.nom}</strong><b style="color:${vm[1]}">${vm[0]}</b></button>`;
|
||||
};
|
||||
if (TRI) {
|
||||
const ids = GROUPES.flatMap(g => g.st).filter(id => capteur(id, MODE)).sort((a, b) => (STATIONS[a].alt - STATIONS[b].alt) * (TRI === 1 ? 1 : -1));
|
||||
document.getElementById('secteurs').innerHTML = `<div class="grille">${ids.map(carteCase).join('')}</div>`;
|
||||
return;
|
||||
}
|
||||
const sects = {};
|
||||
GROUPES.forEach(g => g.st.forEach(id => (sects[g.sect] ||= []).push(id)));
|
||||
const ordre = ['Quatre-Montagnes', 'Hauts-Plateaux et Vercors drômois', 'Trièves et Gresse', 'Royans', 'Diois'];
|
||||
document.getElementById('secteurs').innerHTML = ordre.map(n => `<h3>${n}</h3><div class="grille">${sects[n].map(id => {
|
||||
const s = STATIONS[id];
|
||||
return `<button type="button" class="case${s.exemple ? ' ex' : ''}" data-id="${id}"><small>${s.alt} m · ${s.src}${s.exemple ? ' · pas de données' : s.horsLigne ? ' · hors ligne' : ''}</small><strong>${s.nom}</strong><b style="color:${couleur(s.t)}">${fmt(s.t)}</b></button>`;
|
||||
}).join('')}</div>`).join('');
|
||||
document.getElementById('secteurs').innerHTML = ordre.map(n => { const l = sects[n].filter(id => capteur(id, MODE)); return l.length ? `<h3>${n}</h3><div class="grille">${l.map(carteCase).join('')}</div>` : ''; }).join('');
|
||||
}
|
||||
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 = Math.max(300, Math.min(720, cible.clientWidth || 720)), H = W < 500 ? 330 : 380, g = W < 500 ? 46 : 52, d = 14, b = 30, h = 12;
|
||||
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="${g + 6}" y="${H - b - 8}" 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) + (X(x.t) > W - 130 ? -10 : 10)}" y="${Y(x.alt) + 4}" text-anchor="${X(x.t) > W - 130 ? 'end' : 'start'}">${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 = Math.abs(pente) < 0.15 ? 'En ce moment, il fait presque la même température à toutes les altitudes : pas d’inversion, pas de refroidissement net.' : 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.`
|
||||
: `La température baisse de ${nb1(-pente)} °C tous les 100 m en moyenne ; la ligne verte montre le refroidissement normal (0,65 °C).`;
|
||||
}
|
||||
let largeurCoupe = 0;
|
||||
addEventListener('resize', () => { const w = document.getElementById('coupe-svg').clientWidth; if (w !== largeurCoupe) { largeurCoupe = w; coupe(); } });
|
||||
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();
|
||||
document.getElementById('secteurs').addEventListener('click', ev => {
|
||||
const c = ev.target.closest('.case'); if (c && STATIONS[c.dataset.id]) ouvrirPlein([c.dataset.id], c.dataset.id);
|
||||
@@ -840,18 +955,81 @@ rech.addEventListener('keydown', ev => {
|
||||
});
|
||||
resultats.addEventListener('mousedown', ev => { const li = ev.target.closest('li'); if (li) { ev.preventDefault(); allerA(RECH[+li.dataset.i]); } });
|
||||
rech.addEventListener('blur', () => setTimeout(() => { resultats.hidden = true; }, 120));
|
||||
const filtre = document.getElementById('filtre');
|
||||
filtre.addEventListener('click', () => { const on = filtre.getAttribute('aria-pressed') !== 'true'; filtre.setAttribute('aria-pressed', on); carte.classList.toggle('filtre', on); relancer(); });
|
||||
['rech', 'filtre'].forEach(i => document.getElementById(i).addEventListener('click', ev => ev.stopPropagation()));
|
||||
const modes = document.getElementById('modes');
|
||||
modes.addEventListener('click', ev => {
|
||||
const b = ev.target.closest('button'); if (!b) return;
|
||||
const m = b.dataset.mode;
|
||||
TRI = m !== 'alt' ? 0 : MODE === 'alt' ? (TRI === 1 ? 2 : 1) : 1;
|
||||
MODE = m;
|
||||
const alt = modes.querySelector('[data-mode=alt]'); alt.dataset.tri = TRI; alt.textContent = ['Alt', 'Alt ↑', 'Alt ↓'][TRI];
|
||||
modes.querySelectorAll('button').forEach(x => x.setAttribute('aria-pressed', x === b));
|
||||
puces.forEach(q => { q.hb = null; });
|
||||
listeStations();
|
||||
disposer(); relancer();
|
||||
});
|
||||
// ----- curseur du temps -----
|
||||
let SERIES = null, TEMPS = null, LIVE = null, T0 = 0, N = 0, lectureId = null, majAttente = false, chargeSeries = null;
|
||||
const curseur = document.getElementById('curseur'), tempsBox = document.getElementById('temps'), tempsTxt = document.getElementById('temps-txt'), btnLecture = document.getElementById('lecture');
|
||||
function chargerSeries(){
|
||||
if (chargeSeries) return chargeSeries;
|
||||
chargeSeries = Promise.all(Object.keys(STATIONS).map(id => fetch(`data/semaine/${id}.json?${Math.floor(Date.now() / 300000)}`).then(r => r.ok ? r.json() : null).catch(() => null))).then(rs => {
|
||||
SERIES = {}; let a = Infinity, b = 0;
|
||||
rs.forEach(d => { if (!d || !d.t) return; SERIES[d.id] = d; a = Math.min(a, d.archive_depuis || d.debut); b = Math.max(b, d.debut + (d.t.length - 1) * d.pas); });
|
||||
if (!isFinite(a) || b <= a) return;
|
||||
const fin = Math.floor(b / 1800) * 1800, deb = Math.max(Math.ceil(a / 1800) * 1800, fin - 7 * 86400);
|
||||
T0 = deb; N = (fin - deb) / 1800;
|
||||
curseur.max = N; curseur.value = N; curseur.disabled = false; btnLecture.disabled = false;
|
||||
});
|
||||
return chargeSeries;
|
||||
}
|
||||
function valeurA(id, ts, k){
|
||||
const d = SERIES && SERIES[id]; if (!d) return null;
|
||||
const i = Math.round((ts - d.debut) / d.pas); if (i < 0 || i >= d.t.length) return null;
|
||||
const v = d[k][i]; return v == null ? null : v;
|
||||
}
|
||||
function snapshotLive(){ LIVE = {}; Object.entries(STATIONS).forEach(([id, x]) => { LIVE[id] = {t: x.t, vent: x.vent, pluie: x.pluie, mn: x.mn, mx: x.mx}; }); }
|
||||
function appliquerTemps(){
|
||||
if (TEMPS == null || !LIVE) return;
|
||||
Object.entries(STATIONS).forEach(([id, x]) => Object.assign(x, {t: valeurA(id, TEMPS, 't'), vent: valeurA(id, TEMPS, 'v'), pluie: valeurA(id, TEMPS, 'r'), mn: null, mx: null}));
|
||||
}
|
||||
function rafraichirTemps(){
|
||||
if (majAttente) return; majAttente = true;
|
||||
setTimeout(() => { majAttente = false; puces.forEach(q => { q.hb = null; }); disposer(); relancer(); listeStations(); coupe(); }, 30);
|
||||
}
|
||||
function poserTemps(){
|
||||
const v = +curseur.value;
|
||||
if (v >= N) { // retour au direct
|
||||
if (TEMPS != null && LIVE) Object.entries(LIVE).forEach(([id, x]) => Object.assign(STATIONS[id], x));
|
||||
TEMPS = null; tempsBox.classList.remove('passe'); tempsTxt.textContent = 'Maintenant';
|
||||
} else {
|
||||
if (TEMPS == null) snapshotLive();
|
||||
TEMPS = T0 + v * 1800; tempsBox.classList.add('passe');
|
||||
tempsTxt.textContent = fmtJH.format(new Date(TEMPS * 1000)).replace(',', '');
|
||||
appliquerTemps();
|
||||
}
|
||||
rafraichirTemps();
|
||||
}
|
||||
function arreterLecture(){ if (lectureId) { clearInterval(lectureId); lectureId = null; } btnLecture.textContent = '▶'; btnLecture.setAttribute('aria-label', 'Rejouer les dernières 24 heures'); }
|
||||
curseur.addEventListener('input', () => { arreterLecture(); poserTemps(); });
|
||||
btnLecture.addEventListener('click', () => {
|
||||
if (lectureId) { arreterLecture(); return; }
|
||||
if (+curseur.value >= N - 1) curseur.value = Math.max(0, N - 48);
|
||||
poserTemps();
|
||||
btnLecture.textContent = '❚❚'; btnLecture.setAttribute('aria-label', 'Mettre en pause');
|
||||
lectureId = setInterval(() => { curseur.value = Math.min(N, +curseur.value + 1); poserTemps(); if (+curseur.value >= N) arreterLecture(); }, 260);
|
||||
});
|
||||
function apresDonnees(){ chargerSeries(); if (TEMPS != null) { snapshotLive(); appliquerTemps(); } }
|
||||
['rech', 'modes'].forEach(i => document.getElementById(i).addEventListener('click', ev => ev.stopPropagation()));
|
||||
|
||||
// téléphone : le cartouche se replie (10 s en haut de page, tout de suite si on descend ou zoome), se rouvre en remontant
|
||||
// téléphone : le cartouche se replie tout de suite dès qu'on touche la carte, qu'on descend ou qu'on zoome, se rouvre en remontant
|
||||
let minuteurRepli = 0;
|
||||
function replier(oui){
|
||||
if (carte.clientWidth >= 720) oui = false;
|
||||
if (cart.classList.contains('replie') === oui) return;
|
||||
cart.classList.toggle('replie', oui); relancer();
|
||||
}
|
||||
function armerRepli(){ clearTimeout(minuteurRepli); minuteurRepli = setTimeout(() => replier(true), 10000); }
|
||||
function armerRepli(){} // plus de délai : le cartouche se replie dès qu'on touche la carte ou qu'on descend
|
||||
carte.addEventListener('pointerdown', ev => { if (!ev.target.closest('.cartouche')) replier(true); });
|
||||
addEventListener('scroll', () => { if (scrollY > 30) replier(true); else { replier(false); armerRepli(); } }, {passive: true});
|
||||
cart.addEventListener('click', ev => {
|
||||
if (ev.target.closest('a, button, input, .rech') || carte.clientWidth >= 720) return;
|
||||
@@ -904,7 +1082,7 @@ function rendrePlein(){
|
||||
? pleinIds.map(i => `<button type="button" data-id="${i}" class="${i === id ? 'on' : ''}">${NOMS[i] || court(STATIONS[i].nom)} ${fmt(STATIONS[i].t)}</button>`).join('') : '';
|
||||
const etat = s.t == null ? (s.horsLigne ? 'hors ligne' : 'pas de données en direct') : (s.mn != null ? `24 h : ${fmt(s.mn)} / ${fmt(s.mx)}` : '');
|
||||
plein.querySelector('.plein-corps').innerHTML =
|
||||
`<h2>${s.nom}${icones(id)}</h2>
|
||||
`<h2>${s.nom}${icones(id)}${(o => o.titre ? `<span class="origine">${o.titre}${o.aussi ? `<small>${o.aussi}</small>` : ''}</span>` : '')(origine(id))}</h2>
|
||||
<p class="plein-sous">${s.alt} m · ${s.src}${s.licence ? ` (${s.licence})` : ''}</p>
|
||||
<div class="plein-val"><b style="color:${couleur(s.t)}">${fmt(s.t)}</b><span>${etat}</span>
|
||||
<button type="button" class="plein-carte">Voir sur la carte</button></div>
|
||||
@@ -1035,7 +1213,7 @@ async function chargerDonnees(){
|
||||
const st = d && d.stations && d.stations[cle], r = st && st.releves && st.releves.at(-1);
|
||||
if (!st || !STATIONS[id]) return;
|
||||
const enLigne = r && !st.hors_ligne;
|
||||
Object.assign(STATIONS[id], {t: enLigne ? r.temperature : null, mn: enLigne ? r.temperature_min : null, mx: enLigne ? r.temperature_max : null,
|
||||
Object.assign(STATIONS[id], {t: enLigne ? r.temperature : null, mn: enLigne ? r.temperature_min : null, mx: enLigne ? r.temperature_max : null, vent: enLigne && r.vent_moyen != null ? r.vent_moyen : null, pluie: enLigne && r.pluie_1h != null ? r.pluie_1h : null,
|
||||
exemple: false, horsLigne: !enLigne, src: st.source || STATIONS[id].src, licence: licenceCourte(d.metadonnees && d.metadonnees[cle] && d.metadonnees[cle].licence)});
|
||||
if (enLigne) { const t = new Date(r.dh_utc.replace(' ', 'T') + 'Z'); if (!dernier || t > dernier) dernier = t; }
|
||||
};
|
||||
@@ -1049,7 +1227,7 @@ async function chargerDonnees(){
|
||||
document.getElementById('date').textContent = jour[0].toUpperCase() + jour.slice(1);
|
||||
dernierReleve = dernier; heureReleve = heure; afficherDirect();
|
||||
}
|
||||
phraseDuJour(); listeStations(); disposer(); relancer(); // les puces qui se regroupent s'animent
|
||||
apresDonnees(); phraseDuJour(); listeStations(); coupe(); disposer(); relancer(); // les puces qui se regroupent s'animent
|
||||
}
|
||||
Promise.race([chargerDonnees(), new Promise(r => setTimeout(r, 1500))]).then(() => { ouverture(); ouvrirDepuisAdresse(); });
|
||||
setInterval(chargerDonnees, 60 * 1000); // les relevés arrivent toutes les 6 à 15 minutes
|
||||
@@ -1099,6 +1277,20 @@ function ouverture(){
|
||||
puces.forEach(p => p.m.style.removeProperty('--d'));
|
||||
}, T + 50);
|
||||
}
|
||||
// Bandeau « pas de cookie » : une fois par appareil, s'efface après 4250 ms (pause au survol / toucher)
|
||||
(function(){
|
||||
try { if (localStorage.getItem('vm-sanscookie')) return; } catch (e) {}
|
||||
const b = document.createElement('div'); b.className = 'sanscookie'; b.setAttribute('role', 'status');
|
||||
b.innerHTML = '<b>Non, désolé, je ne veux pas de cookie,<br>Je n\'ai pas faim, ni envie de me faire traquer.</b><span>Ici, rien à accepter : ni cookie de suivi, ni publicité.</span><button type="button" aria-label="Fermer">×</button>';
|
||||
document.body.appendChild(b);
|
||||
let t, fini = false;
|
||||
const partir = () => { if (fini) return; fini = true; b.classList.add('parti'); setTimeout(() => b.remove(), 600); try { localStorage.setItem('vm-sanscookie', '1'); } catch (e) {} };
|
||||
const armer = () => { clearTimeout(t); t = setTimeout(partir, 4250); };
|
||||
b.addEventListener('pointerenter', () => clearTimeout(t)); b.addEventListener('pointerleave', armer);
|
||||
b.addEventListener('focusin', () => clearTimeout(t));
|
||||
b.querySelector('button').addEventListener('click', partir);
|
||||
armer();
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Référencer dans un nouveau ticket
Bloquer un utilisateur