Auto-refresh charts every 2 min; show next refresh time in status line
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
7ba246a628
commit
2501842083
1 file changed
+6
-2
@@ -515,7 +515,10 @@ async function loadHistory(range) {
|
|||||||
const data = await r.json();
|
const data = await r.json();
|
||||||
renderCharts(data, range);
|
renderCharts(data, range);
|
||||||
const line = document.getElementById('updatedLine');
|
const line = document.getElementById('updatedLine');
|
||||||
if (line) line.textContent = `${data.length} readings loaded · fetched ${new Date().toLocaleTimeString()}`;
|
if (line) {
|
||||||
|
const next = new Date(Date.now() + 120000).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
|
||||||
|
line.textContent = `${data.length} readings · updated ${new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })} · next refresh ${next}`;
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
area.innerHTML = `<div class="status error">Failed to load station history. ${e.message}</div>`;
|
area.innerHTML = `<div class="status error">Failed to load station history. ${e.message}</div>`;
|
||||||
}
|
}
|
||||||
@@ -536,8 +539,9 @@ document.getElementById('refreshBtn').addEventListener('click', () => {
|
|||||||
loadHistory(currentRange);
|
loadHistory(currentRange);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Auto-refresh latest every 2 minutes
|
// Auto-refresh latest + charts every 2 minutes
|
||||||
setInterval(updateLatest, 120000);
|
setInterval(updateLatest, 120000);
|
||||||
|
setInterval(() => loadHistory(currentRange), 120000);
|
||||||
|
|
||||||
// ── API key settings ─────────────────────────────────────────────────────────
|
// ── API key settings ─────────────────────────────────────────────────────────
|
||||||
async function checkKeyStatus() {
|
async function checkKeyStatus() {
|
||||||
|
|||||||
Reference in new issue
Block a user