vercors.me : page station en vues 24 h / 7 jours, alerte de lacune, plein écran élargi (patch Codex) ; fiche de la station
Patch fiche-station-vercors appliqué sur modele.html (sans conflit avec les propriétaires, liens ROMMA/IC/MF, Paramètres FR/EN/DE et l'accueil revu), index.html reconstruit. Sous les mesures : « Fiche de la station » (altitude, propriétaires, source, liens) et, quand FORUM_OUVERT, 3 photos épinglées et le lien vers le sujet de la station ; sinon « bientôt ». Textes dans les trois langues. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cette révision appartient à :
1 Parent
a5278c3b32
révision
6f15a7ed2d
2 fichiers modifiés
+276
-54
Aucun fichier ne correspond à votre recherche
@@ -175,7 +175,26 @@ a{color:inherit}
|
|||||||
.plein-onglets{display:flex;gap:6px;overflow-x:auto}
|
.plein-onglets{display:flex;gap:6px;overflow-x:auto}
|
||||||
.plein-onglets button{font:inherit;font-size:12px;font-weight:600;border:1px solid var(--roche);background:#faf9f5;color:var(--roche);border-radius:0;padding:6px 9px;cursor:pointer;white-space:nowrap}
|
.plein-onglets button{font:inherit;font-size:12px;font-weight:600;border:1px solid var(--roche);background:#faf9f5;color:var(--roche);border-radius:0;padding:6px 9px;cursor:pointer;white-space:nowrap}
|
||||||
.plein-onglets button.on{background:var(--roche);color:#fff}
|
.plein-onglets button.on{background:var(--roche);color:#fff}
|
||||||
.plein-corps{max-width:980px;margin:0 auto;padding:20px 16px 64px}
|
.plein-corps{max-width:1200px;margin:0 auto;padding:20px 16px 64px}
|
||||||
|
[data-aff=acces] .plein-corps{max-width:1480px}
|
||||||
|
.plein-periode{display:flex;gap:8px;margin-top:16px}
|
||||||
|
.plein-periode button{font:inherit;font-weight:600;color:var(--sapin);background:none;border:1px solid var(--sapin);padding:7px 12px;cursor:pointer}
|
||||||
|
.plein-periode button[aria-pressed=true]{background:var(--sapin);color:#fff}
|
||||||
|
[data-aff=acces] .plein-periode button{min-height:44px}
|
||||||
|
.plein-lacune{margin:16px 0 0;color:var(--roche)}
|
||||||
|
.plein-fiche{margin-top:32px;padding-top:18px;border-top:1px solid var(--roche)}
|
||||||
|
.plein-fiche h3{margin:0;font-family:var(--titre);font-weight:600;font-size:20px;color:var(--sapin)}
|
||||||
|
.plein-fiche dl{display:grid;grid-template-columns:max-content 1fr;gap:6px 16px;margin:12px 0 0;font-size:14px}
|
||||||
|
.plein-fiche dt{color:var(--gris)}.plein-fiche dd{margin:0;min-width:0;overflow-wrap:anywhere}
|
||||||
|
.plein-fiche a{color:var(--sapin);text-underline-offset:2px}
|
||||||
|
.fiche-photos{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;margin:16px 0 0;max-width:720px}
|
||||||
|
.fiche-photos img{display:block;width:100%;aspect-ratio:4/3;object-fit:cover;border:1px solid var(--pierre)}
|
||||||
|
.fiche-forum{display:inline-block;margin-top:14px;font-weight:600;color:var(--sapin);border:1px solid var(--sapin);padding:8px 12px;text-decoration:none}
|
||||||
|
.fiche-forum:hover{background:var(--sapin);color:#fff}
|
||||||
|
.fiche-bientot{margin:14px 0 0;font-size:13px;color:var(--gris)}
|
||||||
|
[data-aff=acces] .plein-fiche dl{font-size:16px}[data-aff=acces] .fiche-bientot{font-size:15px;color:var(--roche)}
|
||||||
|
[data-aff=acces] .fiche-forum{min-height:44px}
|
||||||
|
@media (max-width:520px){.plein-fiche dl{grid-template-columns:1fr;gap:0}.plein-fiche dd{margin-bottom:8px}}
|
||||||
.plein-corps h2{margin:0;font-family:var(--titre);font-weight:600;font-size:26px;line-height:1.15;color:var(--sapin)}
|
.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{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)}
|
.origine small{font-size:11px;font-weight:400;color:var(--gris)}
|
||||||
@@ -698,7 +717,12 @@ const I18N = {
|
|||||||
'plein.charge': 'Chargement des courbes…', 'plein.vide': 'Pas encore de courbes pour cette station.',
|
'plein.charge': 'Chargement des courbes…', 'plein.vide': 'Pas encore de courbes pour cette station.',
|
||||||
'g.t': 'Température', 'g.h': 'Humidité', 'g.v': 'Vent moyen', 'g.r': 'Pluie (par heure)', 'g.gel': 'gel',
|
'g.t': 'Température', 'g.h': 'Humidité', 'g.v': 'Vent moyen', 'g.r': 'Pluie (par heure)', 'g.gel': 'gel',
|
||||||
'g.mm': (a, b) => `mini ${a} · maxi ${b}`,
|
'g.mm': (a, b) => `mini ${a} · maxi ${b}`,
|
||||||
'g.note': (j, depuis) => `Relevés toutes les 10 minutes, courbes sur ${j} jour${j > 1 ? 's' : ''}${depuis ? ` · archive depuis le ${depuis}` : ''}. Le zéro est marqué « gel ».`,
|
'g.periode': 'Période des courbes', 'g.jour': '24 h', 'g.semaine': '7 jours',
|
||||||
|
'g.lacune': 'Courbe de température : des relevés manquent pendant au moins 3 h sur cette période.', 'g.lacune.lans': 'À Lans village, la réception des relevés est parfois difficile.', 'g.lacune.geve': 'À Gêve, une coupure de la Livebox peut interrompre les relevés.',
|
||||||
|
'g.note': (j, depuis, min) => `Courbes par pas de ${min} minutes sur ${j} jour${j > 1 ? 's' : ''}${depuis ? ` · archive depuis le ${depuis}` : ''}. Le zéro est marqué « gel ».`,
|
||||||
|
'fiche.titre': 'Fiche de la station', 'fiche.alt': 'Altitude', 'fiche.proprio': 'Propriétaires', 'fiche.source': 'Source des relevés', 'fiche.voir': 'Ailleurs',
|
||||||
|
'fiche.bientot': 'Photos et sujet de la station sur le forum : bientôt.', 'fiche.sujet': 'Voir le sujet de la station · Poster une photo',
|
||||||
|
'fiche.forum': 'Aller au forum', 'fiche.photo': a => `Photo de la station, publiée par ${a}`,
|
||||||
'type.station': 'station', 'type.commune': 'commune', 'type.sommet': 'sommet',
|
'type.station': 'station', 'type.commune': 'commune', 'type.sommet': 'sommet',
|
||||||
'cookie.titre': 'Non, désolé, je ne veux pas de cookie,<br>Je n\'ai pas faim, ni envie de me faire traquer.',
|
'cookie.titre': 'Non, désolé, je ne veux pas de cookie,<br>Je n\'ai pas faim, ni envie de me faire traquer.',
|
||||||
'cookie.txt': 'Ici, rien à accepter : ni cookie de suivi, ni publicité.',
|
'cookie.txt': 'Ici, rien à accepter : ni cookie de suivi, ni publicité.',
|
||||||
@@ -772,7 +796,12 @@ const I18N = {
|
|||||||
'plein.charge': 'Loading the charts…', 'plein.vide': 'No charts for this station yet.',
|
'plein.charge': 'Loading the charts…', 'plein.vide': 'No charts for this station yet.',
|
||||||
'g.t': 'Temperature', 'g.h': 'Humidity', 'g.v': 'Average wind', 'g.r': 'Rain (per hour)', 'g.gel': 'frost',
|
'g.t': 'Temperature', 'g.h': 'Humidity', 'g.v': 'Average wind', 'g.r': 'Rain (per hour)', 'g.gel': 'frost',
|
||||||
'g.mm': (a, b) => `min ${a} · max ${b}`,
|
'g.mm': (a, b) => `min ${a} · max ${b}`,
|
||||||
'g.note': (j, depuis) => `Readings every 10 minutes, charts over ${j} day${j > 1 ? 's' : ''}${depuis ? ` · archive since ${depuis}` : ''}. Zero is marked “frost”.`,
|
'g.periode': 'Chart time range', 'g.jour': '24 hours', 'g.semaine': '7 days',
|
||||||
|
'g.lacune': 'Temperature chart: readings are missing for at least 3 hours in this range.', 'g.lacune.lans': 'At Lans village, reception can be unreliable.', 'g.lacune.geve': 'At Gêve, a Livebox outage can interrupt readings.',
|
||||||
|
'g.note': (j, depuis, min) => `Charts in ${min}-minute steps over ${j} day${j > 1 ? 's' : ''}${depuis ? ` · archive since ${depuis}` : ''}. Zero is marked “frost”.`,
|
||||||
|
'fiche.titre': 'Station profile', 'fiche.alt': 'Altitude', 'fiche.proprio': 'Owners', 'fiche.source': 'Data source', 'fiche.voir': 'Elsewhere',
|
||||||
|
'fiche.bientot': 'Photos and the station’s forum thread: coming soon.', 'fiche.sujet': 'See the station’s thread · Post a photo',
|
||||||
|
'fiche.forum': 'Go to the forum', 'fiche.photo': a => `Photo of the station, posted by ${a}`,
|
||||||
'type.station': 'station', 'type.commune': 'village', 'type.sommet': 'summit',
|
'type.station': 'station', 'type.commune': 'village', 'type.sommet': 'summit',
|
||||||
'cookie.titre': 'No, sorry, I don’t want a cookie,<br>I’m not hungry, and I don’t want to be tracked.',
|
'cookie.titre': 'No, sorry, I don’t want a cookie,<br>I’m not hungry, and I don’t want to be tracked.',
|
||||||
'cookie.txt': 'Nothing to accept here: no tracking cookies, no ads.',
|
'cookie.txt': 'Nothing to accept here: no tracking cookies, no ads.',
|
||||||
@@ -843,7 +872,12 @@ const I18N = {
|
|||||||
'plein.charge': 'Kurven werden geladen…', 'plein.vide': 'Für diese Station gibt es noch keine Kurven.',
|
'plein.charge': 'Kurven werden geladen…', 'plein.vide': 'Für diese Station gibt es noch keine Kurven.',
|
||||||
'g.t': 'Temperatur', 'g.h': 'Luftfeuchtigkeit', 'g.v': 'Mittlerer Wind', 'g.r': 'Regen (pro Stunde)', 'g.gel': 'Frost',
|
'g.t': 'Temperatur', 'g.h': 'Luftfeuchtigkeit', 'g.v': 'Mittlerer Wind', 'g.r': 'Regen (pro Stunde)', 'g.gel': 'Frost',
|
||||||
'g.mm': (a, b) => `min. ${a} · max. ${b}`,
|
'g.mm': (a, b) => `min. ${a} · max. ${b}`,
|
||||||
'g.note': (j, depuis) => `Messwerte alle 10 Minuten, Kurven über ${j} Tag${j > 1 ? 'e' : ''}${depuis ? ` · Archiv seit ${depuis}` : ''}. Null ist mit „Frost“ markiert.`,
|
'g.periode': 'Zeitraum der Diagramme', 'g.jour': '24 Stunden', 'g.semaine': '7 Tage',
|
||||||
|
'g.lacune': 'Temperaturkurve: In diesem Zeitraum fehlen Messwerte für mindestens 3 Stunden.', 'g.lacune.lans': 'In Lans Village ist der Empfang mitunter unzuverlässig.', 'g.lacune.geve': 'In Gêve kann ein Ausfall der Livebox die Messdatenübertragung unterbrechen.',
|
||||||
|
'g.note': (j, depuis, min) => `Kurven im ${min}-Minuten-Raster über ${j} Tag${j > 1 ? 'e' : ''}${depuis ? ` · Archiv seit ${depuis}` : ''}. Null ist mit „Frost“ markiert.`,
|
||||||
|
'fiche.titre': 'Steckbrief der Station', 'fiche.alt': 'Höhe', 'fiche.proprio': 'Eigentümer', 'fiche.source': 'Datenquelle', 'fiche.voir': 'Anderswo',
|
||||||
|
'fiche.bientot': 'Fotos und Forumsthema der Station: demnächst.', 'fiche.sujet': 'Thema der Station ansehen · Foto posten',
|
||||||
|
'fiche.forum': 'Zum Forum', 'fiche.photo': a => `Foto der Station, gepostet von ${a}`,
|
||||||
'type.station': 'Station', 'type.commune': 'Gemeinde', 'type.sommet': 'Gipfel',
|
'type.station': 'Station', 'type.commune': 'Gemeinde', 'type.sommet': 'Gipfel',
|
||||||
'cookie.titre': 'Nein danke, ich will keinen Cookie,<br>ich habe keinen Hunger und will nicht verfolgt werden.',
|
'cookie.titre': 'Nein danke, ich will keinen Cookie,<br>ich habe keinen Hunger und will nicht verfolgt werden.',
|
||||||
'cookie.txt': 'Hier gibt es nichts zu akzeptieren: keine Tracking-Cookies, keine Werbung.',
|
'cookie.txt': 'Hier gibt es nichts zu akzeptieren: keine Tracking-Cookies, keine Werbung.',
|
||||||
@@ -1828,7 +1862,7 @@ plein.id = 'plein'; plein.hidden = true;
|
|||||||
plein.setAttribute('role', 'dialog'); plein.setAttribute('aria-modal', 'true'); plein.setAttribute('aria-label', t('plein.aria'));
|
plein.setAttribute('role', 'dialog'); plein.setAttribute('aria-modal', 'true'); plein.setAttribute('aria-label', t('plein.aria'));
|
||||||
plein.innerHTML = '<div class="plein-barre"><button type="button" class="plein-ferme">' + t('plein.retour') + '</button><nav class="plein-onglets"></nav></div><div class="plein-corps"></div>';
|
plein.innerHTML = '<div class="plein-barre"><button type="button" class="plein-ferme">' + t('plein.retour') + '</button><nav class="plein-onglets"></nav></div><div class="plein-corps"></div>';
|
||||||
document.body.appendChild(plein);
|
document.body.appendChild(plein);
|
||||||
let pleinIds = [], pleinId = null, pleinDonnees = null;
|
let pleinIds = [], pleinId = null, pleinDonnees = null, pleinJours = 7;
|
||||||
let fmtJH, fmtMinuit;
|
let fmtJH, fmtMinuit;
|
||||||
function formatsDates(){
|
function formatsDates(){
|
||||||
fmtJH = new Intl.DateTimeFormat(LOC[L], {weekday: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit', hourCycle: 'h23', timeZone: 'Europe/Paris'});
|
fmtJH = new Intl.DateTimeFormat(LOC[L], {weekday: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit', hourCycle: 'h23', timeZone: 'Europe/Paris'});
|
||||||
@@ -1840,6 +1874,7 @@ const fmtHM = new Intl.DateTimeFormat('en-GB', {hour: '2-digit', minute: '2-digi
|
|||||||
function ouvrirPlein(ids, id = ids[0]){
|
function ouvrirPlein(ids, id = ids[0]){
|
||||||
pleinIds = ids.slice(); pleinId = id;
|
pleinIds = ids.slice(); pleinId = id;
|
||||||
const deja = !plein.hidden;
|
const deja = !plein.hidden;
|
||||||
|
if (!deja) pleinJours = 7;
|
||||||
plein.hidden = false;
|
plein.hidden = false;
|
||||||
document.documentElement.style.overflow = 'hidden';
|
document.documentElement.style.overflow = 'hidden';
|
||||||
if (!deja) { history.pushState({plein: 1}, '', '#station=' + id); requestAnimationFrame(() => plein.classList.add('vu')); }
|
if (!deja) { history.pushState({plein: 1}, '', '#station=' + id); requestAnimationFrame(() => plein.classList.add('vu')); }
|
||||||
@@ -1869,7 +1904,13 @@ function rendrePlein(){
|
|||||||
<p class="plein-sous">${s.alt} m · ${s.src}${s.licence ? ` (${s.licence})` : ''}</p>
|
<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>
|
<div class="plein-val"><b style="color:${couleur(s.t)}">${fmt(s.t)}</b><span>${etat}</span>
|
||||||
<button type="button" class="plein-carte">${t('plein.carte')}</button></div>
|
<button type="button" class="plein-carte">${t('plein.carte')}</button></div>
|
||||||
<div class="graphes"><p class="plein-attente">${t('plein.charge')}</p></div>`;
|
<div class="plein-periode" role="group" aria-label="${t('g.periode')}">
|
||||||
|
<button type="button" data-jours="1" aria-pressed="${pleinJours === 1}">${t('g.jour')}</button>
|
||||||
|
<button type="button" data-jours="7" aria-pressed="${pleinJours === 7}">${t('g.semaine')}</button>
|
||||||
|
</div>
|
||||||
|
<div class="graphes"><p class="plein-attente">${t('plein.charge')}</p></div>
|
||||||
|
${ficheStation(id)}`;
|
||||||
|
if (FORUM_OUVERT) chargerFicheForum(id);
|
||||||
pleinDonnees = null;
|
pleinDonnees = null;
|
||||||
fetch(`data/semaine/${id}.json?${Math.floor(Date.now() / 300000)}`).then(r => r.json()).then(d => {
|
fetch(`data/semaine/${id}.json?${Math.floor(Date.now() / 300000)}`).then(r => r.json()).then(d => {
|
||||||
if (id !== pleinId) return;
|
if (id !== pleinId) return;
|
||||||
@@ -1878,9 +1919,42 @@ function rendrePlein(){
|
|||||||
if (id === pleinId) plein.querySelector('.graphes').innerHTML = `<p class="plein-attente">${t('plein.vide')}</p>`;
|
if (id === pleinId) plein.querySelector('.graphes').innerHTML = `<p class="plein-attente">${t('plein.vide')}</p>`;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// Fiche de la station : sobre (altitude, propriétaires, sources) ; photos épinglées et lien du sujet viennent du forum.
|
||||||
|
const FORUM = '/forum';
|
||||||
|
const echapper = x => String(x).replace(/[&<>"']/g, c => ({'&': '&', '<': '<', '>': '>', '"': '"', "'": '''})[c]);
|
||||||
|
function ficheStation(id){
|
||||||
|
const s = STATIONS[id], p = PROPRIO[id], l = liens(id);
|
||||||
|
const ligne = (k, v) => v ? `<dt>${t(k)}</dt><dd>${v}</dd>` : '';
|
||||||
|
return `<section class="plein-fiche" aria-labelledby="fiche-titre"><h3 id="fiche-titre">${t('fiche.titre')}</h3><dl>
|
||||||
|
${ligne('fiche.alt', s.alt + ' m')}
|
||||||
|
${ligne('fiche.proprio', p && p.map(n => PROPRIO_LIEN[n] ? `<a href="${PROPRIO_LIEN[n]}" target="_blank" rel="noopener">${n}</a>` : n).join(' · '))}
|
||||||
|
${ligne('fiche.source', (s.src || '') + (s.licence ? ` (${s.licence})` : ''))}
|
||||||
|
${ligne('fiche.voir', l)}</dl>
|
||||||
|
<div class="fiche-forum-zone">${FORUM_OUVERT ? '' : `<p class="fiche-bientot">${t('fiche.bientot')}</p>`}</div></section>`;
|
||||||
|
}
|
||||||
|
function chargerFicheForum(id){
|
||||||
|
fetch(`${FORUM}/api/station/${encodeURIComponent(id)}.json?${Math.floor(Date.now() / 300000)}`).then(r => r.ok ? r.json() : null).then(d => {
|
||||||
|
const zone = plein.querySelector('.fiche-forum-zone');
|
||||||
|
if (!d || id !== pleinId || !zone) return;
|
||||||
|
const lien = d.sujet && d.sujet.startsWith(FORUM + '/') ? d.sujet : FORUM + '/';
|
||||||
|
const photos = (d.photos || []).filter(x => typeof x.url === 'string' && x.url.startsWith(FORUM + '/photo/')).slice(0, 3);
|
||||||
|
zone.innerHTML = (photos.length ? `<div class="fiche-photos">${photos.map(x =>
|
||||||
|
`<a href="${echapper(lien)}"><img src="${echapper(x.url)}" alt="${echapper(t('fiche.photo', x.auteur || ''))}" loading="lazy" decoding="async"></a>`).join('')}</div>` : '')
|
||||||
|
+ `<a class="fiche-forum" href="${echapper(lien)}">${t(d.sujet ? 'fiche.sujet' : 'fiche.forum')}</a>`;
|
||||||
|
}).catch(() => {});
|
||||||
|
}
|
||||||
plein.addEventListener('click', ev => {
|
plein.addEventListener('click', ev => {
|
||||||
const o = ev.target.closest('.plein-onglets button');
|
const o = ev.target.closest('.plein-onglets button');
|
||||||
if (o) { pleinId = o.dataset.id; rendrePlein(); return; }
|
if (o) { pleinId = o.dataset.id; rendrePlein(); return; }
|
||||||
|
const periode = ev.target.closest('.plein-periode button');
|
||||||
|
if (periode) {
|
||||||
|
pleinJours = Number(periode.dataset.jours);
|
||||||
|
plein.querySelectorAll('.plein-periode button').forEach(bouton => {
|
||||||
|
bouton.setAttribute('aria-pressed', Number(bouton.dataset.jours) === pleinJours);
|
||||||
|
});
|
||||||
|
if (pleinDonnees) dessinerGraphes();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (ev.target.closest('.plein-carte')) {
|
if (ev.target.closest('.plein-carte')) {
|
||||||
const ids = pleinIds.slice();
|
const ids = pleinIds.slice();
|
||||||
fermerPlein();
|
fermerPlein();
|
||||||
@@ -1898,27 +1972,64 @@ function graduations(bas, haut, n = 4){
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function cadrerCourbes(d, jours){
|
||||||
|
const cles = ['t', 'h', 'v', 'r'];
|
||||||
|
// Écarter le remplissage avant le début de l'archive, puis limiter à la période choisie.
|
||||||
|
const archive = d.archive_depuis == null
|
||||||
|
? d.t.findIndex((_, i) => cles.some(cle => d[cle][i] != null))
|
||||||
|
: Math.floor((d.archive_depuis - d.debut) / d.pas);
|
||||||
|
const periode = d.t.length - 1 - Math.floor(jours * 86400 / d.pas);
|
||||||
|
const i0 = Math.min(Math.max(0, archive, periode), Math.max(0, d.t.length - 2));
|
||||||
|
const vue = {...d, debut: d.debut + i0 * d.pas};
|
||||||
|
for (const cle of cles) vue[cle] = d[cle].slice(i0);
|
||||||
|
return vue;
|
||||||
|
}
|
||||||
|
|
||||||
|
function lacuneTemperature(temperatures, pas){
|
||||||
|
// La pluie a des cases vides prévues entre ses mesures horaires.
|
||||||
|
let duree = 0;
|
||||||
|
return temperatures.some(valeur => {
|
||||||
|
duree = valeur == null ? duree + pas : 0;
|
||||||
|
return duree >= 3 * 3600;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function dessinerGraphes(){
|
function dessinerGraphes(){
|
||||||
let d = pleinDonnees;
|
|
||||||
const zone = plein.querySelector('.graphes');
|
const zone = plein.querySelector('.graphes');
|
||||||
if (!d || !zone) return;
|
if (!pleinDonnees || !zone) return;
|
||||||
// on cadre sur ce que l'archive contient (elle se remplit jour après jour)
|
zone.onpointermove = zone.onpointerdown = zone.onpointerleave = null;
|
||||||
const tout = ['t', 'h', 'v', 'r'].map(k => d[k]);
|
const d = cadrerCourbes(pleinDonnees, pleinJours);
|
||||||
let i0 = 0;
|
|
||||||
while (i0 < d.t.length - 2 && tout.every(a => a[i0] == null)) i0++;
|
|
||||||
if (i0 > 0) { d = {...d, debut: d.debut + i0 * d.pas, t: d.t.slice(i0), h: d.h.slice(i0), v: d.v.slice(i0), r: d.r.slice(i0)}; }
|
|
||||||
const n = d.t.length;
|
const n = d.t.length;
|
||||||
|
if (n < 2) {
|
||||||
|
zone.innerHTML = `<p class="plein-attente">${t('plein.vide')}</p>`;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const infoStation = pleinId === 'lans' || pleinId === 'geve' ? ' ' + t('g.lacune.' + pleinId) : '';
|
||||||
|
const lacune = pleinDonnees.t.some(valeur => valeur != null) && lacuneTemperature(d.t, d.pas)
|
||||||
|
? `<p class="plein-lacune">${t('g.lacune')}${infoStation}</p>`
|
||||||
|
: '';
|
||||||
const hum = d.h.map(v => v != null && v >= 3 ? v : null); // hygromètre défaillant (1 %) : ignoré
|
const hum = d.h.map(v => v != null && v >= 3 ? v : null); // hygromètre défaillant (1 %) : ignoré
|
||||||
const defs = [{cle: 't', titre: t('g.t'), v: d.t, f: fmt, ligne: true, couleurs: couleur}];
|
const defs = [];
|
||||||
|
if (d.t.some(v => v != null)) defs.push({cle: 't', titre: t('g.t'), v: d.t, f: fmt, ligne: true, couleurs: couleur});
|
||||||
if (d.capteurs.humidite && hum.some(v => v != null)) defs.push({cle: 'h', titre: t('g.h'), v: hum, f: v => Math.round(v) + ' %', ligne: true, c: '#3f8c97', borne: [0, 100]});
|
if (d.capteurs.humidite && hum.some(v => v != null)) defs.push({cle: 'h', titre: t('g.h'), v: hum, f: v => Math.round(v) + ' %', ligne: true, c: '#3f8c97', borne: [0, 100]});
|
||||||
if (d.capteurs.vent) defs.push({cle: 'v', titre: t('g.v'), v: d.v, f: v => Math.round(v) + ' km/h', ligne: true, c: '#c99700', zero: true, icone: IC_EOLIENNE});
|
if (d.capteurs.vent && d.v.some(v => v != null)) defs.push({cle: 'v', titre: t('g.v'), v: d.v, f: v => Math.round(v) + ' km/h', ligne: true, c: '#c99700', zero: true, icone: IC_EOLIENNE});
|
||||||
if (d.capteurs.pluie) defs.push({cle: 'r', titre: t('g.r'), v: d.r, f: v => dec(v.toFixed(1)) + ' mm', ligne: false, c: '#2f7fc1', zero: true, icone: IC_GOUTTE});
|
if (d.capteurs.pluie && d.r.some(v => v != null)) defs.push({cle: 'r', titre: t('g.r'), v: d.r, f: v => dec(v.toFixed(1)) + ' mm', ligne: false, c: '#2f7fc1', zero: true, icone: IC_GOUTTE});
|
||||||
const W = Math.max(280, zone.clientWidth), H = 150, ml = 40, mr = 10, mt = 8, mb = 22, pw = W - ml - mr;
|
if (!defs.length) {
|
||||||
|
zone.innerHTML = lacune + `<p class="plein-attente">${t('plein.vide')}</p>`;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const W = Math.max(160, zone.clientWidth), H = 150, ml = 40, mr = 10, mt = 8, mb = 22, pw = W - ml - mr;
|
||||||
const X = i => ml + i / (n - 1) * pw;
|
const X = i => ml + i / (n - 1) * pw;
|
||||||
// repères des jours : minuit, heure de Paris
|
// Repères en heure de Paris : toutes les 6 h sur 24 h, à minuit sur 7 jours.
|
||||||
const jours = [];
|
const reperesTemps = [];
|
||||||
for (let i = 0; i < n; i++) { const t = new Date((d.debut + i * d.pas) * 1000); if (fmtHM.format(t) === '00:00') jours.push([i, fmtMinuit.format(t)]); }
|
for (let i = 0; i < n; i++) {
|
||||||
zone.innerHTML = defs.map((g, k) => {
|
const date = new Date((d.debut + i * d.pas) * 1000);
|
||||||
|
const heure = fmtHM.format(date);
|
||||||
|
if (pleinJours === 1 ? ['00:00', '06:00', '12:00', '18:00'].includes(heure) : heure === '00:00') {
|
||||||
|
reperesTemps.push([i, pleinJours === 1 ? heure : fmtMinuit.format(date)]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
zone.innerHTML = lacune + defs.map((g, k) => {
|
||||||
const vals = g.v.filter(v => v != null);
|
const vals = g.v.filter(v => v != null);
|
||||||
let bas = Math.min(...vals), haut = Math.max(...vals);
|
let bas = Math.min(...vals), haut = Math.max(...vals);
|
||||||
if (g.borne) { bas = g.borne[0]; haut = g.borne[1]; }
|
if (g.borne) { bas = g.borne[0]; haut = g.borne[1]; }
|
||||||
@@ -1943,12 +2054,12 @@ function dessinerGraphes(){
|
|||||||
}
|
}
|
||||||
const zero = g.cle === 't' && bas < 0 && haut > 0 ? `<line x1="${ml}" x2="${W - mr}" y1="${Y(0)}" y2="${Y(0)}" stroke="#3d6f8e" stroke-dasharray="4 3" stroke-opacity=".7"/><text x="${W - mr}" y="${Y(0) - 3}" text-anchor="end" class="gz">${t('g.gel')}</text>` : '';
|
const zero = g.cle === 't' && bas < 0 && haut > 0 ? `<line x1="${ml}" x2="${W - mr}" y1="${Y(0)}" y2="${Y(0)}" stroke="#3d6f8e" stroke-dasharray="4 3" stroke-opacity=".7"/><text x="${W - mr}" y="${Y(0) - 3}" text-anchor="end" class="gz">${t('g.gel')}</text>` : '';
|
||||||
const grille = grad.map(v => `<line x1="${ml}" x2="${W - mr}" y1="${Y(v)}" y2="${Y(v)}" stroke="#e4e0d6"/><text x="${ml - 5}" y="${Y(v) + 3.5}" text-anchor="end">${g.cle === 't' ? Math.round(v) + '°' : Math.round(v * 10) / 10}</text>`).join('');
|
const grille = grad.map(v => `<line x1="${ml}" x2="${W - mr}" y1="${Y(v)}" y2="${Y(v)}" stroke="#e4e0d6"/><text x="${ml - 5}" y="${Y(v) + 3.5}" text-anchor="end">${g.cle === 't' ? Math.round(v) + '°' : Math.round(v * 10) / 10}</text>`).join('');
|
||||||
const reperes = jours.map(([i, nom]) => `<line x1="${X(i)}" x2="${X(i)}" y1="${mt}" y2="${H - mb}" stroke="#d9d4c6"/><text x="${X(i) + 4}" y="${H - 7}">${nom}</text>`).join('');
|
const reperes = reperesTemps.map(([i, nom]) => `<line x1="${X(i)}" x2="${X(i)}" y1="${mt}" y2="${H - mb}" stroke="#d9d4c6"/><text x="${i > (n - 1) * 0.85 ? X(i) - 4 : X(i) + 4}" y="${H - 7}" text-anchor="${i > (n - 1) * 0.85 ? 'end' : 'start'}">${nom}</text>`).join('');
|
||||||
const mm = vals.length ? t('g.mm', g.f(Math.min(...vals)), g.f(Math.max(...vals))) : '';
|
const mm = vals.length ? t('g.mm', g.f(Math.min(...vals)), g.f(Math.max(...vals))) : '';
|
||||||
return `<section class="graphe" data-k="${k}"><header><h3>${g.titre}${g.icone || ''}</h3><span class="g-mm">${mm}</span><b class="g-lect"></b></header>
|
return `<section class="graphe" data-k="${k}"><header><h3>${g.titre}${g.icone || ''}</h3><span class="g-mm">${mm}</span><b class="g-lect"></b></header>
|
||||||
<svg width="${W}" height="${H}" viewBox="0 0 ${W} ${H}">${reperes}${grille}${zero}${trace}
|
<svg width="${W}" height="${H}" viewBox="0 0 ${W} ${H}">${reperes}${grille}${zero}${trace}
|
||||||
<line class="curseur" x1="0" x2="0" y1="${mt}" y2="${H - mb}" visibility="hidden"/><circle class="point" r="3.5" visibility="hidden" fill="#fff" stroke="${g.c || '#1f4d3a'}" stroke-width="2"/></svg></section>`;
|
<line class="curseur" x1="0" x2="0" y1="${mt}" y2="${H - mb}" visibility="hidden"/><circle class="point" r="3.5" visibility="hidden" fill="#fff" stroke="${g.c || '#1f4d3a'}" stroke-width="2"/></svg></section>`;
|
||||||
}).join('') + `<p class="plein-note">${t('g.note', Math.min(7, Math.max(1, Math.round(n * d.pas / 86400))), d.archive_depuis ? new Intl.DateTimeFormat(LOC[L], {day: 'numeric', month: 'long', timeZone: 'Europe/Paris'}).format(new Date(d.archive_depuis * 1000)) : '')}</p>`;
|
}).join('') + `<p class="plein-note">${t('g.note', Math.min(7, Math.max(1, Math.round(n * d.pas / 86400))), d.archive_depuis ? new Intl.DateTimeFormat(LOC[L], {day: 'numeric', month: 'long', timeZone: 'Europe/Paris'}).format(new Date(d.archive_depuis * 1000)) : '', d.pas / 60)}</p>`;
|
||||||
|
|
||||||
// curseur partagé : le doigt ou la souris lit la même heure sur toutes les courbes
|
// curseur partagé : le doigt ou la souris lit la même heure sur toutes les courbes
|
||||||
const gr = [...zone.querySelectorAll('.graphe')];
|
const gr = [...zone.querySelectorAll('.graphe')];
|
||||||
@@ -1979,11 +2090,11 @@ function dessinerGraphes(){
|
|||||||
const i = Math.max(0, Math.min(n - 1, Math.round((ev.clientX - r.left - ml) / pw * (n - 1))));
|
const i = Math.max(0, Math.min(n - 1, Math.round((ev.clientX - r.left - ml) / pw * (n - 1))));
|
||||||
gr.forEach((el, k) => { const v = defs[k].v[i]; if (v != null && defs[k].ligne) el.querySelector('.point').setAttribute('cy', defs[k].Y(v)); });
|
gr.forEach((el, k) => { const v = defs[k].v[i]; if (v != null && defs[k].ligne) el.querySelector('.point').setAttribute('cy', defs[k].Y(v)); });
|
||||||
};
|
};
|
||||||
zone.addEventListener('pointermove', poserPoint);
|
zone.onpointermove = poserPoint;
|
||||||
zone.addEventListener('pointerdown', poserPoint);
|
zone.onpointerdown = poserPoint;
|
||||||
zone.addEventListener('pointerleave', () => gr.forEach(el => {
|
zone.onpointerleave = () => gr.forEach(el => {
|
||||||
el.querySelector('.curseur').setAttribute('visibility', 'hidden'); el.querySelector('.point').setAttribute('visibility', 'hidden'); el.querySelector('.g-lect').textContent = '';
|
el.querySelector('.curseur').setAttribute('visibility', 'hidden'); el.querySelector('.point').setAttribute('visibility', 'hidden'); el.querySelector('.g-lect').textContent = '';
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const lire = async f => { try { return await (await fetch(`data/${f}?${Date.now()}`)).json(); } catch (e) { return null; } };
|
const lire = async f => { try { return await (await fetch(`data/${f}?${Date.now()}`)).json(); } catch (e) { return null; } };
|
||||||
|
|||||||
@@ -175,7 +175,26 @@ a{color:inherit}
|
|||||||
.plein-onglets{display:flex;gap:6px;overflow-x:auto}
|
.plein-onglets{display:flex;gap:6px;overflow-x:auto}
|
||||||
.plein-onglets button{font:inherit;font-size:12px;font-weight:600;border:1px solid var(--roche);background:#faf9f5;color:var(--roche);border-radius:0;padding:6px 9px;cursor:pointer;white-space:nowrap}
|
.plein-onglets button{font:inherit;font-size:12px;font-weight:600;border:1px solid var(--roche);background:#faf9f5;color:var(--roche);border-radius:0;padding:6px 9px;cursor:pointer;white-space:nowrap}
|
||||||
.plein-onglets button.on{background:var(--roche);color:#fff}
|
.plein-onglets button.on{background:var(--roche);color:#fff}
|
||||||
.plein-corps{max-width:980px;margin:0 auto;padding:20px 16px 64px}
|
.plein-corps{max-width:1200px;margin:0 auto;padding:20px 16px 64px}
|
||||||
|
[data-aff=acces] .plein-corps{max-width:1480px}
|
||||||
|
.plein-periode{display:flex;gap:8px;margin-top:16px}
|
||||||
|
.plein-periode button{font:inherit;font-weight:600;color:var(--sapin);background:none;border:1px solid var(--sapin);padding:7px 12px;cursor:pointer}
|
||||||
|
.plein-periode button[aria-pressed=true]{background:var(--sapin);color:#fff}
|
||||||
|
[data-aff=acces] .plein-periode button{min-height:44px}
|
||||||
|
.plein-lacune{margin:16px 0 0;color:var(--roche)}
|
||||||
|
.plein-fiche{margin-top:32px;padding-top:18px;border-top:1px solid var(--roche)}
|
||||||
|
.plein-fiche h3{margin:0;font-family:var(--titre);font-weight:600;font-size:20px;color:var(--sapin)}
|
||||||
|
.plein-fiche dl{display:grid;grid-template-columns:max-content 1fr;gap:6px 16px;margin:12px 0 0;font-size:14px}
|
||||||
|
.plein-fiche dt{color:var(--gris)}.plein-fiche dd{margin:0;min-width:0;overflow-wrap:anywhere}
|
||||||
|
.plein-fiche a{color:var(--sapin);text-underline-offset:2px}
|
||||||
|
.fiche-photos{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;margin:16px 0 0;max-width:720px}
|
||||||
|
.fiche-photos img{display:block;width:100%;aspect-ratio:4/3;object-fit:cover;border:1px solid var(--pierre)}
|
||||||
|
.fiche-forum{display:inline-block;margin-top:14px;font-weight:600;color:var(--sapin);border:1px solid var(--sapin);padding:8px 12px;text-decoration:none}
|
||||||
|
.fiche-forum:hover{background:var(--sapin);color:#fff}
|
||||||
|
.fiche-bientot{margin:14px 0 0;font-size:13px;color:var(--gris)}
|
||||||
|
[data-aff=acces] .plein-fiche dl{font-size:16px}[data-aff=acces] .fiche-bientot{font-size:15px;color:var(--roche)}
|
||||||
|
[data-aff=acces] .fiche-forum{min-height:44px}
|
||||||
|
@media (max-width:520px){.plein-fiche dl{grid-template-columns:1fr;gap:0}.plein-fiche dd{margin-bottom:8px}}
|
||||||
.plein-corps h2{margin:0;font-family:var(--titre);font-weight:600;font-size:26px;line-height:1.15;color:var(--sapin)}
|
.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{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)}
|
.origine small{font-size:11px;font-weight:400;color:var(--gris)}
|
||||||
@@ -698,7 +717,12 @@ const I18N = {
|
|||||||
'plein.charge': 'Chargement des courbes…', 'plein.vide': 'Pas encore de courbes pour cette station.',
|
'plein.charge': 'Chargement des courbes…', 'plein.vide': 'Pas encore de courbes pour cette station.',
|
||||||
'g.t': 'Température', 'g.h': 'Humidité', 'g.v': 'Vent moyen', 'g.r': 'Pluie (par heure)', 'g.gel': 'gel',
|
'g.t': 'Température', 'g.h': 'Humidité', 'g.v': 'Vent moyen', 'g.r': 'Pluie (par heure)', 'g.gel': 'gel',
|
||||||
'g.mm': (a, b) => `mini ${a} · maxi ${b}`,
|
'g.mm': (a, b) => `mini ${a} · maxi ${b}`,
|
||||||
'g.note': (j, depuis) => `Relevés toutes les 10 minutes, courbes sur ${j} jour${j > 1 ? 's' : ''}${depuis ? ` · archive depuis le ${depuis}` : ''}. Le zéro est marqué « gel ».`,
|
'g.periode': 'Période des courbes', 'g.jour': '24 h', 'g.semaine': '7 jours',
|
||||||
|
'g.lacune': 'Courbe de température : des relevés manquent pendant au moins 3 h sur cette période.', 'g.lacune.lans': 'À Lans village, la réception des relevés est parfois difficile.', 'g.lacune.geve': 'À Gêve, une coupure de la Livebox peut interrompre les relevés.',
|
||||||
|
'g.note': (j, depuis, min) => `Courbes par pas de ${min} minutes sur ${j} jour${j > 1 ? 's' : ''}${depuis ? ` · archive depuis le ${depuis}` : ''}. Le zéro est marqué « gel ».`,
|
||||||
|
'fiche.titre': 'Fiche de la station', 'fiche.alt': 'Altitude', 'fiche.proprio': 'Propriétaires', 'fiche.source': 'Source des relevés', 'fiche.voir': 'Ailleurs',
|
||||||
|
'fiche.bientot': 'Photos et sujet de la station sur le forum : bientôt.', 'fiche.sujet': 'Voir le sujet de la station · Poster une photo',
|
||||||
|
'fiche.forum': 'Aller au forum', 'fiche.photo': a => `Photo de la station, publiée par ${a}`,
|
||||||
'type.station': 'station', 'type.commune': 'commune', 'type.sommet': 'sommet',
|
'type.station': 'station', 'type.commune': 'commune', 'type.sommet': 'sommet',
|
||||||
'cookie.titre': 'Non, désolé, je ne veux pas de cookie,<br>Je n\'ai pas faim, ni envie de me faire traquer.',
|
'cookie.titre': 'Non, désolé, je ne veux pas de cookie,<br>Je n\'ai pas faim, ni envie de me faire traquer.',
|
||||||
'cookie.txt': 'Ici, rien à accepter : ni cookie de suivi, ni publicité.',
|
'cookie.txt': 'Ici, rien à accepter : ni cookie de suivi, ni publicité.',
|
||||||
@@ -772,7 +796,12 @@ const I18N = {
|
|||||||
'plein.charge': 'Loading the charts…', 'plein.vide': 'No charts for this station yet.',
|
'plein.charge': 'Loading the charts…', 'plein.vide': 'No charts for this station yet.',
|
||||||
'g.t': 'Temperature', 'g.h': 'Humidity', 'g.v': 'Average wind', 'g.r': 'Rain (per hour)', 'g.gel': 'frost',
|
'g.t': 'Temperature', 'g.h': 'Humidity', 'g.v': 'Average wind', 'g.r': 'Rain (per hour)', 'g.gel': 'frost',
|
||||||
'g.mm': (a, b) => `min ${a} · max ${b}`,
|
'g.mm': (a, b) => `min ${a} · max ${b}`,
|
||||||
'g.note': (j, depuis) => `Readings every 10 minutes, charts over ${j} day${j > 1 ? 's' : ''}${depuis ? ` · archive since ${depuis}` : ''}. Zero is marked “frost”.`,
|
'g.periode': 'Chart time range', 'g.jour': '24 hours', 'g.semaine': '7 days',
|
||||||
|
'g.lacune': 'Temperature chart: readings are missing for at least 3 hours in this range.', 'g.lacune.lans': 'At Lans village, reception can be unreliable.', 'g.lacune.geve': 'At Gêve, a Livebox outage can interrupt readings.',
|
||||||
|
'g.note': (j, depuis, min) => `Charts in ${min}-minute steps over ${j} day${j > 1 ? 's' : ''}${depuis ? ` · archive since ${depuis}` : ''}. Zero is marked “frost”.`,
|
||||||
|
'fiche.titre': 'Station profile', 'fiche.alt': 'Altitude', 'fiche.proprio': 'Owners', 'fiche.source': 'Data source', 'fiche.voir': 'Elsewhere',
|
||||||
|
'fiche.bientot': 'Photos and the station’s forum thread: coming soon.', 'fiche.sujet': 'See the station’s thread · Post a photo',
|
||||||
|
'fiche.forum': 'Go to the forum', 'fiche.photo': a => `Photo of the station, posted by ${a}`,
|
||||||
'type.station': 'station', 'type.commune': 'village', 'type.sommet': 'summit',
|
'type.station': 'station', 'type.commune': 'village', 'type.sommet': 'summit',
|
||||||
'cookie.titre': 'No, sorry, I don’t want a cookie,<br>I’m not hungry, and I don’t want to be tracked.',
|
'cookie.titre': 'No, sorry, I don’t want a cookie,<br>I’m not hungry, and I don’t want to be tracked.',
|
||||||
'cookie.txt': 'Nothing to accept here: no tracking cookies, no ads.',
|
'cookie.txt': 'Nothing to accept here: no tracking cookies, no ads.',
|
||||||
@@ -843,7 +872,12 @@ const I18N = {
|
|||||||
'plein.charge': 'Kurven werden geladen…', 'plein.vide': 'Für diese Station gibt es noch keine Kurven.',
|
'plein.charge': 'Kurven werden geladen…', 'plein.vide': 'Für diese Station gibt es noch keine Kurven.',
|
||||||
'g.t': 'Temperatur', 'g.h': 'Luftfeuchtigkeit', 'g.v': 'Mittlerer Wind', 'g.r': 'Regen (pro Stunde)', 'g.gel': 'Frost',
|
'g.t': 'Temperatur', 'g.h': 'Luftfeuchtigkeit', 'g.v': 'Mittlerer Wind', 'g.r': 'Regen (pro Stunde)', 'g.gel': 'Frost',
|
||||||
'g.mm': (a, b) => `min. ${a} · max. ${b}`,
|
'g.mm': (a, b) => `min. ${a} · max. ${b}`,
|
||||||
'g.note': (j, depuis) => `Messwerte alle 10 Minuten, Kurven über ${j} Tag${j > 1 ? 'e' : ''}${depuis ? ` · Archiv seit ${depuis}` : ''}. Null ist mit „Frost“ markiert.`,
|
'g.periode': 'Zeitraum der Diagramme', 'g.jour': '24 Stunden', 'g.semaine': '7 Tage',
|
||||||
|
'g.lacune': 'Temperaturkurve: In diesem Zeitraum fehlen Messwerte für mindestens 3 Stunden.', 'g.lacune.lans': 'In Lans Village ist der Empfang mitunter unzuverlässig.', 'g.lacune.geve': 'In Gêve kann ein Ausfall der Livebox die Messdatenübertragung unterbrechen.',
|
||||||
|
'g.note': (j, depuis, min) => `Kurven im ${min}-Minuten-Raster über ${j} Tag${j > 1 ? 'e' : ''}${depuis ? ` · Archiv seit ${depuis}` : ''}. Null ist mit „Frost“ markiert.`,
|
||||||
|
'fiche.titre': 'Steckbrief der Station', 'fiche.alt': 'Höhe', 'fiche.proprio': 'Eigentümer', 'fiche.source': 'Datenquelle', 'fiche.voir': 'Anderswo',
|
||||||
|
'fiche.bientot': 'Fotos und Forumsthema der Station: demnächst.', 'fiche.sujet': 'Thema der Station ansehen · Foto posten',
|
||||||
|
'fiche.forum': 'Zum Forum', 'fiche.photo': a => `Foto der Station, gepostet von ${a}`,
|
||||||
'type.station': 'Station', 'type.commune': 'Gemeinde', 'type.sommet': 'Gipfel',
|
'type.station': 'Station', 'type.commune': 'Gemeinde', 'type.sommet': 'Gipfel',
|
||||||
'cookie.titre': 'Nein danke, ich will keinen Cookie,<br>ich habe keinen Hunger und will nicht verfolgt werden.',
|
'cookie.titre': 'Nein danke, ich will keinen Cookie,<br>ich habe keinen Hunger und will nicht verfolgt werden.',
|
||||||
'cookie.txt': 'Hier gibt es nichts zu akzeptieren: keine Tracking-Cookies, keine Werbung.',
|
'cookie.txt': 'Hier gibt es nichts zu akzeptieren: keine Tracking-Cookies, keine Werbung.',
|
||||||
@@ -1828,7 +1862,7 @@ plein.id = 'plein'; plein.hidden = true;
|
|||||||
plein.setAttribute('role', 'dialog'); plein.setAttribute('aria-modal', 'true'); plein.setAttribute('aria-label', t('plein.aria'));
|
plein.setAttribute('role', 'dialog'); plein.setAttribute('aria-modal', 'true'); plein.setAttribute('aria-label', t('plein.aria'));
|
||||||
plein.innerHTML = '<div class="plein-barre"><button type="button" class="plein-ferme">' + t('plein.retour') + '</button><nav class="plein-onglets"></nav></div><div class="plein-corps"></div>';
|
plein.innerHTML = '<div class="plein-barre"><button type="button" class="plein-ferme">' + t('plein.retour') + '</button><nav class="plein-onglets"></nav></div><div class="plein-corps"></div>';
|
||||||
document.body.appendChild(plein);
|
document.body.appendChild(plein);
|
||||||
let pleinIds = [], pleinId = null, pleinDonnees = null;
|
let pleinIds = [], pleinId = null, pleinDonnees = null, pleinJours = 7;
|
||||||
let fmtJH, fmtMinuit;
|
let fmtJH, fmtMinuit;
|
||||||
function formatsDates(){
|
function formatsDates(){
|
||||||
fmtJH = new Intl.DateTimeFormat(LOC[L], {weekday: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit', hourCycle: 'h23', timeZone: 'Europe/Paris'});
|
fmtJH = new Intl.DateTimeFormat(LOC[L], {weekday: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit', hourCycle: 'h23', timeZone: 'Europe/Paris'});
|
||||||
@@ -1840,6 +1874,7 @@ const fmtHM = new Intl.DateTimeFormat('en-GB', {hour: '2-digit', minute: '2-digi
|
|||||||
function ouvrirPlein(ids, id = ids[0]){
|
function ouvrirPlein(ids, id = ids[0]){
|
||||||
pleinIds = ids.slice(); pleinId = id;
|
pleinIds = ids.slice(); pleinId = id;
|
||||||
const deja = !plein.hidden;
|
const deja = !plein.hidden;
|
||||||
|
if (!deja) pleinJours = 7;
|
||||||
plein.hidden = false;
|
plein.hidden = false;
|
||||||
document.documentElement.style.overflow = 'hidden';
|
document.documentElement.style.overflow = 'hidden';
|
||||||
if (!deja) { history.pushState({plein: 1}, '', '#station=' + id); requestAnimationFrame(() => plein.classList.add('vu')); }
|
if (!deja) { history.pushState({plein: 1}, '', '#station=' + id); requestAnimationFrame(() => plein.classList.add('vu')); }
|
||||||
@@ -1869,7 +1904,13 @@ function rendrePlein(){
|
|||||||
<p class="plein-sous">${s.alt} m · ${s.src}${s.licence ? ` (${s.licence})` : ''}</p>
|
<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>
|
<div class="plein-val"><b style="color:${couleur(s.t)}">${fmt(s.t)}</b><span>${etat}</span>
|
||||||
<button type="button" class="plein-carte">${t('plein.carte')}</button></div>
|
<button type="button" class="plein-carte">${t('plein.carte')}</button></div>
|
||||||
<div class="graphes"><p class="plein-attente">${t('plein.charge')}</p></div>`;
|
<div class="plein-periode" role="group" aria-label="${t('g.periode')}">
|
||||||
|
<button type="button" data-jours="1" aria-pressed="${pleinJours === 1}">${t('g.jour')}</button>
|
||||||
|
<button type="button" data-jours="7" aria-pressed="${pleinJours === 7}">${t('g.semaine')}</button>
|
||||||
|
</div>
|
||||||
|
<div class="graphes"><p class="plein-attente">${t('plein.charge')}</p></div>
|
||||||
|
${ficheStation(id)}`;
|
||||||
|
if (FORUM_OUVERT) chargerFicheForum(id);
|
||||||
pleinDonnees = null;
|
pleinDonnees = null;
|
||||||
fetch(`data/semaine/${id}.json?${Math.floor(Date.now() / 300000)}`).then(r => r.json()).then(d => {
|
fetch(`data/semaine/${id}.json?${Math.floor(Date.now() / 300000)}`).then(r => r.json()).then(d => {
|
||||||
if (id !== pleinId) return;
|
if (id !== pleinId) return;
|
||||||
@@ -1878,9 +1919,42 @@ function rendrePlein(){
|
|||||||
if (id === pleinId) plein.querySelector('.graphes').innerHTML = `<p class="plein-attente">${t('plein.vide')}</p>`;
|
if (id === pleinId) plein.querySelector('.graphes').innerHTML = `<p class="plein-attente">${t('plein.vide')}</p>`;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// Fiche de la station : sobre (altitude, propriétaires, sources) ; photos épinglées et lien du sujet viennent du forum.
|
||||||
|
const FORUM = '/forum';
|
||||||
|
const echapper = x => String(x).replace(/[&<>"']/g, c => ({'&': '&', '<': '<', '>': '>', '"': '"', "'": '''})[c]);
|
||||||
|
function ficheStation(id){
|
||||||
|
const s = STATIONS[id], p = PROPRIO[id], l = liens(id);
|
||||||
|
const ligne = (k, v) => v ? `<dt>${t(k)}</dt><dd>${v}</dd>` : '';
|
||||||
|
return `<section class="plein-fiche" aria-labelledby="fiche-titre"><h3 id="fiche-titre">${t('fiche.titre')}</h3><dl>
|
||||||
|
${ligne('fiche.alt', s.alt + ' m')}
|
||||||
|
${ligne('fiche.proprio', p && p.map(n => PROPRIO_LIEN[n] ? `<a href="${PROPRIO_LIEN[n]}" target="_blank" rel="noopener">${n}</a>` : n).join(' · '))}
|
||||||
|
${ligne('fiche.source', (s.src || '') + (s.licence ? ` (${s.licence})` : ''))}
|
||||||
|
${ligne('fiche.voir', l)}</dl>
|
||||||
|
<div class="fiche-forum-zone">${FORUM_OUVERT ? '' : `<p class="fiche-bientot">${t('fiche.bientot')}</p>`}</div></section>`;
|
||||||
|
}
|
||||||
|
function chargerFicheForum(id){
|
||||||
|
fetch(`${FORUM}/api/station/${encodeURIComponent(id)}.json?${Math.floor(Date.now() / 300000)}`).then(r => r.ok ? r.json() : null).then(d => {
|
||||||
|
const zone = plein.querySelector('.fiche-forum-zone');
|
||||||
|
if (!d || id !== pleinId || !zone) return;
|
||||||
|
const lien = d.sujet && d.sujet.startsWith(FORUM + '/') ? d.sujet : FORUM + '/';
|
||||||
|
const photos = (d.photos || []).filter(x => typeof x.url === 'string' && x.url.startsWith(FORUM + '/photo/')).slice(0, 3);
|
||||||
|
zone.innerHTML = (photos.length ? `<div class="fiche-photos">${photos.map(x =>
|
||||||
|
`<a href="${echapper(lien)}"><img src="${echapper(x.url)}" alt="${echapper(t('fiche.photo', x.auteur || ''))}" loading="lazy" decoding="async"></a>`).join('')}</div>` : '')
|
||||||
|
+ `<a class="fiche-forum" href="${echapper(lien)}">${t(d.sujet ? 'fiche.sujet' : 'fiche.forum')}</a>`;
|
||||||
|
}).catch(() => {});
|
||||||
|
}
|
||||||
plein.addEventListener('click', ev => {
|
plein.addEventListener('click', ev => {
|
||||||
const o = ev.target.closest('.plein-onglets button');
|
const o = ev.target.closest('.plein-onglets button');
|
||||||
if (o) { pleinId = o.dataset.id; rendrePlein(); return; }
|
if (o) { pleinId = o.dataset.id; rendrePlein(); return; }
|
||||||
|
const periode = ev.target.closest('.plein-periode button');
|
||||||
|
if (periode) {
|
||||||
|
pleinJours = Number(periode.dataset.jours);
|
||||||
|
plein.querySelectorAll('.plein-periode button').forEach(bouton => {
|
||||||
|
bouton.setAttribute('aria-pressed', Number(bouton.dataset.jours) === pleinJours);
|
||||||
|
});
|
||||||
|
if (pleinDonnees) dessinerGraphes();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (ev.target.closest('.plein-carte')) {
|
if (ev.target.closest('.plein-carte')) {
|
||||||
const ids = pleinIds.slice();
|
const ids = pleinIds.slice();
|
||||||
fermerPlein();
|
fermerPlein();
|
||||||
@@ -1898,27 +1972,64 @@ function graduations(bas, haut, n = 4){
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function cadrerCourbes(d, jours){
|
||||||
|
const cles = ['t', 'h', 'v', 'r'];
|
||||||
|
// Écarter le remplissage avant le début de l'archive, puis limiter à la période choisie.
|
||||||
|
const archive = d.archive_depuis == null
|
||||||
|
? d.t.findIndex((_, i) => cles.some(cle => d[cle][i] != null))
|
||||||
|
: Math.floor((d.archive_depuis - d.debut) / d.pas);
|
||||||
|
const periode = d.t.length - 1 - Math.floor(jours * 86400 / d.pas);
|
||||||
|
const i0 = Math.min(Math.max(0, archive, periode), Math.max(0, d.t.length - 2));
|
||||||
|
const vue = {...d, debut: d.debut + i0 * d.pas};
|
||||||
|
for (const cle of cles) vue[cle] = d[cle].slice(i0);
|
||||||
|
return vue;
|
||||||
|
}
|
||||||
|
|
||||||
|
function lacuneTemperature(temperatures, pas){
|
||||||
|
// La pluie a des cases vides prévues entre ses mesures horaires.
|
||||||
|
let duree = 0;
|
||||||
|
return temperatures.some(valeur => {
|
||||||
|
duree = valeur == null ? duree + pas : 0;
|
||||||
|
return duree >= 3 * 3600;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function dessinerGraphes(){
|
function dessinerGraphes(){
|
||||||
let d = pleinDonnees;
|
|
||||||
const zone = plein.querySelector('.graphes');
|
const zone = plein.querySelector('.graphes');
|
||||||
if (!d || !zone) return;
|
if (!pleinDonnees || !zone) return;
|
||||||
// on cadre sur ce que l'archive contient (elle se remplit jour après jour)
|
zone.onpointermove = zone.onpointerdown = zone.onpointerleave = null;
|
||||||
const tout = ['t', 'h', 'v', 'r'].map(k => d[k]);
|
const d = cadrerCourbes(pleinDonnees, pleinJours);
|
||||||
let i0 = 0;
|
|
||||||
while (i0 < d.t.length - 2 && tout.every(a => a[i0] == null)) i0++;
|
|
||||||
if (i0 > 0) { d = {...d, debut: d.debut + i0 * d.pas, t: d.t.slice(i0), h: d.h.slice(i0), v: d.v.slice(i0), r: d.r.slice(i0)}; }
|
|
||||||
const n = d.t.length;
|
const n = d.t.length;
|
||||||
|
if (n < 2) {
|
||||||
|
zone.innerHTML = `<p class="plein-attente">${t('plein.vide')}</p>`;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const infoStation = pleinId === 'lans' || pleinId === 'geve' ? ' ' + t('g.lacune.' + pleinId) : '';
|
||||||
|
const lacune = pleinDonnees.t.some(valeur => valeur != null) && lacuneTemperature(d.t, d.pas)
|
||||||
|
? `<p class="plein-lacune">${t('g.lacune')}${infoStation}</p>`
|
||||||
|
: '';
|
||||||
const hum = d.h.map(v => v != null && v >= 3 ? v : null); // hygromètre défaillant (1 %) : ignoré
|
const hum = d.h.map(v => v != null && v >= 3 ? v : null); // hygromètre défaillant (1 %) : ignoré
|
||||||
const defs = [{cle: 't', titre: t('g.t'), v: d.t, f: fmt, ligne: true, couleurs: couleur}];
|
const defs = [];
|
||||||
|
if (d.t.some(v => v != null)) defs.push({cle: 't', titre: t('g.t'), v: d.t, f: fmt, ligne: true, couleurs: couleur});
|
||||||
if (d.capteurs.humidite && hum.some(v => v != null)) defs.push({cle: 'h', titre: t('g.h'), v: hum, f: v => Math.round(v) + ' %', ligne: true, c: '#3f8c97', borne: [0, 100]});
|
if (d.capteurs.humidite && hum.some(v => v != null)) defs.push({cle: 'h', titre: t('g.h'), v: hum, f: v => Math.round(v) + ' %', ligne: true, c: '#3f8c97', borne: [0, 100]});
|
||||||
if (d.capteurs.vent) defs.push({cle: 'v', titre: t('g.v'), v: d.v, f: v => Math.round(v) + ' km/h', ligne: true, c: '#c99700', zero: true, icone: IC_EOLIENNE});
|
if (d.capteurs.vent && d.v.some(v => v != null)) defs.push({cle: 'v', titre: t('g.v'), v: d.v, f: v => Math.round(v) + ' km/h', ligne: true, c: '#c99700', zero: true, icone: IC_EOLIENNE});
|
||||||
if (d.capteurs.pluie) defs.push({cle: 'r', titre: t('g.r'), v: d.r, f: v => dec(v.toFixed(1)) + ' mm', ligne: false, c: '#2f7fc1', zero: true, icone: IC_GOUTTE});
|
if (d.capteurs.pluie && d.r.some(v => v != null)) defs.push({cle: 'r', titre: t('g.r'), v: d.r, f: v => dec(v.toFixed(1)) + ' mm', ligne: false, c: '#2f7fc1', zero: true, icone: IC_GOUTTE});
|
||||||
const W = Math.max(280, zone.clientWidth), H = 150, ml = 40, mr = 10, mt = 8, mb = 22, pw = W - ml - mr;
|
if (!defs.length) {
|
||||||
|
zone.innerHTML = lacune + `<p class="plein-attente">${t('plein.vide')}</p>`;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const W = Math.max(160, zone.clientWidth), H = 150, ml = 40, mr = 10, mt = 8, mb = 22, pw = W - ml - mr;
|
||||||
const X = i => ml + i / (n - 1) * pw;
|
const X = i => ml + i / (n - 1) * pw;
|
||||||
// repères des jours : minuit, heure de Paris
|
// Repères en heure de Paris : toutes les 6 h sur 24 h, à minuit sur 7 jours.
|
||||||
const jours = [];
|
const reperesTemps = [];
|
||||||
for (let i = 0; i < n; i++) { const t = new Date((d.debut + i * d.pas) * 1000); if (fmtHM.format(t) === '00:00') jours.push([i, fmtMinuit.format(t)]); }
|
for (let i = 0; i < n; i++) {
|
||||||
zone.innerHTML = defs.map((g, k) => {
|
const date = new Date((d.debut + i * d.pas) * 1000);
|
||||||
|
const heure = fmtHM.format(date);
|
||||||
|
if (pleinJours === 1 ? ['00:00', '06:00', '12:00', '18:00'].includes(heure) : heure === '00:00') {
|
||||||
|
reperesTemps.push([i, pleinJours === 1 ? heure : fmtMinuit.format(date)]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
zone.innerHTML = lacune + defs.map((g, k) => {
|
||||||
const vals = g.v.filter(v => v != null);
|
const vals = g.v.filter(v => v != null);
|
||||||
let bas = Math.min(...vals), haut = Math.max(...vals);
|
let bas = Math.min(...vals), haut = Math.max(...vals);
|
||||||
if (g.borne) { bas = g.borne[0]; haut = g.borne[1]; }
|
if (g.borne) { bas = g.borne[0]; haut = g.borne[1]; }
|
||||||
@@ -1943,12 +2054,12 @@ function dessinerGraphes(){
|
|||||||
}
|
}
|
||||||
const zero = g.cle === 't' && bas < 0 && haut > 0 ? `<line x1="${ml}" x2="${W - mr}" y1="${Y(0)}" y2="${Y(0)}" stroke="#3d6f8e" stroke-dasharray="4 3" stroke-opacity=".7"/><text x="${W - mr}" y="${Y(0) - 3}" text-anchor="end" class="gz">${t('g.gel')}</text>` : '';
|
const zero = g.cle === 't' && bas < 0 && haut > 0 ? `<line x1="${ml}" x2="${W - mr}" y1="${Y(0)}" y2="${Y(0)}" stroke="#3d6f8e" stroke-dasharray="4 3" stroke-opacity=".7"/><text x="${W - mr}" y="${Y(0) - 3}" text-anchor="end" class="gz">${t('g.gel')}</text>` : '';
|
||||||
const grille = grad.map(v => `<line x1="${ml}" x2="${W - mr}" y1="${Y(v)}" y2="${Y(v)}" stroke="#e4e0d6"/><text x="${ml - 5}" y="${Y(v) + 3.5}" text-anchor="end">${g.cle === 't' ? Math.round(v) + '°' : Math.round(v * 10) / 10}</text>`).join('');
|
const grille = grad.map(v => `<line x1="${ml}" x2="${W - mr}" y1="${Y(v)}" y2="${Y(v)}" stroke="#e4e0d6"/><text x="${ml - 5}" y="${Y(v) + 3.5}" text-anchor="end">${g.cle === 't' ? Math.round(v) + '°' : Math.round(v * 10) / 10}</text>`).join('');
|
||||||
const reperes = jours.map(([i, nom]) => `<line x1="${X(i)}" x2="${X(i)}" y1="${mt}" y2="${H - mb}" stroke="#d9d4c6"/><text x="${X(i) + 4}" y="${H - 7}">${nom}</text>`).join('');
|
const reperes = reperesTemps.map(([i, nom]) => `<line x1="${X(i)}" x2="${X(i)}" y1="${mt}" y2="${H - mb}" stroke="#d9d4c6"/><text x="${i > (n - 1) * 0.85 ? X(i) - 4 : X(i) + 4}" y="${H - 7}" text-anchor="${i > (n - 1) * 0.85 ? 'end' : 'start'}">${nom}</text>`).join('');
|
||||||
const mm = vals.length ? t('g.mm', g.f(Math.min(...vals)), g.f(Math.max(...vals))) : '';
|
const mm = vals.length ? t('g.mm', g.f(Math.min(...vals)), g.f(Math.max(...vals))) : '';
|
||||||
return `<section class="graphe" data-k="${k}"><header><h3>${g.titre}${g.icone || ''}</h3><span class="g-mm">${mm}</span><b class="g-lect"></b></header>
|
return `<section class="graphe" data-k="${k}"><header><h3>${g.titre}${g.icone || ''}</h3><span class="g-mm">${mm}</span><b class="g-lect"></b></header>
|
||||||
<svg width="${W}" height="${H}" viewBox="0 0 ${W} ${H}">${reperes}${grille}${zero}${trace}
|
<svg width="${W}" height="${H}" viewBox="0 0 ${W} ${H}">${reperes}${grille}${zero}${trace}
|
||||||
<line class="curseur" x1="0" x2="0" y1="${mt}" y2="${H - mb}" visibility="hidden"/><circle class="point" r="3.5" visibility="hidden" fill="#fff" stroke="${g.c || '#1f4d3a'}" stroke-width="2"/></svg></section>`;
|
<line class="curseur" x1="0" x2="0" y1="${mt}" y2="${H - mb}" visibility="hidden"/><circle class="point" r="3.5" visibility="hidden" fill="#fff" stroke="${g.c || '#1f4d3a'}" stroke-width="2"/></svg></section>`;
|
||||||
}).join('') + `<p class="plein-note">${t('g.note', Math.min(7, Math.max(1, Math.round(n * d.pas / 86400))), d.archive_depuis ? new Intl.DateTimeFormat(LOC[L], {day: 'numeric', month: 'long', timeZone: 'Europe/Paris'}).format(new Date(d.archive_depuis * 1000)) : '')}</p>`;
|
}).join('') + `<p class="plein-note">${t('g.note', Math.min(7, Math.max(1, Math.round(n * d.pas / 86400))), d.archive_depuis ? new Intl.DateTimeFormat(LOC[L], {day: 'numeric', month: 'long', timeZone: 'Europe/Paris'}).format(new Date(d.archive_depuis * 1000)) : '', d.pas / 60)}</p>`;
|
||||||
|
|
||||||
// curseur partagé : le doigt ou la souris lit la même heure sur toutes les courbes
|
// curseur partagé : le doigt ou la souris lit la même heure sur toutes les courbes
|
||||||
const gr = [...zone.querySelectorAll('.graphe')];
|
const gr = [...zone.querySelectorAll('.graphe')];
|
||||||
@@ -1979,11 +2090,11 @@ function dessinerGraphes(){
|
|||||||
const i = Math.max(0, Math.min(n - 1, Math.round((ev.clientX - r.left - ml) / pw * (n - 1))));
|
const i = Math.max(0, Math.min(n - 1, Math.round((ev.clientX - r.left - ml) / pw * (n - 1))));
|
||||||
gr.forEach((el, k) => { const v = defs[k].v[i]; if (v != null && defs[k].ligne) el.querySelector('.point').setAttribute('cy', defs[k].Y(v)); });
|
gr.forEach((el, k) => { const v = defs[k].v[i]; if (v != null && defs[k].ligne) el.querySelector('.point').setAttribute('cy', defs[k].Y(v)); });
|
||||||
};
|
};
|
||||||
zone.addEventListener('pointermove', poserPoint);
|
zone.onpointermove = poserPoint;
|
||||||
zone.addEventListener('pointerdown', poserPoint);
|
zone.onpointerdown = poserPoint;
|
||||||
zone.addEventListener('pointerleave', () => gr.forEach(el => {
|
zone.onpointerleave = () => gr.forEach(el => {
|
||||||
el.querySelector('.curseur').setAttribute('visibility', 'hidden'); el.querySelector('.point').setAttribute('visibility', 'hidden'); el.querySelector('.g-lect').textContent = '';
|
el.querySelector('.curseur').setAttribute('visibility', 'hidden'); el.querySelector('.point').setAttribute('visibility', 'hidden'); el.querySelector('.g-lect').textContent = '';
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const lire = async f => { try { return await (await fetch(`data/${f}?${Date.now()}`)).json(); } catch (e) { return null; } };
|
const lire = async f => { try { return await (await fetch(`data/${f}?${Date.now()}`)).json(); } catch (e) { return null; } };
|
||||||
|
|||||||
Référencer dans un nouveau ticket
Bloquer un utilisateur