utility: let setInfoBlock also clear

8aadada0e26f419187650892d35aee14f892c5e1

Wolfsblvt <wolfsblvt@gmail.com>

1 files changed, +6 -1Ignore whitespace
public/scripts/utils.js+6 -1
@@ -2260,10 +2260,15 @@ export function arraysEqual(a, b) {
22602260/**
22612261 * Updates the content and style of an information block
22622262 * @param {string | HTMLElement} target - The CSS selector or the HTML element of the information block
22632263 * @param {string | HTMLElement?} content - The message to display inside the information block (supports HTML) or an HTML element
22642264 * @param {'hint' | 'info' | 'warning' | 'error'} [type='info'] - The type of message, which determines the styling of the information block
22652265 */
22662266export function setInfoBlock(target, content, type = 'info') {
2267+ if (!content) {
2268+ clearInfoBlock(target);
2269+ return;
2270+ }
2271+
22672272 const infoBlock = typeof target === 'string' ? document.querySelector(target) : target;
22682273 if (infoBlock) {
22692274 infoBlock.className = `info-block ${type}`;