screentinker/Examples/PIP-Fundraiser-Thermometer/thermo-overlay.js
screentinker 0b138f10c6
Add PiP overlay example recipes (#132)
Self-contained examples for the PiP overlay API (POST /api/pip), each
with a CSP-safe query-param overlay (external JS), config.example.json,
zero runtime deps, an offline test, and a README:

- PIP-Announce-Broadcast    manual one-shot message to a screen/group
- PIP-Weather-Widget        Open-Meteo current conditions (keyless)
- PIP-Air-Quality           Open-Meteo US AQI widget (keyless)
- PIP-Crypto-Ticker         CoinGecko price strip (keyless)
- PIP-News-Ticker           scrolling RSS/Atom headlines
- PIP-Room-Status-Calendar  ICS-driven Available/Busy room sign
- PIP-Event-Countdown       client-side countdown, auto-clears at zero
- PIP-Welcome-Board         rotating welcome/birthday cards from CSV
- PIP-Fundraiser-Thermometer goal-progress bar from local/URL JSON
- PIP-QR-Rotator            rotating QR codes, encoded client-side
- PIP-Incident-Webhook      event-driven: red on firing, clear on resolved

Also includes the CAP-AU (NSW RFS) and US NWS/NOAA emergency-alert
monitors that push expiry-aware PiP overlays.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-18 20:20:37 -05:00

33 lines
1.2 KiB
JavaScript

// External overlay script — same-origin so the server CSP (scriptSrc 'self') permits it.
// Reads the fundraiser fields from the URL query string and fills the thermometer.
(function () {
var q = new URLSearchParams(location.search);
var get = function (k) { return (q.get(k) || '').trim(); };
var pct = Math.max(0, Math.min(100, parseFloat(get('pct')) || 0));
var pctLabel = get('pctLabel') || (Math.round(pct) + '%');
var done = pct >= 100;
document.getElementById('campaign').textContent = get('campaign') || 'Fundraiser';
document.getElementById('raised').textContent = get('raised') || '0';
document.getElementById('goal').textContent = get('goal') || '0';
var pctEl = document.getElementById('pct');
pctEl.textContent = pctLabel;
if (done) pctEl.classList.add('done');
var footer = document.getElementById('footer');
if (done) {
footer.className = 'footer done-banner';
footer.textContent = 'Goal reached! 🎉';
} else {
footer.textContent = 'Thank you for your support';
}
// Animate the fill from 0 to pct after first paint.
var fill = document.getElementById('fill');
requestAnimationFrame(function () {
requestAnimationFrame(function () { fill.style.height = pct + '%'; });
});
})();