Files
reflector-dashboard/lib/ui_msg.js
T
bjorne cb8b9af20e sync från dev (svx-web): lastheard paginering + separat live-feed, listen-vy, UI-uppdateringar
- lastheard 24h: client-side paginering (lib/pager.js), dynamisk sidstorlek
- lastheard: separat live-feed (lastheard_live_view.js), 24h loggar varje key-up
- listen_view.js + auth/admin_listen.*: Listen Live
- genomgående UI/auth-uppdateringar synkade från dev
Inga hårdkodade secrets/IP/login — endast hostnamn.
2026-11-18 22:07:16 +01:00

32 lines
1.4 KiB
JavaScript

// ui_msg.js — shared status/error message helpers (dmr-web, svx-web, svxlink-web).
// Canonical copy: callmgr2/www-mumien/lib/ui_msg.js; other repos carry a COPY.
//
// setMsg(elOrId, text, isErr) inline text line: hidden when empty, green/red
// showErr(elOrId, text) show/hide an error line, keeps its own colour
// flashMsg(selOrEl, html, isErr, ttlMs) panel-style box (svxlink-web); ttl 0 = stays
(function () {
'use strict';
const el = x => (typeof x === 'string' ? (document.getElementById(x) || document.querySelector(x)) : x);
function setMsg(target, msg, isErr) {
const e = el(target); if (!e) return;
if (!msg) { e.style.display = 'none'; e.textContent = ''; return; }
e.textContent = msg;
e.style.color = isErr ? '#ff8080' : '#0f0';
e.style.display = 'block';
}
function showErr(target, msg) {
const e = el(target); if (!e) return;
if (!msg) { e.style.display = 'none'; e.textContent = ''; return; }
e.textContent = msg;
e.style.display = 'block';
}
function flashMsg(target, html, isErr, ttlMs) {
const e = el(target); if (!e) return;
e.innerHTML = '<div class="panel" style="color:' + (isErr ? '#ff8080' : '#00ff9c') + ';">' + html + '</div>';
if (ttlMs > 0) setTimeout(() => { if (e.firstChild) e.innerHTML = ''; }, ttlMs);
}
window.setMsg = setMsg;
window.showErr = showErr;
window.flashMsg = flashMsg;
})();