41 lines
1.8 KiB
JavaScript
41 lines
1.8 KiB
JavaScript
// Reflector Dashboard — web front-end for SvxReflector
|
|
// Copyright (C) 2026 SA7AUX (Björn)
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify it under
|
|
// the terms of the GNU Affero General Public License as published by the Free
|
|
// Software Foundation, either version 3 of the License, or (at your option) any
|
|
// later version. See the LICENSE file for details.
|
|
|
|
// ui_msg.js — shared status/error message helpers (dmr-web, svx-web, svxlink-web).
|
|
// Canonical copy: <dmr-portal>/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;
|
|
})();
|