Fichiers
meteo-vercors/maquettes/accueil-carte/modele.html
T

1473 lignes
101 KiB
HTML
Brut Annotations Historique

Ce fichier contient des caractères Unicode ambigus.
Ce fichier contient des caractères Unicode qui peuvent être confondus avec d'autres caractères. Si vous pensez que c'est intentionnel, vous pouvez ignorer cet avertissement. Utilisez le bouton Échappe pour les dévoiler.
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Météo Vercors : la température du Vercors, station par station</title>
<meta name="theme-color" content="#f5f3ee">
<meta name="description" content="Les températures en direct de 21 stations du Vercors, de Villard-de-Lans à Die : courbes sur 7 jours, vent et pluie.">
<meta property="og:title" content="Météo Vercors"><meta property="og:description" content="Le Vercors en direct, station par station.">
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' fill='%231f4d3a'/%3E%3Cpath d='M3 24 12 9l5 8 3-4 9 11z' fill='%23f5f3ee'/%3E%3C/svg%3E">
<link rel="preload" href="polices/outfit-normal.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="polices/bitter-normal.woff2" as="font" type="font/woff2" crossorigin>
<style>
@font-face{font-family:'Bitter';font-style:italic;font-weight:500;font-display:swap;src:url(polices/bitter-italic.woff2) format('woff2');unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD}
@font-face{font-family:'Bitter';font-style:normal;font-weight:500 700;font-display:swap;src:url(polices/bitter-normal.woff2) format('woff2');unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD}
@font-face{font-family:'Outfit';font-style:normal;font-weight:400 600;font-display:swap;src:url(polices/outfit-normal.woff2) format('woff2');unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD}
:root{
--titre:'Bitter', Georgia, serif;
--texte:'Outfit', system-ui, sans-serif;
--sapin:#1f4d3a; --mousse:#6f8f5c; --calcaire:#f5f3ee; --pierre:#e4e0d6;
--roche:#2b2f2c; --glacier:#6eb5bd; --chaud:#b5643c; --gris:#5d635e;
}
*{box-sizing:border-box}
@font-face{font-family:'GastinelG';font-weight:700;font-display:swap;src:url(polices/inter-g.woff2) format('woff2')}
html{scroll-behavior:smooth}
@media (prefers-reduced-motion:reduce){html{scroll-behavior:auto}}
html,body{margin:0;background:var(--calcaire);color:var(--roche);font-family:var(--texte)}
a{color:inherit}
/* ---------- la carte = l'accueil ---------- */
.carte{position:relative;height:100svh;min-height:600px;overflow:hidden;background:#f2f0e8}
.couche{position:absolute;left:-50%;top:-50%;width:200%;height:200%;display:block;transform-origin:0 0;will-change:transform}
#fond{filter:blur(2px)}
#tuiles{position:absolute;inset:0;overflow:hidden;transition:opacity .35s}
.calque{transition:opacity .35s}
#intro{position:absolute;inset:0;width:100%;height:100%;pointer-events:none}
#intro path{fill:none;stroke:#6b7a6e;stroke-opacity:.38;stroke-width:.8px;vector-effect:non-scaling-stroke;stroke-dasharray:1;stroke-dashoffset:1;animation:trace linear forwards}
#intro path.m{stroke-opacity:.6;stroke-width:1.1px}
@keyframes trace{to{stroke-dashoffset:0}}
.carte.ouverture #tuiles,.carte.ouverture .calque,.carte.ouverture .puce{opacity:0}
.carte.ouverture.fond #tuiles,.carte.ouverture.fond .calque{opacity:1}
.carte.ouverture.stations .puce{opacity:1}
#intro{transition:opacity .4s ease}
.carte.ouverture.fond #intro{opacity:0}
.carte.ouverture.stations .puce > button,.carte.ouverture.stations .puce .pt,.carte.ouverture.stations .puce .fil{animation:arrive .2s cubic-bezier(.2,.8,.2,1) both;animation-delay:var(--d,0ms)}
@keyframes arrive{from{opacity:0;transform:translateY(-6px)}}
.niveau{position:absolute;left:0;top:0;transform-origin:0 0;will-change:transform}
.niveau img{position:absolute;width:513px;height:513px;opacity:0;transition:opacity .25s;pointer-events:none;user-select:none}
.niveau img.vu{opacity:1}
.couche .h0{fill:#f2f0e8}
.couche .h500{fill:#ebede1}
.couche .h900{fill:#e2e8d6}
.couche .h1300{fill:#d5dfc7}
.couche .h1700{fill:#e3dfd2}
.couche .h2000{fill:#ece9e0}
.couche .h2200{fill:#f3f1eb}
.couche .courbe{fill:none;stroke:var(--sapin);stroke-opacity:.15;stroke-width:.5px;vector-effect:non-scaling-stroke;stroke-linejoin:round}
.couche .maitresse{stroke-opacity:.32;stroke-width:.9px}
.couche .riviere{fill:none;stroke:var(--glacier);stroke-width:1.2px;vector-effect:non-scaling-stroke;stroke-linejoin:round;stroke-linecap:round}
.couche .riviere.grande{stroke:#3f8c97;stroke-width:3.2px}
.couche .riviere.moyenne{stroke:#5aa3ad;stroke-width:1.8px}
.couche .fleuve-halo.moyen{stroke-width:4.5px;stroke-opacity:.7}
.couche .fleuve-halo{fill:none;stroke:#fff;stroke-opacity:.85;stroke-width:7px;vector-effect:non-scaling-stroke;stroke-linejoin:round;stroke-linecap:round}
.couche .voile{fill:#f5f3ee;opacity:.2}
.couche .limite{fill:none;stroke:var(--sapin);stroke-opacity:.85;stroke-width:1.6px;vector-effect:non-scaling-stroke;stroke-linejoin:round}
.couche .limite-halo{fill:none;stroke:#fff;stroke-opacity:.7;stroke-width:6px;vector-effect:non-scaling-stroke;stroke-linejoin:round}
.carte{cursor:grab;touch-action:pan-y}
.carte.glisse{cursor:grabbing;user-select:none}
.calque{position:absolute;inset:0;pointer-events:none}
.commandes{position:absolute;right:20px;top:50%;transform:translateY(-50%);z-index:4;display:flex;flex-direction:column}
.commandes button{width:36px;height:36px;font:600 20px/1 var(--texte);color:var(--roche);background:rgba(250,249,245,.95);border:1px solid var(--roche);border-radius:0;cursor:pointer}
.commandes button+button{border-top:0}
.commandes button:hover{background:#fff}
.commandes button:disabled{color:#b9bcb5;cursor:default}
.etq{position:absolute;white-space:nowrap;transform:translate(-50%,-50%);
text-shadow:0 0 2px #f4f2ea,0 0 2px #f4f2ea,0 0 3px #f4f2ea,0 0 5px #f4f2ea}
.etq.village{font-size:12px;font-weight:500;color:var(--roche);transform:translate(7px,-50%)}
.etq.village::before{content:"";position:absolute;left:-7px;top:50%;width:4px;height:4px;margin-top:-2px;background:var(--roche)}
.etq.ville{font-size:11.5px;font-weight:600;letter-spacing:.12em;text-transform:uppercase;color:var(--gris)}
.etq.pic{font-family:var(--titre);font-style:italic;font-size:12px;color:#55574f;transform:translate(-50%,-2px)}
.etq.pic::before{content:"";display:block;margin:0 auto 2px;width:0;height:0;border-left:4px solid transparent;border-right:4px solid transparent;border-bottom:6px solid #55574f}
.etq.pic small{font-style:normal;font-family:var(--texte);font-size:10.5px;margin-left:4px;color:var(--gris)}
.etq.region{font-family:var(--titre);font-size:14px;letter-spacing:.4em;text-transform:uppercase;color:var(--sapin);opacity:.55}
.etq.lieudit{font-family:var(--titre);font-style:italic;font-size:12px;color:#3f7f88}
.etq.fleuve{font-family:var(--titre);font-style:italic;font-size:14px;letter-spacing:.14em;color:#2f7480}
.etq.cache{display:none}
/* mesures : une puce par village ou par site */
.puce{position:absolute;pointer-events:auto}
.puce .pt{position:absolute;left:-4px;top:-4px;width:8px;height:8px;background:var(--roche);outline:2px solid #fff}
.puce .fil{position:absolute;background:var(--roche);height:1px;transform-origin:0 0}
.puce > button{position:absolute;font:inherit;color:inherit;text-align:left;cursor:pointer;white-space:nowrap;
background:rgba(250,249,245,.95);border:1px solid var(--roche);border-radius:0;padding:4px 8px 5px}
.puce > button:hover,.puce.ouverte > button{background:#fff}
.puce .val{display:inline-block;font-family:var(--titre);font-weight:600;font-size:21px;line-height:1;font-variant-numeric:tabular-nums}
.puce .n{display:inline-block;margin-left:6px;padding:1px 4px;font-size:10.5px;font-weight:600;vertical-align:4px;background:var(--roche);color:#fff}
.puce .nom{display:block;margin-top:3px;font-size:10px;font-weight:600;letter-spacing:.08em;text-transform:uppercase}
.puce.cache{display:none}
.puce > button.ex .val{opacity:.45;font-style:italic}
.puce > button.hl .val{color:var(--gris)!important;text-decoration:line-through}
.fiche{position:absolute;display:none;background:#fff;border:1px solid var(--roche);width:272px;padding:12px 14px;z-index:6;pointer-events:auto}
.puce.ouverte{z-index:6}
.puce.ouverte .fiche{display:block;transform-origin:top left;animation:ouvre .26s cubic-bezier(.2,.8,.2,1)}
.puce.ouverte .fiche li{animation:ligne .32s cubic-bezier(.2,.8,.2,1) both;animation-delay:calc(var(--i) * 45ms + 70ms)}
.puce.ouverte > button{box-shadow:inset 0 -3px 0 var(--sapin)}
.puce > button{transition:background .15s,transform .15s}
.puce > button:hover{transform:translateY(-1px)}
@keyframes ouvre{from{opacity:0;transform:translateY(-6px);clip-path:inset(0 0 100% 0)}to{opacity:1;transform:none;clip-path:inset(0 0 0 0)}}
@keyframes ligne{from{opacity:0;transform:translateX(-8px)}}
.puce.ferme .fiche{animation:fermeture .17s ease-in forwards}
@keyframes fermeture{to{opacity:0;transform:translateY(-6px);clip-path:inset(0 0 100% 0)}}
@media (prefers-reduced-motion:reduce){.puce.ouverte .fiche,.puce.ouverte .fiche li{animation:none}}
.fiche h3{margin:0 0 8px;font-family:var(--titre);font-size:17px;font-weight:600}
.fiche ul{list-style:none;margin:0;padding:0;max-height:300px;overflow:auto}
.fiche li{display:grid;grid-template-columns:1fr auto;gap:2px 10px;padding:7px 0;border-top:1px solid var(--pierre)}
.fiche li b{font-family:var(--titre);font-size:19px;font-weight:600;text-align:right}
.fiche li span{font-size:13px}
.fiche li em{grid-column:1/-1;font-style:normal;font-size:11.5px;color:var(--gris)}
.ic{display:inline-block;width:14px;height:14px;vertical-align:-2px;margin-left:5px}
.fiche li em .ic{margin:0 5px 0 0}
.fiche .actions{display:flex;flex-direction:column;align-items:flex-start;gap:8px;margin-top:10px}
.fiche .pleinbtn{font:inherit;font-size:11.5px;font-weight:600;letter-spacing:.1em;text-transform:uppercase;background:var(--sapin);color:#fff;border:0;border-radius:0;padding:7px 10px;cursor:pointer}
.fiche .pleinbtn:hover{background:#17392b}
#plein{position:fixed;inset:0;z-index:30;background:var(--calcaire);overflow:auto;opacity:0;transform:translateY(14px);transition:opacity .22s ease,transform .26s cubic-bezier(.2,.8,.2,1)}
#plein.vu{opacity:1;transform:none}
#plein[hidden]{display:none}
.plein-barre{position:sticky;top:0;z-index:2;display:flex;gap:10px;align-items:center;padding:10px 16px;background:rgba(245,243,238,.94);-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);border-bottom:1px solid var(--pierre)}
.plein-ferme{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:9px 12px;cursor:pointer;white-space:nowrap}
.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.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}
.plein-val span{font-size:13.5px;color:var(--gris)}
.plein-carte{margin-left:auto;font:inherit;font-size:12px;font-weight:600;color:var(--sapin);background:none;border:1px solid var(--sapin);border-radius:0;padding:7px 10px;cursor:pointer}
.graphe{margin-top:26px}
.graphe header{display:flex;align-items:baseline;gap:6px 14px;flex-wrap:wrap;margin-bottom:6px}
.graphe h3{margin:0;font-family:var(--titre);font-weight:600;font-size:17px}
.g-mm{font-size:12px;color:var(--gris)}
.g-lect{margin-left:auto;font-size:12.5px;font-weight:600;font-variant-numeric:tabular-nums}
.graphe > svg{display:block;max-width:100%;touch-action:pan-y;font-family:var(--texte);font-size:10.5px;fill:var(--gris)}
.graphe > svg .gz{fill:#3d6f8e}
.graphe > svg .curseur{stroke:var(--roche);stroke-width:1}
.plein-note,.plein-attente{margin:24px 0 0;font-size:12px;color:var(--gris)}
.fiche .zoom{display:inline-block;margin-top:8px;font:inherit;font-size:13px;font-weight:600;color:var(--sapin);background:none;border:0;padding:0;cursor:pointer;text-decoration:underline}
/* cartouche : le titre posé sur la carte, comme sur une carte imprimée */
.cartouche{position:absolute;top:28px;left:28px;width:340px;z-index:4;
background:rgba(250,249,245,.95);border:1px solid var(--roche);outline:1px solid var(--roche);outline-offset:4px;padding:16px 20px 18px}
.cartouche nav{display:flex;justify-content:space-between;align-items:baseline;font-size:11px;font-weight:600;letter-spacing:.16em;text-transform:uppercase}
.cartouche nav span{color:var(--sapin);font-size:16px;letter-spacing:.22em}
.cartouche nav a{text-decoration:none;margin-left:14px;color:var(--gris)}
.cartouche nav a:hover{color:var(--roche);text-decoration:underline}
.cartouche h1{margin:6px 0 0;font-family:var(--titre);font-weight:700;font-size:66px;line-height:.95;letter-spacing:-.015em;color:var(--sapin)}
.cartouche .date{margin:8px 0 0;font-size:13px;color:var(--gris)}
.cartouche .phrase{margin:14px 0 0;padding-top:12px;border-top:1px solid var(--pierre);font-family:var(--titre);font-size:16px;line-height:1.4}
.cartouche .phrase strong{font-weight:600}
.cartouche .reseau{margin:10px 0 0;font-size:12.5px;color:var(--gris)}
.pendule{position:absolute;top:calc(100% + 6px);left:50%;transform:translateX(-50%);padding-top:21px;pointer-events:none}
.pendule .corde{position:absolute;top:0;width:1px;height:22px;background:var(--roche);transform-origin:50% 0;will-change:transform}
.pancarte{will-change:transform}
.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;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}
#rech-res{position:absolute;left:0;right:0;top:100%;z-index:8;margin:2px 0 0;padding:0;list-style:none;background:#fff;border:1px solid var(--roche);max-height:260px;overflow:auto}
#rech-res li{padding:7px 9px;font-size:13.5px;cursor:pointer;border-top:1px solid var(--pierre)}
#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}
.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}
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}
#retour.vu{display:inline-block}
.legende{position:absolute;left:28px;bottom:22px;z-index:3;font-size:11.5px;color:var(--gris);
text-shadow:0 0 3px #f4f2ea,0 0 3px #f4f2ea}
.echelle{display:flex;align-items:flex-end;gap:8px;color:var(--roche)}
.sous-carte{max-width:1080px;margin:0 auto;padding:10px 28px 0;font-size:11.5px;color:var(--gris)}
.echelle i{display:block;height:5px;border:1px solid var(--roche);background:linear-gradient(90deg,var(--roche) 50%,#fff 50%);background-size:50% 100%}
.thermo{position:absolute;right:28px;bottom:22px;z-index:3;font-size:11px;color:var(--gris);text-align:right;
text-shadow:0 0 3px #f4f2ea,0 0 3px #f4f2ea}
.thermo i{display:block;width:180px;height:6px;margin:4px 0 3px;border:1px solid var(--roche)}
.thermo span{display:flex;justify-content:space-between}
.suite{position:absolute;left:50%;bottom:16px;transform:translateX(-50%);z-index:3;font-size:12px;font-weight:600;letter-spacing:.14em;text-transform:uppercase;color:var(--sapin);text-decoration:none;
padding:8px 14px;--coin:linear-gradient(var(--sapin),var(--sapin));
background:var(--coin) left top/9px 1.5px,var(--coin) left top/1.5px 9px,var(--coin) right top/9px 1.5px,var(--coin) right top/1.5px 9px,
var(--coin) left bottom/9px 1.5px,var(--coin) left bottom/1.5px 9px,var(--coin) right bottom/9px 1.5px,var(--coin) right bottom/1.5px 9px,
rgba(250,249,245,.45);
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)}
.record{flex:0 0 100%;font-size:11.5px;color:var(--gris)}
.record select{font:inherit;font-size:11.5px;color:var(--sapin);background:#fff;border:1px solid var(--pierre);border-radius:0;padding:3px 4px;margin-left:4px}
.compte{display:inline-flex;align-items:center;gap:8px;padding:5px 11px 5px 7px;background:#fff;border:1px solid #000;color:#000;font-size:12px;font-weight:600;text-decoration:none}
.compte:hover{background:#ecebe5}
.compte .gmark{font-family:'GastinelG','Inter',system-ui,sans-serif;font-weight:700;font-size:22px;line-height:1;color:#000;letter-spacing:-.02em}
.legende{left:auto;right:222px}
.forum-box{position:absolute;left:28px;bottom:16px;z-index:3;width:372px;background:rgba(250,249,245,.97);border:1px solid var(--roche);box-shadow:0 0 0 3px rgba(250,249,245,.97),0 0 0 4px var(--pierre);color:var(--roche)}
.fb-haut{display:flex;justify-content:space-between;align-items:baseline;padding:12px 16px 2px}
.fb-haut b{font-family:var(--titre);font-weight:700;font-size:28px;color:var(--sapin);line-height:1.1}
.fb-haut small{font-size:11px;font-weight:600;letter-spacing:.1em;text-transform:uppercase;color:var(--gris)}
.fb-une{padding:4px 16px 12px;border-bottom:1px solid var(--pierre)}
.fb-une small{display:block;font-size:11px;letter-spacing:.08em;text-transform:uppercase;color:var(--gris)}
.fb-une a{display:block;margin-top:2px;font-family:var(--titre);font-weight:600;font-size:17px;line-height:1.3;color:var(--roche);text-decoration:none}
.fb-une a:hover{text-decoration:underline}
.fb-une span{font-size:12.5px;color:var(--gris)}
.fb-cta{display:block;margin:12px 16px 6px;padding:11px 14px;background:var(--sapin);color:#fff;text-align:center;font-size:13px;font-weight:600;letter-spacing:.07em;text-transform:uppercase;text-decoration:none;border:1px solid var(--sapin)}
.fb-cta:hover{background:#17382b}
.fb-co{margin:0 16px 12px;text-align:center;font-size:12.5px;color:var(--gris)}
.fb-co a{display:inline-flex;align-items:center;gap:5px;color:#000;font-weight:600;text-decoration:underline;text-underline-offset:2px}
.fb-co .g{font-family:'GastinelG','Inter',system-ui,sans-serif;font-weight:700;font-size:17px;line-height:1;text-decoration:none}
.fb-bas{display:flex;gap:12px;align-items:center;padding:10px 16px;background:#303336;color:#d9dbde;font-size:12.5px;line-height:1.4}
.fb-bas .gcarre{flex:0 0 32px;height:32px;display:grid;place-items:center;background:#fff;color:#000;font-family:'GastinelG','Inter',system-ui,sans-serif;font-weight:700;font-size:22px}
.fb-bas strong{color:#fff;font-weight:600}
.forum-box.ferme .fb-co{display:none}
.forum-box.ferme .fb-cta{background:#7d8a82;border-color:#7d8a82;cursor:default}
.forum-box.ferme .fb-une a{pointer-events:none}
.forum-box.mobile{display:none}
@media (max-width:1000px){.forum-box{left:auto;right:28px;bottom:68px;width:320px}.legende{left:28px;right:auto}}
@media (max-width:719px){.carte .forum-box{display:none}.forum-box.mobile{display:block;position:static;width:auto;flex:0 0 100%;margin:6px 0 4px}}
.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}
/* ---------- panneaux déroulants ---------- */
.panneaux{max-width:1080px;margin:0 auto;padding:36px 28px 32px;display:grid;gap:14px}
.panneau{border:1px solid var(--roche);background:#faf9f5}
.panneau-tete{display:flex;align-items:baseline;gap:14px;width:100%;padding:18px 20px;background:none;border:0;border-radius:0;cursor:pointer;text-align:left;font:inherit;color:var(--sapin)}
.panneau-tete b{font-family:var(--titre);font-weight:600;font-size:24px}
.panneau-tete small{font-size:13px;color:var(--gris)}
.panneau-tete i{margin-left:auto;align-self:center;width:9px;height:9px;border-right:2px solid var(--sapin);border-bottom:2px solid var(--sapin);transform:rotate(45deg);transition:transform .4s ease}
.panneau.ouvert .panneau-tete i{transform:rotate(225deg)}
.panneau-corps{display:grid;grid-template-rows:0fr;transition:grid-template-rows .45s ease}
.panneau.ouvert .panneau-corps{grid-template-rows:1fr}
.panneau-in{overflow:hidden;min-height:0}
.corps-liste{padding:2px 20px 22px}
.corps-liste > p{margin:0 0 14px;color:var(--gris);font-size:14.5px}
.corps-liste h3{font-family:var(--titre);font-weight:600;font-size:18px;margin:22px 0 10px}
.bilan{display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));border-top:1px solid var(--roche);border-left:1px solid var(--roche)}
.bilan div{padding:12px 14px;border-right:1px solid var(--roche);border-bottom:1px solid var(--roche);background:#faf9f5}
.bilan small{display:block;font-size:11.5px;letter-spacing:.06em;text-transform:uppercase;color:var(--gris)}
.bilan b{display:block;font-family:var(--titre);font-size:28px;margin:2px 0}
.bilan span{font-size:13px;color:var(--roche)}
.bilan-note{margin:10px 0 0;font-size:12px;color:var(--gris)}
@media (prefers-reduced-motion:reduce){.panneau-corps,.panneau-tete i{transition:none}}
@media (max-width:719px){.panneaux{padding:24px 16px 24px}.panneau-tete{padding:14px 14px;flex-wrap:wrap;gap:2px 10px}.panneau-tete b{font-size:20px}.corps-liste{padding:2px 14px 18px}}
/* ---------- 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)}
.liste > p{margin:0 0 22px;color:var(--gris);font-size:14.5px}
.liste h3{font-family:var(--titre);font-weight:600;font-size:18px;margin:26px 0 10px}
.grille{display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:0;border-top:1px solid var(--roche);border-left:1px solid var(--roche)}
.case{font:inherit;color:inherit;text-align:left;cursor:pointer;border:0;border-radius:0;border-right:1px solid var(--roche);border-bottom:1px solid var(--roche);padding:12px 14px;text-decoration:none;background:#faf9f5}
.case:hover{background:#fff}
.case.ex b{opacity:.45;font-style:italic}
.case small{display:block;font-size:11px;font-weight:600;letter-spacing:.08em;text-transform:uppercase;color:var(--gris)}
.case strong{display:block;font-size:14.5px;font-weight:600;margin:2px 0 6px}
.case b{font-family:var(--titre);font-size:30px;font-weight:600;line-height:1}
.case em{display:block;font-style:normal;font-size:12px;color:var(--gris);margin-top:5px}
.pied{background:#303336;color:#d1d3d6;padding:34px 28px 22px;font-size:13px;line-height:1.7;border-top:4px solid #1c1d1f}
.pied-grille{max-width:1080px;margin:0 auto;display:grid;grid-template-columns:1.4fr 1fr 1fr;gap:34px}
.pied p{margin:6px 0}
.pied h4{margin:0 0 8px;font-family:var(--texte);font-size:11.5px;font-weight:600;letter-spacing:.12em;text-transform:uppercase;color:#fff;border-bottom:1px solid #4a4d51;padding-bottom:7px}
.pied ul{list-style:none;margin:0;padding:0}
.pied .accroche{font-family:var(--titre);font-style:italic;font-size:17px;color:#fff}
.pied a{color:#b9c2cc;text-decoration:none;font-weight:500}
.pied a:hover{color:#fff;text-decoration:underline}
.pied-bas{max-width:1080px;margin:26px auto 0!important;padding-top:14px;border-top:1px solid #45484c;font-size:12px;color:#8e9298}
@media (max-width:720px){
.carte{min-height:0}
.cartouche{top:0;left:0;right:0;width:auto;padding:12px 16px 12px;border:0;outline:0;border-bottom:1px solid var(--pierre);
background:rgba(250,249,245,.9);-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px)}
.cartouche h1{font-size:46px}
.cartouche{cursor:pointer;transition:padding .35s ease}
.pendule{display:none}
.cartouche h1{transition:font-size .35s ease,margin .35s ease}
.cartouche .phrase,.cartouche .reseau,.cartouche .date{max-height:160px;overflow:hidden;transition:max-height .35s ease,opacity .25s ease,margin .35s ease,padding .35s ease}
.cartouche.replie .phrase,.cartouche.replie .reseau,.cartouche.replie .date{max-height:0;opacity:0;margin-top:0;padding-top:0;border-top-color:transparent}
.cartouche.replie #retour,.cartouche.replie .outils{display:none}
.cartouche.replie h1{font-size:30px;margin-top:2px}
.cartouche.replie{padding-bottom:9px}
.cartouche .phrase{font-size:14.5px;margin-top:10px;padding-top:9px}
.legende{left:14px;bottom:14px}
.legende .credits{display:none}
.thermo{right:14px;bottom:14px}
.thermo i{width:110px}
.commandes{right:10px}
.suite{display:none}
.puce .val{font-size:18px}
.fiche{width:244px}
.liste{padding:40px 16px 24px}
.pied{padding:26px 16px 30px}
.pied-grille{grid-template-columns:1fr;gap:22px}
.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>
<main class="carte ouverture" id="carte" aria-label="Carte des stations météo du Vercors">
<!--SVG-->
<div class="calque" id="calque"></div>
<div class="commandes" id="commandes"><button type="button" id="plus" aria-label="Zoomer">+</button><button type="button" id="moins" aria-label="Dézoomer">−</button></div>
<header class="cartouche" id="cartouche">
<nav><span>Météo</span><div><a href="#stations">Stations</a><a href="a-propos.html">À propos</a></div></nav>
<h1>Vercors</h1>
<p class="date" id="date">Mardi 3 novembre · relevés de 7 h 40</p>
<p class="phrase" id="phrase"></p>
<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>
<label class="record">Mise en avant <select id="record"><option value="auto">Selon la saison</option><option value="froid">Plus froid</option><option value="chaud">Plus chaud</option><option value="vent">Plus de vent</option><option value="pluie">Plus de pluie</option></select></label>
</div>
<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>
</header>
<div class="legende" id="legende">
<div class="echelle"><i id="barre"></i><span id="km">5 km</span></div>
</div>
<a class="suite" href="#stations">Toutes les stations ↓</a>
<div class="forum-box">
<div class="fb-haut"><b>Forum</b><small data-n></small></div>
<div class="fb-une"><small>À la une · Récapitulatif de la semaine</small><a href="forum/index.html" data-une>Le récapitulatif de la semaine arrive ici</a><span data-auteur></span></div>
<a class="fb-cta" href="forum/index.html">Rejoindre la discussion →</a>
<p class="fb-co">Déjà un compte ? <a href="forum/connexion.html"><span class="g" aria-hidden="true">G</span>Se connecter avec Gastinel</a></p>
<div class="fb-bas"><span class="gcarre" aria-hidden="true">G</span><span><strong>L'écosystème Gastinel.</strong> Un compte pour le forum, vos favoris et toutes nos applications. Sans publicité, une alternative aux GAFAM.</span></div>
</div>
<div class="thermo" id="thermo"><i id="degrade"></i><span><span>−10°</span><span>0°</span><span>+15°</span></span></div>
</main>
<p class="sous-carte">Courbes de niveau tous les 100 m · zoom : molette (PC) ou deux doigts (téléphone)</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 class="forum-box mobile">
<div class="fb-haut"><b>Forum</b><small data-n></small></div>
<div class="fb-une"><small>À la une · Récapitulatif de la semaine</small><a href="forum/index.html" data-une>Le récapitulatif de la semaine arrive ici</a><span data-auteur></span></div>
<a class="fb-cta" href="forum/index.html">Rejoindre la discussion →</a>
<p class="fb-co">Déjà un compte ? <a href="forum/connexion.html"><span class="g" aria-hidden="true">G</span>Se connecter avec Gastinel</a></p>
<div class="fb-bas"><span class="gcarre" aria-hidden="true">G</span><span><strong>L'écosystème Gastinel.</strong> Un compte pour le forum, vos favoris et toutes nos applications. Sans publicité, une alternative aux GAFAM.</span></div>
</div>
</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="panneaux" id="stations">
<div class="panneau" id="p-stations">
<button type="button" class="panneau-tete" aria-expanded="false" aria-controls="c-stations"><b>Les stations</b><small>toutes, du nord au sud</small><i aria-hidden="true"></i></button>
<div class="panneau-corps" id="c-stations" inert><div class="panneau-in"><div class="corps-liste">
<p>Sur la carte : une valeur par village ou par site ; le détail ici.</p>
<div id="secteurs"></div>
</div></div></div>
</div>
<div class="panneau" id="p-bilan">
<button type="button" class="panneau-tete" aria-expanded="false" aria-controls="c-bilan"><b>Bilan de la semaine</b><small>records des 7 derniers jours</small><i aria-hidden="true"></i></button>
<div class="panneau-corps" id="c-bilan" inert><div class="panneau-in"><div class="corps-liste" id="bilan">Chargement…</div></div></div>
</div>
</section>
<footer class="pied">
<div class="pied-grille">
<div>
<p class="accroche">Des stations de chez nous, des chiffres d'ici.</p>
<p>Données : Météo-France (Licence Ouverte), Infoclimat (CC BY ou CC BY-NC selon la station), WeatherLink, station Gastinel. Fond de carte : IGN, licence ouverte.</p>
</div>
<div>
<h4>Contact</h4>
<ul><li><a href="mailto:studio@gastinel.me">studio@gastinel.me</a></li>
<li><a href="https://wa.me/message/XAHBYTJZNQ6TK1" rel="noopener">WhatsApp</a></li>
<li><a href="tel:+33636276419">06 36 27 64 19</a></li></ul>
</div>
<div>
<h4>Le site</h4>
<ul><li><a href="a-propos.html">À propos</a></li><li><a href="a-propos.html#sources">Sources et licences</a></li><li><a href="a-propos.html#mentions">Mentions légales</a></li><li><a href="cgu.html">CGU</a></li><li><a href="confidentialite.html">Confidentialité</a></li></ul>
<p>SIRET <a href="https://entreprises.lefigaro.fr/nd-38/entreprise-104816749" rel="noopener">10481674900014</a></p>
</div>
</div>
<p class="pied-bas">© Théo Gastinel · Météo Vercors</p>
</footer>
<noscript><p style="max-width:640px;margin:0 auto;padding:16px;font-family:system-ui">Météo Vercors a besoin de JavaScript pour afficher la carte et les relevés en direct. Les sources et les mentions légales sont sur la page <a href="a-propos.html">À propos</a>.</p></noscript>
<script>
const C = /*CARTE*/;
const ETIQ = /*ETIQUETTES*/;
const FORUM_OUVERT = false; // passer à true quand le forum et la connexion Gastinel sont en ligne
// Stations du Vercors relevées dans les notes (Boîte + liste du 16/10) ; valeurs d'exemple (matin d'inversion)
const STATIONS = {
'autrans': {nom:'Autrans – L\'Escandille', src:'Météo-France', alt:1069, lat:45.182, lon:5.5522, t:-4.8},
'geve': {nom:'Autrans – Gêve nordique', src:'WeatherLink', alt:1353, lat:45.213, lon:5.56, t:-1.6},
'engins': {nom:'Engins', src:'ROMMA', alt:905, lat:45.1796, lon:5.6172, t:-2.9},
'meaudre': {nom:'Méaudre', src:'WeatherLink', alt:976, lat:45.1306, lon:5.5288, t:-6.4},
'lans': {nom:'Lans-en-Vercors – village', src:'WeatherLink', alt:1020, lat:45.13, lon:5.60, t:-2.8},
'bruyeres': {nom:'Lans-en-Vercors – Les Bruyères', src:'WeatherLink', alt:990, lat:45.10, lon:5.57, t:-4.1},
'allieres': {nom:'Lans-en-Vercors – Les Allières', src:'WeatherLink', alt:1449, lat:45.095, lon:5.6002, t:0.9},
'villard': {nom:'Villard-de-Lans – Payonère', src:'Météo-France', alt:1027, lat:45.0785, lon:5.561, t:-3.6},
'moucherolle': {nom:'Crête de la Moucherolle', src:'Infoclimat', alt:1965, lat:45.0093, lon:5.5575, t:2.1},
'chapelle': {nom:'La Chapelle-en-Vercors – Les Finets', src:'Météo-France', alt:879, lat:44.9615, lon:5.4222, t:-5.2},
'oscence': {nom:'Combe de l\'Oscence', src:'ROMMA', alt:1000, lat:44.972, lon:5.3835, t:-8.9},
'darbounouse': {nom:'Combe de Darbounouse', src:'Infoclimat', alt:1282, lat:44.9676, lon:5.4771, t:-11.2},
'rousset': {nom:'Col du Rousset – plateau de Beurre', src:'Météo-France', alt:1400, lat:44.8417, lon:5.4217, t:-0.5},
'gresse': {nom:'Gresse-en-Vercors', src:'Météo-France', alt:1220, lat:44.8998, lon:5.5657, t:-3.9},
'st-jean': {nom:'Saint-Jean-en-Royans', src:'Météo-France', alt:308, lat:45.0092, lon:5.2925, t:2.6},
'rochechinard': {nom:'Rochechinard', src:'Infoclimat', alt:683, lat:45.0215, lon:5.2477, t:3.1},
'die': {nom:'Die', src:'Infoclimat', alt:400, lat:44.75, lon:5.3667, t:1.9},
'st-julien-q': {nom:'Saint-Julien-en-Quint', src:'Infoclimat', alt:574, lat:44.8378, lon:5.2922, t:-0.8},
'marignac': {nom:'Marignac-en-Diois', src:'Infoclimat', alt:600, lat:44.8093, lon:5.3492, t:0.4},
'archiane': {nom:'Cirque d\'Archiane', src:'Infoclimat', alt:747, lat:44.7445, lon:5.5064, t:-2.7},
'solaure': {nom:'Solaure-en-Diois', src:'Infoclimat', alt:442, lat:44.7065, lon:5.3984, t:1.2},
};
// Une puce par village ou site ; la 1re station est celle affichée. Ordre = priorité d'affichage.
const GROUPES = [
{nom:'Darbounouse', st:['darbounouse'], sect:'Hauts-Plateaux et Vercors drômois'},
{nom:'Villard-de-Lans', st:['villard'], sect:'Quatre-Montagnes'},
{nom:'La Chapelle', st:['chapelle'], sect:'Hauts-Plateaux et Vercors drômois'},
{nom:'Autrans', st:['autrans','geve'], sect:'Quatre-Montagnes'},
{nom:'Méaudre', st:['meaudre'], sect:'Quatre-Montagnes'},
{nom:'Lans-en-Vercors', st:['lans','bruyeres','allieres'], sect:'Quatre-Montagnes'},
{nom:'Moucherolle', st:['moucherolle'], sect:'Quatre-Montagnes'},
{nom:'Col du Rousset', st:['rousset'], sect:'Hauts-Plateaux et Vercors drômois'},
{nom:'Gresse', st:['gresse'], sect:'Trièves et Gresse'},
{nom:'Die', st:['die'], sect:'Diois'},
{nom:'St-Jean-en-Royans', st:['st-jean','rochechinard'], sect:'Royans'},
{nom:'Oscence', st:['oscence'], sect:'Hauts-Plateaux et Vercors drômois'},
{nom:'Engins', st:['engins'], sect:'Quatre-Montagnes'},
{nom:'Archiane', st:['archiane'], sect:'Diois'},
{nom:'St-Julien-en-Quint', st:['st-julien-q'], sect:'Diois'},
{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.
const NOMS = {geve:'Gêve', bruyeres:'Les Bruyères', allieres:'Les Allières', rochechinard:'Rochechinard'};
const PUCES = [...GROUPES.map(g => ({nom: g.nom, st: [g.st[0]]})),
...GROUPES.flatMap(g => g.st.slice(1).map(id => ({nom: NOMS[id], st: [id], parent: g.nom})))];
const P = (lon, lat) => [(lon - C.lon0) * C.k * C.m, (C.lat1 - lat) * C.m];
const fmt = v => v == null ? '—' : (v < 0 ? '−' : v > 0 ? '+' : '') + Math.abs(v).toFixed(1).replace('.', ',') + '°';
const court = n => n.split(' – ').pop();
const STOPS = [[-10,[36,95,107]],[-3,[56,128,138]],[3,[31,77,58]],[9,[120,104,52]],[15,[181,100,60]]];
function couleur(t){
if (t == null) return 'var(--gris)';
if (t <= STOPS[0][0]) return `rgb(${STOPS[0][1]})`;
for (let i = 1; i < STOPS.length; i++) if (t <= STOPS[i][0]) {
const [a, ca] = STOPS[i-1], [b, cb] = STOPS[i], u = (t - a) / (b - a);
return `rgb(${ca.map((v, j) => Math.round(v + (cb[j] - v) * u))})`;
}
return `rgb(${STOPS.at(-1)[1]})`;
}
document.getElementById('degrade').style.background =
`linear-gradient(90deg,${[-10,-6,-3,0,3,6,9,12,15].map(couleur).join(',')})`;
// tant que les données réelles ne sont pas arrivées, tout est exemple
Object.values(STATIONS).forEach(x => { x.t = x.mn = x.mx = null; x.exemple = true; });
// phrase du jour : le point le plus froid, et l'inversion si elle se voit
const MOMENT = h => h < 5 ? 'Cette nuit' : h < 12 ? 'Ce matin' : h < 18 ? 'Cet après-midi' : h < 23 ? 'Ce soir' : 'Cette nuit';
let RECORD = 'auto';
try { RECORD = localStorage.getItem('vm-record') || 'auto'; } catch (e) {}
// saisons météorologiques : hiver = décembre à février, été = juin à août
function saisonMeteo(){
const m = parseInt(new Intl.DateTimeFormat('fr-FR', {month: 'numeric', timeZone: 'Europe/Paris'}).format(new Date()), 10);
return m === 12 || m <= 2 ? 'hiver' : m >= 6 && m <= 8 ? 'ete' : 'entre';
}
function phraseDuJour(){
const toutes = Object.values(STATIONS), reelles = toutes.filter(x => x.t != null);
if (!reelles.length) {
document.getElementById('phrase').textContent = 'Relevés en cours de chargement…';
document.getElementById('reseau').textContent = `${toutes.length} stations dans le massif`;
return;
}
const l = [...reelles].sort((a, b) => a.t - b.t), f = l[0], c = l[l.length - 1], deg = t => fmt(t).replace('°', ' °C');
const sais = saisonMeteo(), mode = RECORD !== 'auto' ? RECORD : sais === 'hiver' ? 'froid' : sais === 'ete' ? 'chaud' : 'ecart';
const mom = MOMENT(heureParis());
let s;
if (mode === 'chaud') s = `${mom}, <strong>${deg(c.t)} à ${court(c.nom)}</strong>, le point le plus chaud du massif en ce moment.`;
else if (mode === 'ecart') s = `${mom}, de <strong>${deg(f.t)} à ${court(f.nom)}</strong> à <strong>${deg(c.t)} à ${court(c.nom)}</strong> : le plus froid et le plus chaud du massif.`;
else if (mode === 'vent') {
const v = toutes.filter(x => x.vent != null && capteur(Object.keys(STATIONS).find(k => STATIONS[k] === x), 'vent')).sort((a, b) => b.vent - a.vent)[0];
s = v ? `${mom}, <strong>${Math.round(v.vent)} km/h à ${court(v.nom)}</strong>, le vent moyen le plus fort du massif.` : `${mom}, aucun vent mesuré pour l'instant.`;
} else if (mode === 'pluie') {
const r = toutes.filter(x => x.pluie != null && x.pluie > 0).sort((a, b) => b.pluie - a.pluie)[0];
s = r ? `${mom}, <strong>${nb1(r.pluie)} mm en une heure à ${court(r.nom)}</strong>, la pluie la plus forte du massif.` : `${mom}, pas de pluie mesurée dans le massif.`;
} else {
s = `${mom}, <strong>${deg(f.t)} à ${court(f.nom)}</strong>, le point le plus froid du massif en ce moment.`;
const h = l.filter(x => x.alt - f.alt >= 300 && x.t - f.t >= 3).sort((a, b) => b.alt - a.alt)[0];
if (h) s += ` ${h.alt - f.alt} m plus haut, ${court(h.nom)} : ${deg(h.t)}. L'air froid est resté au fond.`;
}
document.getElementById('phrase').innerHTML = s;
document.getElementById('reseau').textContent = `${reelles.length} stations en direct sur ${toutes.length} · Météo-France, Infoclimat, station Gastinel`;
}
function heureParis(d = new Date()){ return +new Intl.DateTimeFormat('en-GB', {hour: '2-digit', hourCycle: 'h23', timeZone: 'Europe/Paris'}).format(d); }
phraseDuJour();
// ---- calques ----
const carte = document.getElementById('carte'), calque = document.getElementById('calque'),
cart = document.getElementById('cartouche'),
retour = document.getElementById('retour');
const etqs = ETIQ.map(e => {
const d = document.createElement('div');
d.className = 'etq ' + e.t;
d.innerHTML = e.n + (e.t === 'pic' && e.ele ? `<small>${e.ele}</small>` : '');
calque.appendChild(d);
return {e, d, xy: P(e.lon, e.lat)};
});
const puces = PUCES.map(g => {
const m = document.createElement('div');
m.className = 'puce';
m.innerHTML = '<i class="fil"></i><i class="pt"></i><button type="button" aria-expanded="false"></button><div class="fiche"></div>';
carte.appendChild(m);
const p = {g, m, b: m.querySelector('button'), xy: P(STATIONS[g.st[0]].lon, STATIONS[g.st[0]].lat), ids: g.st};
p.b.addEventListener('click', ev => { ev.stopPropagation(); ouvrir(p); });
m.querySelector('.fiche').addEventListener('click', ev => {
ev.stopPropagation();
if (ev.target.closest('.zoom')) { fermer(); zoomer(boite(p.ids)); }
if (ev.target.closest('.pleinbtn')) { fermer(); ouvrirPlein(p.ids.filter(i => STATIONS[i]), p.ids[0]); }
});
return p;
});
function fermer(){
puces.forEach(x => {
if (!x.m.classList.contains('ouverte')) return;
x.b.setAttribute('aria-expanded', 'false');
if (reduit) { x.m.classList.remove('ouverte'); return; }
x.m.classList.add('ferme');
clearTimeout(x.minuteur);
x.minuteur = setTimeout(() => x.m.classList.remove('ouverte', 'ferme'), 170);
});
}
document.addEventListener('click', fermer);
// pincer sur la carte zoome la carte, pas la page (Safari : gesturestart ; autres : toucher à deux doigts)
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]})), 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);
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>`;
if (hb !== p.hb) { p.b.innerHTML = hb; p.hb = hb; }
if (hf !== p.hf) { p.m.querySelector('.fiche').innerHTML = hf; p.hf = hf; }
}
function ouvrir(p){
if (carte.clientWidth < 720) { fermer(); ouvrirPlein(p.ids, p.ids[0]); return; } // téléphone : plein écran direct
const o = !p.m.classList.contains('ouverte');
fermer();
// une puce qui regroupe plusieurs sites : on zoome directement, la fiche reste pour le reste
if (o && p.absorbe && !p.mini) { zoomer(boite(p.ids)); return; }
if (o) { clearTimeout(p.minuteur); p.m.classList.remove('ferme'); p.m.classList.add('ouverte'); p.b.setAttribute('aria-expanded', 'true'); }
}
function boite(ids){
const la = ids.map(i => STATIONS[i].lat), lo = ids.map(i => STATIONS[i].lon);
const cx = (Math.min(...lo) + Math.max(...lo)) / 2, cy = (Math.min(...la) + Math.max(...la)) / 2;
const dx = Math.max(Math.max(...lo) - Math.min(...lo), 0.09) / 2 + 0.03, dy = Math.max(Math.max(...la) - Math.min(...la), 0.07) / 2 + 0.03;
return [cx - dx, cy + dy, cx + dx, cy - dy];
}
function chevauche(a, b){ return !(a.right < b.left || a.left > b.right || a.bottom < b.top || a.top > b.bottom); }
// Vue libre : centre (unités de la carte, 100 m) et échelle (px par unité).
// « cible » est la vue visée : la vue affichée la rejoint en douceur à chaque image.
// La carte est faite d'images pré-calculées (4 niveaux de zoom) : à chaque image affichée, on ne fait
// que les déplacer et les agrandir (transformation CSS, faite par la carte graphique).
let vue = null, cible = null, Z = null, bornes = null, boucleId = 0, sMin = 1, largeur = 0, actif = 0, calcul = 0;
const S_MAX = 9, reduit = matchMedia('(prefers-reduced-motion: reduce)').matches;
const T = /*TUILES*/, dPnr = document.getElementById('d-pnr');
const couches = T.niveaux.map(n => {
const d = document.createElement('div');
d.className = 'niveau';
document.getElementById('tuiles').appendChild(d);
return {n, d, imgs: new Map()};
});
// place les images : le niveau 0 couvre tout (dessous), le niveau adapté à l'échelle se pose dessus
function poser(){
const {W, H} = Z, s = vue.s, vx = vue.cx - Z.cx / s, vy = vue.cy - Z.cy / s;
const voulu = Math.min(couches.length - 1, Math.max(0, Math.ceil(Math.log2(s * devicePixelRatio * 0.85))));
couches.forEach((c, k) => {
const affiche = k === 0 || k === voulu;
c.d.style.display = affiche ? '' : 'none';
if (!affiche) return;
const sl = c.n.s, a = T.taille / sl;
c.d.style.transform = `translate3d(${(T.ox - vx) * s}px,${(T.oy - vy) * s}px,0) scale(${s / sl})`;
const i0 = Math.max(c.n.i0, Math.floor((vx - T.ox) / a)), i1 = Math.min(c.n.i1, Math.floor((vx + W / s - T.ox) / a));
const j0 = Math.max(c.n.j0, Math.floor((vy - T.oy) / a)), j1 = Math.min(c.n.j1, Math.floor((vy + H / s - T.oy) / a));
for (let i = i0; i <= i1; i++) for (let j = j0; j <= j1; j++) {
const cle = i + '_' + j;
if (c.imgs.has(cle)) continue;
const img = new Image();
img.decoding = 'async'; img.alt = '';
img.style.left = i * T.taille + 'px'; img.style.top = j * T.taille + 'px';
img.onload = () => img.classList.add('vu');
img.src = `tuiles/${c.n.L}/${cle}.webp?v=${T.version}`;
c.d.appendChild(img); c.imgs.set(cle, img);
}
});
}
// zone utile de la carte : hors cartouche et marges
function zone(){
const W = carte.clientWidth, mob = W < 720;
const r0 = carte.getBoundingClientRect(), rc = cart.getBoundingClientRect();
const pxL = mob ? 0 : rc.right - r0.left + 16, pxT = mob ? rc.bottom - r0.top + 6 : 0;
const pad = mob ? [46, 12, 64, 12] : [46, 60, 70, 30]; // haut, droite, bas, gauche
const H = carte.clientHeight, aw = W - pxL - pad[1] - pad[3], ah = H - pxT - pad[0] - pad[2];
return {W, H, mob, r0, aw, ah, pxT, pad, cx: pxL + pad[3] + aw / 2, cy: pxT + pad[0] + ah / 2};
}
function ajuster(b, z){
const [ax, ay] = P(b[0], b[1]), [bx, by] = P(b[2], b[3]);
return {cx: (ax + bx) / 2, cy: (ay + by) / 2, s: Math.min(z.aw / (bx - ax), z.ah / (by - ay))};
}
function borner(v){
// jamais plus dézoomé que la vue de départ, et jamais hors de ce qu'elle montre
v.s = Math.min(S_MAX, Math.max(sMin, v.s));
if (bornes) {
const z = Z || zone();
const vx = Math.min(bornes.x1 - z.W / v.s, Math.max(bornes.x0, v.cx - z.cx / v.s));
const vy = Math.min(bornes.y1 - z.H / v.s, Math.max(bornes.y0, v.cy - z.cy / v.s));
v.cx = vx + z.cx / v.s; v.cy = vy + z.cy / v.s;
}
return v;
}
// vue obtenue en zoomant d'un facteur f autour d'un point de l'écran (px dans la carte)
function autour(f, mx, my, base = cible || vue){
const z = Z || zone(), s = base.s, ns = Math.min(S_MAX, Math.max(sMin, s * f));
const ux = base.cx + (mx - z.cx) / s, uy = base.cy + (my - z.cy) / s;
return borner({cx: ux - (mx - z.cx) / ns, cy: uy - (my - z.cy) / ns, s: ns});
}
function viser(v){ cible = v; actif = performance.now(); relancer(); }
function zoomer(b){ viser(borner(ajuster(b, Z || zone()))); }
function relancer(){ if (!boucleId) boucleId = requestAnimationFrame(boucle); }
function boucle(){
boucleId = 0;
if (!vue) { disposer(); return; }
let bouge = false;
if (cible) {
const k = reduit || document.hidden ? 1 : 0.2;
const ls = Math.log(vue.s), lc = Math.log(cible.s);
vue = {cx: vue.cx + (cible.cx - vue.cx) * k, cy: vue.cy + (cible.cy - vue.cy) * k, s: Math.exp(ls + (lc - ls) * k)};
if (Math.abs(lc - ls) < 0.003 && Math.hypot(cible.cx - vue.cx, cible.cy - vue.cy) * vue.s < 0.4) { vue = cible; cible = null; }
else bouge = true;
}
// geste en cours : images et étiquettes suivent à chaque image ; les regroupements de stations
// sont recalculés quelques fois par seconde, donc les stations se séparent pendant le zoom
const t = performance.now();
if (bouge || t - actif < 150) { if (t - calcul > 120) disposer(); else suivre(); relancer(); }
else if (disposer()) relancer();
}
retour.addEventListener('click', () => zoomer(MASSIF));
// première vue : tout le massif ; sur téléphone la carte prend la hauteur qu'il lui faut
function initialiser(){
largeur = carte.clientWidth;
carte.style.height = '';
let z = zone();
if (z.mob) {
const [ax, ay] = P(MASSIF[0], MASSIF[1]), [bx, by] = P(MASSIF[2], MASSIF[3]);
carte.style.height = Math.round(z.pxT + z.pad[0] + (by - ay) * z.aw / (bx - ax) + z.pad[2]) + 'px';
z = zone();
}
vue = ajuster(MASSIF, z); sMin = vue.s; cible = null;
// ce que montre la vue de départ = la zone où l'on peut se déplacer
const x0 = vue.cx - z.cx / sMin, y0 = vue.cy - z.cy / sMin;
bornes = {x0, y0, x1: x0 + z.W / sMin, y1: y0 + z.H / sMin};
}
// le point de l'écran est-il dans le Parc ? (la molette y zoome ; ailleurs elle fait défiler la page)
function dansParc(mx, my){
const z = Z, s = vue.s;
try { return dPnr.isPointInFill(new DOMPoint(vue.cx + (mx - z.cx) / s, vue.cy + (my - z.cy) / s)); }
catch (e) { return true; }
}
carte.addEventListener('wheel', ev => {
if (!vue || !Z || ev.target.closest('.cartouche, .fiche')) return;
const r = carte.getBoundingClientRect(), mx = ev.clientX - r.left, my = ev.clientY - r.top;
if (!ev.ctrlKey && !dansParc(mx, my)) return;
// dans le Parc, la molette ne fait jamais défiler la page (tout dézoomé, elle ne fait rien)
ev.preventDefault();
const f = Math.exp(-ev.deltaY * (ev.deltaMode ? 0.06 : 0.0022));
viser(autour(f, mx, my));
}, {passive: false});
carte.addEventListener('dblclick', ev => {
if (ev.target.closest('button, a, .fiche, .cartouche, .commandes')) return;
const r = carte.getBoundingClientRect();
viser(autour(ev.shiftKey ? 0.5 : 2, ev.clientX - r.left, ev.clientY - r.top));
});
// glisser à la souris ; au doigt, un doigt fait défiler la page, deux doigts déplacent et zooment.
// Le geste suit le doigt sans retard : la vue est posée directement.
const doigts = new Map();
carte.addEventListener('pointerdown', ev => {
// au doigt, une étiquette de station compte aussi pour pincer ; à la souris, elle reste un bouton
const zoneLibre = ev.pointerType === 'touch' ? '.fiche, .cartouche, .commandes' : 'button, a, .fiche, .cartouche, .commandes';
if (ev.target.closest(zoneLibre)) return;
doigts.set(ev.pointerId, {x: ev.clientX, y: ev.clientY});
if (ev.pointerType === 'mouse') { carte.setPointerCapture(ev.pointerId); carte.classList.add('glisse'); }
});
carte.addEventListener('pointermove', ev => {
if (!doigts.has(ev.pointerId)) return;
const avant = [...doigts.values()].map(p => ({...p}));
doigts.set(ev.pointerId, {x: ev.clientX, y: ev.clientY});
const apres = [...doigts.values()];
if (ev.pointerType === 'touch' && apres.length < 2) return;
const r = carte.getBoundingClientRect();
const milieu = l => [l.reduce((a, p) => a + p.x, 0) / l.length - r.left, l.reduce((a, p) => a + p.y, 0) / l.length - r.top];
const [x0, y0] = milieu(avant), [x1, y1] = milieu(apres);
let v = vue;
if (apres.length >= 2) {
const d = l => Math.hypot(l[0].x - l[1].x, l[0].y - l[1].y) || 1;
v = autour(d(apres) / d(avant), x1, y1, vue);
}
vue = borner({...v, cx: v.cx - (x1 - x0) / v.s, cy: v.cy - (y1 - y0) / v.s});
cible = null; actif = performance.now(); relancer();
});
['pointerup', 'pointercancel'].forEach(t => carte.addEventListener(t, ev => { doigts.delete(ev.pointerId); carte.classList.remove('glisse'); }));
document.getElementById('plus').addEventListener('click', () => { const z = Z || zone(); viser(autour(2, z.cx, z.cy)); });
document.getElementById('moins').addEventListener('click', () => { const z = Z || zone(); viser(autour(0.5, z.cx, z.cy)); });
function echelle(s){
if (s > sMin * 1.05) replier(true); // zoomer replie le cartouche sur téléphone
const km = [1, 2, 5, 10, 20].find(k => k * 10 * s >= 60) || 20;
document.getElementById('barre').style.width = (km * 10 * s) + 'px';
document.getElementById('km').textContent = km + ' km';
retour.classList.toggle('vu', s > sMin * 1.15);
document.getElementById('plus').disabled = s >= S_MAX;
document.getElementById('moins').disabled = s <= sMin * 1.001;
}
// à chaque image d'un geste : les images suivent, puces et noms glissent avec, sans recalcul
function suivre(){
if (!Z) return;
poser();
const s = vue.s, vx = vue.cx - Z.cx / s, vy = vue.cy - Z.cy / s;
const ecran = ([x, y]) => [(x - vx) * s, (y - vy) * s];
puces.forEach(p => {
if (p.m.classList.contains('cache')) return;
[p.x, p.y] = ecran(p.xy);
p.m.style.left = p.x + 'px'; p.m.style.top = p.y + 'px';
});
etqs.forEach(({d, xy}) => {
if (d.classList.contains('cache')) return;
const [x, y] = ecran(xy);
d.style.left = x + 'px'; d.style.top = y + 'px';
});
echelle(s);
}
// placement complet : images, puis puces (regroupements) et noms (sans chevauchement).
// Renvoie vrai tant qu'une puce est en mouvement.
function disposer(){
if (!carte.clientWidth) return false;
if (!vue) initialiser();
const z = Z = zone(), {W, H, mob, r0} = z, s = vue.s;
const vx = vue.cx - z.cx / s, vy = vue.cy - z.cy / s;
calcul = performance.now();
poser();
echelle(s);
const ecran = ([x, y]) => [(x - vx) * s, (y - vy) * s];
const interdits = [cart, document.getElementById('legende'), document.getElementById('thermo'), document.getElementById('commandes'), document.getElementById('pendule')]
.map(el => { const r = el.getBoundingClientRect();
return {left: r.left - 8, top: r.top - 8, right: r.right + 8, bottom: r.bottom + 8}; });
const dedans = r => r.left >= r0.left + 4 && r.right <= r0.right - 4 && r.top >= r0.top + 4 && r.bottom <= r0.bottom - 4;
// puces : au-dessus du point, sinon dessous, à droite, à gauche ; sinon fusion avec la voisine
const posees = [];
puces.forEach(p => {
p.avant = p.etat; p.dansAvant = p.dans; p.etat = 'hors'; p.dans = null;
p.ids = p.g.st.slice(); p.absorbe = false; p.mini = s > 5; p.titre = p.g.nom; p.m.classList.remove('cache');
p.force = null;
});
// tant qu'on n'a pas bien zoomé, les stations d'un même village restent dans la puce du village
// (comptées avant le placement, pour que la puce soit mesurée avec son « +N »)
if (s < sMin * 2.2) puces.forEach(p => {
if (!p.g.parent) return;
const v = puces.find(q => q.g.nom === p.g.parent);
if (v) { v.ids.push(...p.ids); p.force = v; }
});
// la station la plus froide et la plus chaude du moment passent en premier : jamais cachées dans un « +N »
const vivantes = puces.filter(p => !p.force && STATIONS[p.g.st[0]].t != null);
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 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
const hors = x < 0 || y < 0 || x > W || y > H;
// la puce de son village d'abord, sinon la plus proche
const pres = q => Math.hypot(q.p.x - x, q.p.y - y);
const village = posees.find(q => q.p.g.nom === p.g.parent && pres(q) < 220);
const q = !hors && (village || posees.length && posees.reduce((a, b) => pres(a) < pres(b) ? a : b));
if (q && (q === village || pres(q) < 160)) { q.p.ids.push(...p.ids); q.p.absorbe = true; remplir(q.p); p.etat = 'dans'; p.dans = q.p; }
p.m.classList.add('cache');
return;
}
p.b.style.left = choix.dx + 'px'; p.b.style.top = choix.dy + 'px';
const fx = Math.min(Math.max(0, choix.dx), choix.dx + bw), fy = Math.min(Math.max(0, choix.dy), choix.dy + bh);
const fil = p.m.querySelector('.fil');
fil.style.width = Math.hypot(fx, fy) + 'px';
fil.style.transform = `rotate(${Math.atan2(fy, fx)}rad)`;
posees.push({p, r: choix.r});
p.etat = 'vue';
});
// séparation : la puce sort de celle qui la contenait ; fusion : elle y rentre en s'effaçant
const t = performance.now(), D = 300, doux = u => 1 - Math.pow(1 - u, 3);
let anime = false;
puces.forEach(p => {
if (!reduit && p.etat === 'vue' && p.avant === 'dans' && p.dansAvant) p.anim = {t, sens: 'sort', de: p.dansAvant};
if (!reduit && p.etat === 'dans' && p.avant === 'vue') p.anim = {t, sens: 'entre'};
if (p.anim && (p.anim.sens === 'sort' ? p.etat !== 'vue' : p.etat !== 'dans')) p.anim = null;
const u = p.anim ? Math.min(1, (t - p.anim.t) / D) : 1;
if (u >= 1) p.anim = null;
if (!p.anim) { p.m.style.transform = ''; p.m.style.opacity = ''; return; }
anime = true;
const e = doux(u);
if (p.anim.sens === 'sort') {
const k = 1 - e;
p.m.style.transform = `translate(${(p.anim.de.x - p.x) * k}px, ${(p.anim.de.y - p.y) * k}px) scale(${0.6 + 0.4 * e})`;
p.m.style.opacity = e;
} else {
p.m.classList.remove('cache');
p.m.style.transform = `translate(${(p.dans.x - p.x) * e}px, ${(p.dans.y - p.y) * e}px) scale(${1 - 0.4 * e})`;
p.m.style.opacity = 1 - e;
}
});
// une fusion peut élargir une puce déjà posée : on garde sa place, la fiche se cale dessous
const fw = mob ? 244 : 272;
posees.forEach(({p}) => {
const f = p.m.querySelector('.fiche'), bl = parseFloat(p.b.style.left), bt = parseFloat(p.b.style.top);
f.style.left = Math.max(-p.x + 8, Math.min(bl, W - p.x - fw - 8)) + 'px';
f.style.top = (bt + p.b.offsetHeight + 6) + 'px';
});
posees.forEach(q => interdits.push(q.r, {left: r0.left + q.p.x - 7, right: r0.left + q.p.x + 7, top: r0.top + q.p.y - 7, bottom: r0.top + q.p.y + 7}));
// étiquettes : priorité selon l'échelle, puis sans chevauchement
const seuil = s > 3 ? 3 : s > 1.6 ? 2 : 1;
const placees = [];
etqs.sort((a, b) => a.e.p - b.e.p).forEach(({e, d, xy}) => {
d.classList.remove('cache');
const [x, y] = ecran(xy);
if (e.p > seuil || x < 0 || y < 0 || x > W || y > H) { d.classList.add('cache'); return; }
d.style.left = x + 'px'; d.style.top = y + 'px';
const r = d.getBoundingClientRect();
const g = {left: r.left - 4, right: r.right + 4, top: r.top - 3, bottom: r.bottom + 3};
if (!dedans(r) || interdits.some(z => chevauche(g, z)) || placees.some(z => chevauche(g, z))) d.classList.add('cache');
else placees.push(g);
});
return anime;
}
// 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 => { 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);
});
// Forum : tant qu'il n'est pas ouvert (connexion Gastinel non branchée), l'encadré annonce l'ouverture sans faux bouton
if (!FORUM_OUVERT) document.querySelectorAll('.forum-box').forEach(b => {
b.classList.add('ferme');
const cta = b.querySelector('.fb-cta'); cta.removeAttribute('href'); cta.setAttribute('aria-disabled', 'true'); cta.textContent = 'Ouverture prochainement';
const une = b.querySelector('[data-une]'); une.removeAttribute('href'); une.textContent = 'Le récapitulatif de la semaine, par les adhérents, arrive bientôt.';
b.querySelector('.fb-une small').textContent = 'Bientôt';
});
// panneaux déroulants (stations, bilan)
function basculer(p, oui){
const o = oui == null ? !p.classList.contains('ouvert') : oui;
p.classList.toggle('ouvert', o);
p.querySelector('.panneau-tete').setAttribute('aria-expanded', o);
p.querySelector('.panneau-corps').inert = !o;
if (o && p.id === 'p-bilan') remplirBilan();
}
document.querySelectorAll('.panneau-tete').forEach(b => b.addEventListener('click', () => basculer(b.closest('.panneau'))));
document.querySelectorAll('a[href="#stations"]').forEach(a => a.addEventListener('click', ev => {
ev.preventDefault(); basculer(document.getElementById('p-stations'), true);
document.getElementById('stations').scrollIntoView({behavior: reduit ? 'auto' : 'smooth', block: 'start'});
}));
// lien partagé #stations : on ouvre le panneau puis on efface l'ancre, pour qu'un rechargement depuis le haut de page ne redescende pas
if (location.hash === '#stations') { basculer(document.getElementById('p-stations'), true); history.replaceState(null, '', location.pathname + location.search); }
async function remplirBilan(){
const z = document.getElementById('bilan');
await chargerSeries();
if (!SERIES || !Object.keys(SERIES).length) { z.textContent = 'Pas encore assez de relevés.'; return; }
let fr, ch, vt, pl, debut = Infinity;
Object.entries(SERIES).forEach(([id, d]) => {
debut = Math.min(debut, d.archive_depuis || d.debut);
const cap = SEM[id] || {};
d.t.forEach((v, i) => {
const ts = d.debut + i * d.pas;
if (v != null) { if (!fr || v < fr.v) fr = {v, id, ts}; if (!ch || v > ch.v) ch = {v, id, ts}; }
if (cap.vent && d.v[i] != null && (!vt || d.v[i] > vt.v)) vt = {v: d.v[i], id, ts};
if (cap.pluie && d.r[i] != null && d.r[i] > 0 && (!pl || d.r[i] > pl.v)) pl = {v: d.r[i], id, ts};
});
});
const jours = (Date.now() / 1000 - debut) / 86400;
const quand = r => `${court(STATIONS[r.id].nom)} · ${fmtJH.format(new Date(r.ts * 1000)).replace(',', '')}`;
const carte = (titre, r, val) => `<div><small>${titre}</small><b>${r ? val(r.v) : '—'}</b><span>${r ? quand(r) : 'aucune mesure'}</span></div>`;
z.innerHTML = `<div class="bilan">${carte('Le plus froid', fr, fmt)}${carte('Le plus chaud', ch, fmt)}${carte('Vent moyen maximal', vt, v => Math.round(v) + ' km/h')}${carte('Pluie la plus forte en 1 h', pl, v => nb1(v) + ' mm')}</div>`
+ (jours < 6.5 ? `<p class="bilan-note">L'archive couvre ${Math.max(1, Math.round(jours * 10) / 10).toString().replace('.', ',')} jours pour l'instant ; elle se complète jour après jour.</p>` : '');
}
// données en direct : postes Météo-France (collecteur toutes les 6 min) et stations Infoclimat (extraction du fichier LAN)
const POSTES_MF = {'mf-autrans': 'autrans', 'mf-villard': 'villard', 'mf-chapelle': 'chapelle',
'mf-rousset': 'rousset', 'mf-gresse': 'gresse', 'mf-st-jean': 'st-jean'};
let dernierReleve = null, heureReleve = '';
function afficherDirect(){
if (!dernierReleve) return;
const min = Math.max(0, Math.round((Date.now() - dernierReleve) / 60000));
const d = document.getElementById('direct');
d.textContent = `Relevés de ${heureReleve} · ${min < 1 ? 'à l’instant' : min < 120 ? `il y a ${min} min` : `il y a ${Math.round(min / 60)} h`}`;
d.classList.toggle('vieux', min > 45);
}
setInterval(afficherDirect, 30000);
// la pancarte se balance au bout de ses cordes : à chaque passage au milieu, nouvelle amplitude (15 px au plus d'un bord à l'autre) et nouvelle période
(function(){
const pendule = document.getElementById('pendule');
if (reduit) return;
const cordes = [...pendule.querySelectorAll('.corde')], plaque = pendule.querySelector('.pancarte'), L = 22;
let ph = 0, A = 6, P = 3000, avant = performance.now();
const balancer = t => {
const dt = Math.min(100, t - avant); avant = t;
const ancien = ph; ph += dt / P * 2 * Math.PI;
if (Math.floor(ancien / Math.PI) !== Math.floor(ph / Math.PI)) { A = 3 + Math.random() * 4.5; P = 2600 + Math.random() * 1600; }
const x = A * Math.sin(ph), a = Math.asin(x / L);
cordes.forEach(c => { c.style.transform = `rotate(${-a}rad)`; });
plaque.style.transform = `translate(${x}px,${L * (1 - Math.cos(a))}px)`;
requestAnimationFrame(balancer);
};
requestAnimationFrame(balancer);
})();
// recherche : stations d'abord, puis villages et sommets de la carte
const RECH = [];
Object.keys(STATIONS).forEach(id => RECH.push({n: STATIONS[id].nom, id, lon: STATIONS[id].lon, lat: STATIONS[id].lat, t: 'station'}));
ETIQ.filter(e => ['village', 'ville', 'pic'].includes(e.t)).forEach(e => RECH.push({n: e.n, lon: e.lon, lat: e.lat, t: e.t === 'pic' ? 'sommet' : 'commune'}));
const norm = x => x.normalize('NFD').replace(/[\u0300-\u036f]/g, '').toLowerCase().replace(/[^a-z0-9]+/g, ' ').trim();
const rech = document.getElementById('rech'), resultats = document.getElementById('rech-res');
let choixRech = -1;
function listerRecherche(){
const q = norm(rech.value);
const l = q ? RECH.filter(r => norm(r.n).includes(q)).sort((a, b) => (a.t === 'station' ? 0 : 1) - (b.t === 'station' ? 0 : 1)).slice(0, 7) : [];
resultats.innerHTML = l.map((r, i) => `<li data-i="${RECH.indexOf(r)}" class="${i === choixRech ? 'on' : ''}">${r.n}<small>${r.t}</small></li>`).join('');
resultats.hidden = !l.length;
return l;
}
function allerA(r){
resultats.hidden = true; rech.blur(); rech.value = '';
fermer();
const b = r.id ? boite([r.id]) : [r.lon - 0.05, r.lat + 0.04, r.lon + 0.05, r.lat - 0.04];
zoomer(b);
if (r.id) setTimeout(() => { const p = puces.find(q => q.ids.includes(r.id) && !q.m.classList.contains('cache')); if (p) ouvrir(p); }, 650);
}
rech.addEventListener('input', () => { choixRech = -1; listerRecherche(); });
rech.addEventListener('keydown', ev => {
const l = listerRecherche();
if (ev.key === 'ArrowDown') { choixRech = Math.min(l.length - 1, choixRech + 1); listerRecherche(); ev.preventDefault(); }
else if (ev.key === 'ArrowUp') { choixRech = Math.max(0, choixRech - 1); listerRecherche(); ev.preventDefault(); }
else if (ev.key === 'Enter' && l.length) { allerA(l[Math.max(0, choixRech)]); }
else if (ev.key === 'Escape') { resultats.hidden = true; }
});
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 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);
});
(FORUM_OUVERT ? fetch('data/forum-une.json?' + Math.floor(Date.now() / 300000)).then(r => r.ok ? r.json() : null).then(u => {
if (!u || !u.titre) return;
document.querySelectorAll('[data-une]').forEach(a => { a.textContent = u.titre; if (u.url) a.href = u.url; });
document.querySelectorAll('[data-auteur]').forEach(e => { e.textContent = u.auteur ? 'par ' + u.auteur : ''; });
if (u.n) document.querySelectorAll('[data-n]').forEach(e => { e.textContent = u.n + (u.n > 1 ? ' sujets' : ' sujet') + ' cette semaine'; });
}).catch(() => {}) : 0);
function apresDonnees(){ chargerSeries(); if (TEMPS != null) { snapshotLive(); appliquerTemps(); } }
const selRecord = document.getElementById('record');
selRecord.value = RECORD;
selRecord.addEventListener('change', () => { RECORD = selRecord.value; try { localStorage.setItem('vm-record', RECORD); } catch (e) {} phraseDuJour(); });
['rech', 'modes'].forEach(i => document.getElementById(i).addEventListener('click', ev => ev.stopPropagation()));
// 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(){} // 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, select, label, .rech') || carte.clientWidth >= 720) return;
const ouvrir = cart.classList.contains('replie');
replier(!ouvrir); if (ouvrir) armerRepli();
});
armerRepli();
// ---- plein écran d'une station : courbes sur 7 jours (archive du serveur) ----
const IC_GOUTTE = '<svg class="ic" viewBox="0 0 16 16" role="img" aria-label="Pluviomètre"><title>Pluviomètre</title><path d="M8 1.4C8 1.4 3 7.1 3 10.3a5 5 0 0 0 10 0C13 7.1 8 1.4 8 1.4z" fill="#2f7fc1"/></svg>';
const IC_EOLIENNE = '<svg class="ic" viewBox="0 0 16 16" role="img" aria-label="Anémomètre"><title>Anémomètre</title><path d="M7.3 7h1.4l.5 8H6.8z" fill="#d9a400"/><g fill="#d9a400"><path d="M8 6.6 7.1.9h1.8z"/><path transform="rotate(120 8 6.6)" d="M8 6.6 7.1.9h1.8z"/><path transform="rotate(240 8 6.6)" d="M8 6.6 7.1.9h1.8z"/><circle cx="8" cy="6.6" r="1.2"/></g></svg>';
let SEM = {}; // capteurs connus par station (index de l'archive)
function icones(id){ const c = SEM[id]; return c ? `${c.pluie ? IC_GOUTTE : ''}${c.vent ? IC_EOLIENNE : ''}` : ''; }
const plein = document.createElement('div');
plein.id = 'plein'; plein.hidden = true;
plein.setAttribute('role', 'dialog'); plein.setAttribute('aria-modal', 'true'); plein.setAttribute('aria-label', 'Détail de la station');
plein.innerHTML = '<div class="plein-barre"><button type="button" class="plein-ferme">← Retour à la carte</button><nav class="plein-onglets"></nav></div><div class="plein-corps"></div>';
document.body.appendChild(plein);
let pleinIds = [], pleinId = null, pleinDonnees = null;
const fmtJH = new Intl.DateTimeFormat('fr-FR', {weekday: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit', hourCycle: 'h23', timeZone: 'Europe/Paris'});
const fmtMinuit = new Intl.DateTimeFormat('fr-FR', {weekday: 'short', day: 'numeric', timeZone: 'Europe/Paris'});
const fmtHM = new Intl.DateTimeFormat('en-GB', {hour: '2-digit', minute: '2-digit', hourCycle: 'h23', timeZone: 'Europe/Paris'});
function ouvrirPlein(ids, id = ids[0]){
pleinIds = ids.slice(); pleinId = id;
const deja = !plein.hidden;
plein.hidden = false;
document.documentElement.style.overflow = 'hidden';
if (!deja) { history.pushState({plein: 1}, '', '#station=' + id); requestAnimationFrame(() => plein.classList.add('vu')); }
else history.replaceState({plein: 1}, '', '#station=' + id);
rendrePlein();
plein.scrollTop = 0;
plein.querySelector('.plein-ferme').focus({preventScroll: true});
}
function masquerPlein(){
if (location.hash.startsWith('#station=')) history.replaceState(null, '', location.pathname + location.search);
plein.classList.remove('vu');
document.documentElement.style.overflow = '';
setTimeout(() => { if (!plein.classList.contains('vu')) plein.hidden = true; }, reduit ? 0 : 260);
}
function fermerPlein(){ if (history.state && history.state.plein) history.back(); else masquerPlein(); }
addEventListener('popstate', () => { if (!plein.hidden && !(history.state && history.state.plein)) masquerPlein(); });
addEventListener('keydown', ev => { if (ev.key === 'Escape' && !plein.hidden) fermerPlein(); });
plein.querySelector('.plein-ferme').addEventListener('click', fermerPlein);
function rendrePlein(){
const id = pleinId, s = STATIONS[id];
plein.querySelector('.plein-onglets').innerHTML = pleinIds.length > 1
? 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)}${(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>
<div class="graphes"><p class="plein-attente">Chargement des courbes…</p></div>`;
pleinDonnees = null;
fetch(`data/semaine/${id}.json?${Math.floor(Date.now() / 300000)}`).then(r => r.json()).then(d => {
if (id !== pleinId) return;
pleinDonnees = d; dessinerGraphes();
}).catch(() => {
if (id === pleinId) plein.querySelector('.graphes').innerHTML = '<p class="plein-attente">Pas encore de courbes pour cette station.</p>';
});
}
plein.addEventListener('click', ev => {
const o = ev.target.closest('.plein-onglets button');
if (o) { pleinId = o.dataset.id; rendrePlein(); return; }
if (ev.target.closest('.plein-carte')) {
const ids = pleinIds.slice();
fermerPlein();
setTimeout(() => zoomer(boite(ids)), 320);
}
});
addEventListener('resize', () => { if (!plein.hidden && pleinDonnees) dessinerGraphes(); });
// graduations « rondes » entre bas et haut
function graduations(bas, haut, n = 4){
const brut = (haut - bas) / n, mag = Math.pow(10, Math.floor(Math.log10(brut || 1)));
const pas = [1, 2, 2.5, 5, 10].map(k => k * mag).find(p => p >= brut) || mag * 10;
const out = [];
for (let v = Math.ceil(bas / pas) * pas; v <= haut + 1e-9; v += pas) out.push(+v.toFixed(6));
return out;
}
function dessinerGraphes(){
let d = pleinDonnees;
const zone = plein.querySelector('.graphes');
if (!d || !zone) return;
// on cadre sur ce que l'archive contient (elle se remplit jour après jour)
const tout = ['t', 'h', 'v', 'r'].map(k => d[k]);
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 hum = d.h.map(v => v != null && v >= 3 ? v : null); // hygromètre défaillant (1 %) : ignoré
const defs = [{cle: 't', titre: 'Température', v: d.t, f: fmt, ligne: true, couleurs: couleur}];
if (d.capteurs.humidite && hum.some(v => v != null)) defs.push({cle: 'h', titre: 'Humidité', v: hum, f: v => Math.round(v) + ' %', ligne: true, c: '#3f8c97', borne: [0, 100]});
if (d.capteurs.vent) defs.push({cle: 'v', titre: 'Vent moyen', 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: 'Pluie (par heure)', v: d.r, f: v => v.toFixed(1).replace('.', ',') + ' 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;
const X = i => ml + i / (n - 1) * pw;
// repères des jours : minuit, heure de Paris
const jours = [];
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)]); }
zone.innerHTML = defs.map((g, k) => {
const vals = g.v.filter(v => v != null);
let bas = Math.min(...vals), haut = Math.max(...vals);
if (g.borne) { bas = g.borne[0]; haut = g.borne[1]; }
else if (g.zero) { bas = 0; haut = Math.max(haut * 1.15, g.cle === 'r' ? 1 : 10); }
else { const m = Math.max(1, (haut - bas) * 0.12); bas -= m; haut += m; }
const Y = v => mt + (1 - (v - bas) / (haut - bas)) * (H - mt - mb);
const grad = graduations(bas, haut, 4);
let trace = '';
if (g.ligne) {
let seg = '';
g.v.forEach((v, i) => { seg += v == null ? '' : `${seg && g.v[i - 1] != null ? 'L' : 'M'}${X(i).toFixed(1)} ${Y(v).toFixed(1)}`; });
let stroke = g.c;
if (g.couleurs) {
const stops = Array.from({length: 11}, (_, j) => { const val = haut - (haut - bas) * j / 10; return `<stop offset="${j * 10}%" stop-color="${g.couleurs(val)}"/>`; }).join('');
trace = `<defs><linearGradient id="gt${k}" gradientUnits="userSpaceOnUse" x1="0" y1="${Y(haut)}" x2="0" y2="${Y(bas)}">${stops}</linearGradient></defs>`;
stroke = `url(#gt${k})`;
}
trace += `<path d="${seg}" fill="none" stroke="${stroke}" stroke-width="1.8" stroke-linejoin="round" stroke-linecap="round"/>`;
} else {
const bw = Math.max(2, pw / (n - 1) * 2 - 1.5);
trace = g.v.map((v, i) => v ? `<rect x="${(X(i) - bw / 2).toFixed(1)}" y="${Y(v).toFixed(1)}" width="${bw.toFixed(1)}" height="${(Y(0) - Y(v)).toFixed(1)}" fill="${g.c}"/>` : '').join('');
}
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">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 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 mm = vals.length ? `mini ${g.f(Math.min(...vals))} · maxi ${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>
<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>`;
}).join('') + `<p class="plein-note">Relevés toutes les 10 minutes, courbes sur ${Math.min(7, Math.max(1, Math.round(n * d.pas / 86400)))} jour${n * d.pas > 1.5 * 86400 ? 's' : ''}${d.archive_depuis ? ` · archive depuis le ${new Intl.DateTimeFormat('fr-FR', {day: 'numeric', month: 'long', timeZone: 'Europe/Paris'}).format(new Date(d.archive_depuis * 1000))}` : ''}. Le zéro est marqué « gel ».</p>`;
// curseur partagé : le doigt ou la souris lit la même heure sur toutes les courbes
const gr = [...zone.querySelectorAll('.graphe')];
const poser = ev => {
const r = gr[0].querySelector('svg').getBoundingClientRect();
const i = Math.max(0, Math.min(n - 1, Math.round((ev.clientX - r.left - ml) / pw * (n - 1))));
gr.forEach((el, k) => {
const g = defs[k], v = g.v[i], x = X(i);
const ligne = el.querySelector('.curseur'), pt = el.querySelector('.point');
ligne.setAttribute('x1', x); ligne.setAttribute('x2', x); ligne.setAttribute('visibility', 'visible');
el.querySelector('.g-lect').textContent = `${fmtJH.format(new Date((d.debut + i * d.pas) * 1000))} · ${v == null ? '—' : g.f(v)}`;
if (v == null || !g.ligne) { pt.setAttribute('visibility', 'hidden'); return; }
pt.setAttribute('cx', x); pt.setAttribute('visibility', 'visible');
});
};
// hauteur du point : recalculée depuis les mêmes échelles
defs.forEach((g, k) => {
const vals = g.v.filter(v => v != null);
let bas = Math.min(...vals), haut = Math.max(...vals);
if (g.borne) { bas = g.borne[0]; haut = g.borne[1]; }
else if (g.zero) { bas = 0; haut = Math.max(haut * 1.15, g.cle === 'r' ? 1 : 10); }
else { const m = Math.max(1, (haut - bas) * 0.12); bas -= m; haut += m; }
g.Y = v => mt + (1 - (v - bas) / (haut - bas)) * (H - mt - mb);
});
const poserPoint = ev => {
poser(ev);
const r = gr[0].querySelector('svg').getBoundingClientRect();
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)); });
};
zone.addEventListener('pointermove', poserPoint);
zone.addEventListener('pointerdown', poserPoint);
zone.addEventListener('pointerleave', () => gr.forEach(el => {
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 licenceCourte = l => !l ? '' : /NC/.test(l) ? 'CC BY-NC' : /CC BY/.test(l) ? 'CC BY' : '';
async function chargerDonnees(){
const [mf, ic, wl, vp2, sem] = await Promise.all([lire('meteofrance.json'), lire('infoclimat.json'), lire('weatherlink.json'), lire('vp2.json'), lire('semaine/index.json')]);
if (sem) SEM = sem;
let dernier = null;
const poser = (d, cle, id) => {
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, 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; }
};
for (const [cle, id] of Object.entries(POSTES_MF)) poser(mf, cle, id);
if (ic && ic.stations) for (const id of Object.keys(ic.stations)) poser(ic, id, id);
if (wl && wl.stations) for (const [id, st] of Object.entries(wl.stations)) if (!st.hors_ligne && STATIONS[id]) poser(wl, id, id);
if (vp2 && vp2.stations) poser(vp2, 'lans', 'lans'); // VP2 de Lans : directement depuis le LAN, plus par Infoclimat
if (dernier) {
const jour = new Intl.DateTimeFormat('fr-FR', {weekday: 'long', day: 'numeric', month: 'long', timeZone: 'Europe/Paris'}).format(dernier);
const heure = new Intl.DateTimeFormat('fr-FR', {hour: '2-digit', minute: '2-digit', timeZone: 'Europe/Paris'}).format(dernier).replace(':', ' h ');
document.getElementById('date').textContent = jour[0].toUpperCase() + jour.slice(1);
dernierReleve = dernier; heureReleve = heure; afficherDirect();
}
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
// la barre d'adresse du téléphone change la hauteur : on ne recadre que si la largeur change
addEventListener('resize', () => { if (carte.clientWidth !== largeur) vue = null; relancer(); });
// premier dessin sans attendre une image (requestAnimationFrame est suspendu dans un onglet caché)
document.fonts.ready.then(() => disposer());
disposer();
// lien direct vers une station : #station=autrans
function ouvrirDepuisAdresse(){
const m = location.hash.match(/^#station=([\w-]+)/);
if (m && STATIONS[m[1]] && plein.hidden) ouvrirPlein([m[1]], m[1]);
}
addEventListener('hashchange', ouvrirDepuisAdresse);
// ouverture : les courbes se tracent de la plus haute à la plus basse, puis les stations arrivent du nord au sud.
// 0,7 s au plus sur téléphone, 1,3 s sur ordinateur ou tablette.
const INTRO = /*INTRO*/;
function ouverture(){
disposer();
if (reduit || !Z || !INTRO.length) { carte.classList.remove('ouverture'); return; }
const T = carte.clientWidth < 720 ? 700 : 1300, tc = T * 0.6, ns = 'http://www.w3.org/2000/svg';
const s = vue.s, vx = vue.cx - Z.cx / s, vy = vue.cy - Z.cy / s;
const sv = document.createElementNS(ns, 'svg');
sv.id = 'intro'; sv.setAttribute('aria-hidden', 'true'); sv.setAttribute('preserveAspectRatio', 'none');
sv.setAttribute('viewBox', `${vx} ${vy} ${Z.W / s} ${Z.H / s}`);
// tracé limité au Parc
sv.innerHTML = '<clipPath id="c-intro"><use href="#d-pnr"/></clipPath><g clip-path="url(#c-intro)"></g>';
const g = sv.querySelector('g');
INTRO.forEach(([alt, d], i) => {
const p = document.createElementNS(ns, 'path');
p.setAttribute('d', d); p.setAttribute('pathLength', '1');
if (alt % 500 === 0) p.classList.add('m');
p.style.animationDelay = (i / INTRO.length * tc * 0.55) + 'ms';
p.style.animationDuration = (tc * 0.45) + 'ms';
g.appendChild(p);
});
carte.insertBefore(sv, calque);
const vues = puces.filter(p => !p.m.classList.contains('cache')).sort((a, b) => a.y - b.y);
vues.forEach((p, i) => p.m.style.setProperty('--d', (i / Math.max(1, vues.length - 1) * (T - tc - 200)) + 'ms'));
setTimeout(() => carte.classList.add('fond'), tc * 0.7);
setTimeout(() => carte.classList.add('stations'), tc);
setTimeout(() => {
carte.classList.remove('ouverture', 'fond', 'stations'); sv.remove();
puces.forEach(p => p.m.style.removeProperty('--d'));
}, T + 50);
}
// Bandeau « pas de cookie » : une fois par appareil, s'efface après 6250 ms (pause au survol / toucher)
(function(){
// Dynamique : affiché à la 1re visite, puis seulement après 7 jours sans visite (?cookie force l'affichage). La date de dernière visite reste dans le navigateur, jamais envoyée au serveur.
let montrer = true;
try {
const dernier = +localStorage.getItem('vm-derniere-visite') || 0, maintenant = Date.now();
montrer = !dernier || maintenant - dernier >= 7 * 86400000 || /[?&]cookie\b/.test(location.search);
localStorage.setItem('vm-derniere-visite', String(maintenant));
} catch (e) {}
if (!montrer) return;
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); };
const armer = () => { clearTimeout(t); t = setTimeout(partir, 6250); };
b.addEventListener('pointerenter', () => clearTimeout(t)); b.addEventListener('pointerleave', armer);
b.addEventListener('focusin', () => clearTimeout(t));
b.querySelector('button').addEventListener('click', partir);
armer();
})();
</script>
</body>
</html>