no message
This commit is contained in:
+68
-51
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
<div id="wrap" style="padding:12px;font-family:system-ui,-apple-system,Segoe UI,Roboto,sans-serif;">
|
<div id="wrap" style="padding:12px;font-family:system-ui,-apple-system,Segoe UI,Roboto,sans-serif;">
|
||||||
<!-- Controls -->
|
<!-- Controls -->
|
||||||
<div style="display:flex;gap:10px;flex-wrap:wrap;align-items:center;">
|
<div style="display:flex;gap:10px;flex-wrap:wrap;align-items:center;">
|
||||||
@@ -12,16 +11,21 @@
|
|||||||
<option value="total">Gesamt</option>
|
<option value="total">Gesamt</option>
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<label style="display:flex;gap:6px;align-items:center;">
|
<label style="display:flex;gap:6px;align-items:center;">
|
||||||
<span>Datum</span>
|
<span>Datum</span>
|
||||||
<input id="date" type="date" />
|
<input id="date" type="date" />
|
||||||
|
<span id="dateLabel" style="font-weight:800; opacity:.95; margin-left:6px;"></span>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<button id="prev" type="button">◀</button>
|
<button id="prev" type="button">◀</button>
|
||||||
<button id="today" type="button">Heute</button>
|
<button id="today" type="button">Heute</button>
|
||||||
<button id="next" type="button">▶</button>
|
<button id="next" type="button">▶</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="period" style="margin-top:10px;font-size:12px;opacity:0.75;"></div>
|
<div id="period" style="margin-top:10px;font-size:12px;opacity:0.75;"></div>
|
||||||
<div id="hint" style="margin-top:6px;font-size:12px;opacity:0.8;"></div>
|
<div id="hint" style="margin-top:6px;font-size:12px;opacity:0.8;"></div>
|
||||||
|
|
||||||
<div id="grid"
|
<div id="grid"
|
||||||
style="margin-top:14px;
|
style="margin-top:14px;
|
||||||
display:grid;
|
display:grid;
|
||||||
@@ -30,25 +34,23 @@
|
|||||||
width:100%;
|
width:100%;
|
||||||
max-width:none;">
|
max-width:none;">
|
||||||
</div>
|
</div>
|
||||||
<!-- Debug/Status -->
|
|
||||||
<div id="dbg" style="margin-top:10px;font-size:12px;opacity:0.75;"></div>
|
<div id="dbg" style="margin-top:10px;font-size:12px;opacity:0.75;"></div>
|
||||||
<!-- Fehler -->
|
|
||||||
<div id="err" style="margin-top:6px;font-size:12px;opacity:0.9;color:#ffb4b4;"></div>
|
<div id="err" style="margin-top:6px;font-size:12px;opacity:0.9;color:#ffb4b4;"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
/* Responsive: bei schmalen Screens 1 Spalte */
|
|
||||||
@media (max-width: 720px) {
|
@media (max-width: 720px) {
|
||||||
#grid { grid-template-columns: 1fr !important; }
|
#grid { grid-template-columns: 1fr !important; }
|
||||||
}
|
}
|
||||||
/* Statischer "Fluid" Hintergrund in Donut-Farben */
|
|
||||||
|
/* Statischer "Fluid" Hintergrund */
|
||||||
#wrap{
|
#wrap{
|
||||||
position:relative;
|
position:relative;
|
||||||
overflow:hidden;
|
overflow:hidden;
|
||||||
min-height:100vh;
|
min-height:100vh;
|
||||||
/* Grundton, damit es nicht "lochig" wirkt */
|
|
||||||
background: rgba(18, 18, 22, 1);
|
background: rgba(18, 18, 22, 1);
|
||||||
}
|
}
|
||||||
/* Nur EIN Layer, statisch */
|
|
||||||
#wrap::before{
|
#wrap::before{
|
||||||
content:"";
|
content:"";
|
||||||
position:absolute;
|
position:absolute;
|
||||||
@@ -59,27 +61,27 @@
|
|||||||
radial-gradient(620px 520px at 55% 85%, rgba(99,179,255,0.26), transparent 64%),
|
radial-gradient(620px 520px at 55% 85%, rgba(99,179,255,0.26), transparent 64%),
|
||||||
radial-gradient(700px 560px at 35% 70%, rgba(168,85,247,0.22), transparent 66%),
|
radial-gradient(700px 560px at 35% 70%, rgba(168,85,247,0.22), transparent 66%),
|
||||||
radial-gradient(900px 700px at 50% 50%, rgba(255,255,255,0.06), transparent 70%);
|
radial-gradient(900px 700px at 50% 50%, rgba(255,255,255,0.06), transparent 70%);
|
||||||
filter: blur(18px); /* weniger blur = mehr sichtbar */
|
filter: blur(18px);
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
pointer-events:none;
|
pointer-events:none;
|
||||||
z-index:0;
|
z-index:0;
|
||||||
}
|
}
|
||||||
/* Content über dem Background */
|
|
||||||
#wrap > *{
|
#wrap > *{
|
||||||
position:relative;
|
position:relative;
|
||||||
z-index:1;
|
z-index:1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#period {
|
#period {
|
||||||
font-size: 15px; /* größer */
|
font-size: 15px;
|
||||||
font-weight: 600; /* dicker */
|
font-weight: 600;
|
||||||
letter-spacing: 0.2px;
|
letter-spacing: 0.2px;
|
||||||
opacity: 0.95;
|
opacity: 0.95;
|
||||||
}
|
}
|
||||||
/* Werte-Zeile (Produktion / Verbrauch / …) */
|
|
||||||
#hint {
|
#hint {
|
||||||
margin-top: 6px;
|
margin-top: 6px;
|
||||||
font-size: 15px; /* größer */
|
font-size: 15px;
|
||||||
font-weight: 700; /* noch etwas dicker */
|
font-weight: 700;
|
||||||
letter-spacing: 0.3px;
|
letter-spacing: 0.3px;
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
@@ -91,20 +93,20 @@
|
|||||||
#hint .kv b {
|
#hint .kv b {
|
||||||
font-weight: 800;
|
font-weight: 800;
|
||||||
}
|
}
|
||||||
/* App/kleine Breite: untereinander */
|
|
||||||
@media (max-width: 720px) {
|
@media (max-width: 720px) {
|
||||||
#hint .kv {
|
#hint .kv {
|
||||||
display: block;
|
display: block;
|
||||||
margin: 4px 0;
|
margin: 4px 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<!-- 1) Puffer-Handler: fängt Symcon-Messages ab, selbst wenn UI noch nicht ready ist -->
|
<!-- Puffer-Handler (Symcon kann handleMessage sehr früh callen) -->
|
||||||
<script>
|
<script>
|
||||||
window.__EnergyPieQueue = window.__EnergyPieQueue || [];
|
window.__EnergyPieQueue = window.__EnergyPieQueue || [];
|
||||||
window.__EnergyPieReady = false;
|
window.__EnergyPieReady = false;
|
||||||
|
|
||||||
window.handleMessage = function (data) {
|
window.handleMessage = function (data) {
|
||||||
window.__EnergyPieQueue.push(data);
|
window.__EnergyPieQueue.push(data);
|
||||||
if (window.__EnergyPieReady && typeof window.__EnergyPieConsume === "function") {
|
if (window.__EnergyPieReady && typeof window.__EnergyPieConsume === "function") {
|
||||||
@@ -113,10 +115,12 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
(function () {
|
(function () {
|
||||||
const elRange = document.getElementById('range');
|
const elRange = document.getElementById('range');
|
||||||
const elDate = document.getElementById('date');
|
const elDate = document.getElementById('date');
|
||||||
|
const elDateLabel = document.getElementById('dateLabel');
|
||||||
const elPrev = document.getElementById('prev');
|
const elPrev = document.getElementById('prev');
|
||||||
const elToday = document.getElementById('today');
|
const elToday = document.getElementById('today');
|
||||||
const elNext = document.getElementById('next');
|
const elNext = document.getElementById('next');
|
||||||
@@ -125,9 +129,9 @@
|
|||||||
const elGrid = document.getElementById('grid');
|
const elGrid = document.getElementById('grid');
|
||||||
const elDbg = document.getElementById('dbg');
|
const elDbg = document.getElementById('dbg');
|
||||||
const elErr = document.getElementById('err');
|
const elErr = document.getElementById('err');
|
||||||
// Start nicht "leer"
|
|
||||||
elGrid.innerHTML = '<div style="opacity:.75;padding:12px;">Lade Daten…</div>';
|
elGrid.innerHTML = '<div style="opacity:.75;padding:12px;">Lade Daten…</div>';
|
||||||
// --- helpers ---
|
|
||||||
function toNum(x) {
|
function toNum(x) {
|
||||||
const n = Number(x);
|
const n = Number(x);
|
||||||
return Number.isFinite(n) ? n : 0;
|
return Number.isFinite(n) ? n : 0;
|
||||||
@@ -146,31 +150,17 @@
|
|||||||
.replaceAll('"','"')
|
.replaceAll('"','"')
|
||||||
.replaceAll("'",''');
|
.replaceAll("'",''');
|
||||||
}
|
}
|
||||||
function fmtDateTime(d) {
|
|
||||||
const yyyy = d.getFullYear();
|
|
||||||
const mm = String(d.getMonth() + 1).padStart(2,'0');
|
|
||||||
const dd = String(d.getDate()).padStart(2,'0');
|
|
||||||
const hh = String(d.getHours()).padStart(2,'0');
|
|
||||||
const mi = String(d.getMinutes()).padStart(2,'0');
|
|
||||||
return `${dd}.${mm}.${yyyy} ${hh}:${mi}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function fmtDay(d) {
|
function fmtDay(d) {
|
||||||
const dd = String(d.getDate()).padStart(2,'0');
|
const dd = String(d.getDate()).padStart(2,'0');
|
||||||
const mm = String(d.getMonth() + 1).padStart(2,'0');
|
const mm = String(d.getMonth() + 1).padStart(2,'0');
|
||||||
const yyyy = d.getFullYear();
|
const yyyy = d.getFullYear();
|
||||||
return `${dd}.${mm}.${yyyy}`;
|
return `${dd}.${mm}.${yyyy}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function monthNameDe(m) {
|
function monthNameDe(m) {
|
||||||
return ['Jan','Feb','Mär','Apr','Mai','Jun','Jul','Aug','Sep','Okt','Nov','Dez'][m] || '';
|
return ['Jan','Feb','Mär','Apr','Mai','Jun','Jul','Aug','Sep','Okt','Nov','Dez'][m] || '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// ISO Woche + ISO Jahr (wichtig: ISO-Jahr kann am Jahresrand abweichen)
|
|
||||||
function getISOWeekYear(date) {
|
function getISOWeekYear(date) {
|
||||||
const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
|
const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
|
||||||
// Donnerstag bestimmt ISO-Jahr
|
|
||||||
d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
|
d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
|
||||||
const isoYear = d.getUTCFullYear();
|
const isoYear = d.getUTCFullYear();
|
||||||
const yearStart = new Date(Date.UTC(isoYear, 0, 1));
|
const yearStart = new Date(Date.UTC(isoYear, 0, 1));
|
||||||
@@ -178,22 +168,19 @@
|
|||||||
return { week: weekNo, year: isoYear };
|
return { week: weekNo, year: isoYear };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function showErr(e) {
|
function showErr(e) {
|
||||||
const msg = (e && e.message) ? e.message : String(e);
|
const msg = (e && e.message) ? e.message : String(e);
|
||||||
elErr.textContent = 'JS-Fehler: ' + msg;
|
elErr.textContent = 'JS-Fehler: ' + msg;
|
||||||
}
|
}
|
||||||
window.addEventListener('error', (ev) => showErr(ev.error || ev.message));
|
window.addEventListener('error', (ev) => showErr(ev.error || ev.message));
|
||||||
window.addEventListener('unhandledrejection', (ev) => showErr(ev.reason));
|
window.addEventListener('unhandledrejection', (ev) => showErr(ev.reason));
|
||||||
// --- requestAction robust finden ---
|
|
||||||
function getRequestAction() {
|
function getRequestAction() {
|
||||||
if (typeof window.requestAction === 'function') return window.requestAction;
|
if (typeof window.requestAction === 'function') return window.requestAction;
|
||||||
if (typeof window.parent?.requestAction === 'function') return window.parent.requestAction;
|
if (typeof window.parent?.requestAction === 'function') return window.parent.requestAction;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function safeRequestAction(ident, value) {
|
function safeRequestAction(ident, value) {
|
||||||
const tryCall = () => {
|
const tryCall = () => {
|
||||||
const ra = getRequestAction();
|
const ra = getRequestAction();
|
||||||
@@ -204,37 +191,37 @@
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
if (tryCall()) return;
|
if (tryCall()) return;
|
||||||
|
|
||||||
let tries = 0;
|
let tries = 0;
|
||||||
const timer = setInterval(() => {
|
const timer = setInterval(() => {
|
||||||
tries++;
|
tries++;
|
||||||
if (tryCall() || tries >= 150) clearInterval(timer);
|
if (tryCall() || tries >= 150) clearInterval(timer);
|
||||||
}, 120);
|
}, 120);
|
||||||
}
|
}
|
||||||
|
|
||||||
function safeRefreshSoon() {
|
function safeRefreshSoon() {
|
||||||
setTimeout(() => safeRequestAction('Refresh', 1), 150);
|
setTimeout(() => safeRequestAction('Refresh', 1), 150);
|
||||||
}
|
}
|
||||||
// --- donut card ---
|
|
||||||
function donutCard({ title, percent, subtitle, color }) {
|
function donutCard({ title, percent, subtitle, color }) {
|
||||||
const share = clamp01(percent / 100);
|
const share = clamp01(percent / 100);
|
||||||
const r = 56;
|
const r = 56;
|
||||||
const c = 2 * Math.PI * r;
|
const c = 2 * Math.PI * r;
|
||||||
let dash = share * c;
|
let dash = share * c;
|
||||||
// Schutz gegen Rundungs-Artefakte bei 99.9..100%
|
|
||||||
if (dash > c - 0.01) dash = c;
|
if (dash > c - 0.01) dash = c;
|
||||||
|
|
||||||
return `
|
return `
|
||||||
<div style="padding:18px 10px;
|
<div style="padding:18px 10px;width:100%;
|
||||||
width:100%;
|
display:flex;flex-direction:column;
|
||||||
display:flex;
|
align-items:center;justify-content:center;
|
||||||
flex-direction:column;
|
|
||||||
align-items:center;
|
|
||||||
justify-content:center;
|
|
||||||
gap:12px;">
|
gap:12px;">
|
||||||
|
|
||||||
<div style="font-size:15px;font-weight:800;opacity:.95;">
|
<div style="font-size:15px;font-weight:800;opacity:.95;">
|
||||||
${escapeHtml(title)}
|
${escapeHtml(title)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style="position:relative;width:180px;height:180px;">
|
<div style="position:relative;width:180px;height:180px;">
|
||||||
<svg width="180" height="180" viewBox="0 0 180 180">
|
<svg width="180" height="180" viewBox="0 0 180 180">
|
||||||
<!-- Anteilsegment -->
|
|
||||||
<circle cx="90" cy="90" r="${r}"
|
<circle cx="90" cy="90" r="${r}"
|
||||||
fill="none"
|
fill="none"
|
||||||
stroke="${color}"
|
stroke="${color}"
|
||||||
@@ -244,32 +231,40 @@ return `
|
|||||||
transform="rotate(-90 90 90)"
|
transform="rotate(-90 90 90)"
|
||||||
style="filter: drop-shadow(0 0 12px ${color});" />
|
style="filter: drop-shadow(0 0 12px ${color});" />
|
||||||
</svg>
|
</svg>
|
||||||
|
|
||||||
<div style="position:absolute;inset:0;display:flex;
|
<div style="position:absolute;inset:0;display:flex;
|
||||||
align-items:center;justify-content:center;
|
align-items:center;justify-content:center;
|
||||||
font-weight:900;font-size:26px;">
|
font-weight:900;font-size:26px;">
|
||||||
${escapeHtml(percent.toFixed(1))}%
|
${escapeHtml(percent.toFixed(1))}%
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style="font-size:13px;opacity:.75;text-align:center;">
|
<div style="font-size:13px;opacity:.75;text-align:center;">
|
||||||
${escapeHtml(subtitle)}
|
${escapeHtml(subtitle)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function render(data) {
|
function render(data) {
|
||||||
const values = data?.values || {};
|
const values = data?.values || {};
|
||||||
const prod = toNum(values?.Produktion);
|
const prod = toNum(values?.Produktion);
|
||||||
const cons = toNum(values?.Hausverbrauch);
|
const cons = toNum(values?.Hausverbrauch);
|
||||||
const grid = toNum(values?.Netz);
|
const grid = toNum(values?.Netz);
|
||||||
|
|
||||||
const eigen = cons - grid;
|
const eigen = cons - grid;
|
||||||
const eigenClamped = eigen < 0 ? 0 : eigen;
|
const eigenClamped = eigen < 0 ? 0 : eigen;
|
||||||
|
|
||||||
const evq = (prod > 0) ? (eigenClamped / prod * 100) : 0;
|
const evq = (prod > 0) ? (eigenClamped / prod * 100) : 0;
|
||||||
const autark = (cons > 0) ? (eigenClamped / cons * 100) : 0;
|
const autark = (cons > 0) ? (eigenClamped / cons * 100) : 0;
|
||||||
|
|
||||||
if (data?.range) elRange.value = data.range;
|
if (data?.range) elRange.value = data.range;
|
||||||
if (data?.date) elDate.value = data.date;
|
if (data?.date) elDate.value = data.date;
|
||||||
|
|
||||||
const isTotal = (data?.range === 'total');
|
const isTotal = (data?.range === 'total');
|
||||||
elDate.disabled = isTotal;
|
elDate.disabled = isTotal;
|
||||||
|
|
||||||
|
// Zeitraum (wie bei dir)
|
||||||
if (data?.tStart && data?.tEnd) {
|
if (data?.tStart && data?.tEnd) {
|
||||||
const s = new Date(data.tStart * 1000);
|
const s = new Date(data.tStart * 1000);
|
||||||
|
|
||||||
@@ -291,7 +286,24 @@ return `
|
|||||||
elPeriod.textContent = '';
|
elPeriod.textContent = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Datum-Label (dein Wunsch: im "Datum"-Bereich)
|
||||||
|
elDateLabel.textContent = '';
|
||||||
|
if (data?.date) {
|
||||||
|
const d = new Date(data.date + 'T00:00:00');
|
||||||
|
|
||||||
|
if (data.range === 'week') {
|
||||||
|
const iso = getISOWeekYear(d);
|
||||||
|
elDateLabel.textContent = `Woche ${iso.week}: ${iso.year}`;
|
||||||
|
} else if (data.range === 'month') {
|
||||||
|
elDateLabel.textContent = `${monthNameDe(d.getMonth())} ${d.getFullYear()}`;
|
||||||
|
} else if (data.range === 'year') {
|
||||||
|
elDateLabel.textContent = `${d.getFullYear()}`;
|
||||||
|
} else if (data.range === 'total') {
|
||||||
|
elDateLabel.textContent = 'Gesamt';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Werte / Keine Daten
|
||||||
if (data?.hasData === false) {
|
if (data?.hasData === false) {
|
||||||
elHint.innerHTML = `
|
elHint.innerHTML = `
|
||||||
<span style="font-weight:900; font-size:16px;">
|
<span style="font-weight:900; font-size:16px;">
|
||||||
@@ -310,7 +322,6 @@ return `
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
elGrid.innerHTML = [
|
elGrid.innerHTML = [
|
||||||
donutCard({
|
donutCard({
|
||||||
title: 'Eigenverbrauchsquote',
|
title: 'Eigenverbrauchsquote',
|
||||||
@@ -325,9 +336,8 @@ return `
|
|||||||
color: '#A855F7'
|
color: '#A855F7'
|
||||||
})
|
})
|
||||||
].join('');
|
].join('');
|
||||||
|
|
||||||
}
|
}
|
||||||
// --- cache ---
|
|
||||||
function saveLast(data) {
|
function saveLast(data) {
|
||||||
try { sessionStorage.setItem('EnergyPie_last', JSON.stringify(data)); } catch(e) {}
|
try { sessionStorage.setItem('EnergyPie_last', JSON.stringify(data)); } catch(e) {}
|
||||||
}
|
}
|
||||||
@@ -339,6 +349,7 @@ return `
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.__EnergyPieConsume = function (data) {
|
window.__EnergyPieConsume = function (data) {
|
||||||
if (typeof data === 'string') {
|
if (typeof data === 'string') {
|
||||||
try { data = JSON.parse(data); } catch(e) {}
|
try { data = JSON.parse(data); } catch(e) {}
|
||||||
@@ -347,8 +358,9 @@ return `
|
|||||||
saveLast(data);
|
saveLast(data);
|
||||||
render(data);
|
render(data);
|
||||||
};
|
};
|
||||||
// UI events
|
|
||||||
elRange.addEventListener('change', () => safeRequestAction('SetRange', elRange.value));
|
elRange.addEventListener('change', () => safeRequestAction('SetRange', elRange.value));
|
||||||
|
|
||||||
let dateTimer = null;
|
let dateTimer = null;
|
||||||
function pushDateNow() {
|
function pushDateNow() {
|
||||||
if (dateTimer) clearTimeout(dateTimer);
|
if (dateTimer) clearTimeout(dateTimer);
|
||||||
@@ -356,17 +368,22 @@ return `
|
|||||||
}
|
}
|
||||||
elDate.addEventListener('input', pushDateNow);
|
elDate.addEventListener('input', pushDateNow);
|
||||||
elDate.addEventListener('change', pushDateNow);
|
elDate.addEventListener('change', pushDateNow);
|
||||||
|
|
||||||
elPrev.addEventListener('click', () => safeRequestAction('Prev', 1));
|
elPrev.addEventListener('click', () => safeRequestAction('Prev', 1));
|
||||||
elToday.addEventListener('click', () => safeRequestAction('Today', 1));
|
elToday.addEventListener('click', () => safeRequestAction('Today', 1));
|
||||||
elNext.addEventListener('click', () => safeRequestAction('Next', 1));
|
elNext.addEventListener('click', () => safeRequestAction('Next', 1));
|
||||||
|
|
||||||
const cached = loadLast();
|
const cached = loadLast();
|
||||||
if (cached) render(cached);
|
if (cached) render(cached);
|
||||||
|
|
||||||
window.__EnergyPieReady = true;
|
window.__EnergyPieReady = true;
|
||||||
if (window.__EnergyPieQueue && window.__EnergyPieQueue.length) {
|
if (window.__EnergyPieQueue && window.__EnergyPieQueue.length) {
|
||||||
const q = window.__EnergyPieQueue.splice(0);
|
const q = window.__EnergyPieQueue.splice(0);
|
||||||
q.forEach(d => window.__EnergyPieConsume(d));
|
q.forEach(d => window.__EnergyPieConsume(d));
|
||||||
}
|
}
|
||||||
|
|
||||||
safeRefreshSoon();
|
safeRefreshSoon();
|
||||||
|
|
||||||
document.addEventListener('visibilitychange', () => {
|
document.addEventListener('visibilitychange', () => {
|
||||||
if (!document.hidden) safeRefreshSoon();
|
if (!document.hidden) safeRefreshSoon();
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user