diff --git a/static/stocks.html b/static/stocks.html index 06120e7..6499367 100644 --- a/static/stocks.html +++ b/static/stocks.html @@ -1,118 +1,137 @@ - - - Stock alcool - - - - + + + -
- -
Chargement…
-
+
+ +
Chargement…
+
- + async function updateGauge() { + try { + const res = await fetch(DATA_URL, { cache: 'no-store' }); + if (!res.ok) throw new Error(res.status); + const text = await res.text(); + const pct = Math.min(100, Math.max(0, parseFloat(text))); + updateGaugeColor(pct); + gauge.set(pct); + document.getElementById('value').textContent = pct.toFixed(1) + ' %'; + } catch (e) { + document.getElementById('value').textContent = 'Erreur de chargement'; + console.error(e); + } + } - + window.addEventListener('load', () => { + initGauge(); + updateGauge(); + setInterval(updateGauge, 30_000); + }); + + window.addEventListener('resize', () => { + const last = gauge ? gauge.value : 0; + initGauge(); + if (gauge && last !== undefined) { + updateGaugeColor(last); + gauge.set(last); + } + }); + + + -