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) {
2260/**2260/**
2261 * Updates the content and style of an information block2261 * Updates the content and style of an information block
2262 * @param {string | HTMLElement} target - The CSS selector or the HTML element of the information block2262 * @param {string | HTMLElement} target - The CSS selector or the HTML element of the information block
2263 * @param {string | HTMLElement} content - The message to display inside the information block (supports HTML) or an HTML element2263 * @param {string | HTMLElement?} content - The message to display inside the information block (supports HTML) or an HTML element
2264 * @param {'hint' | 'info' | 'warning' | 'error'} [type='info'] - The type of message, which determines the styling of the information block2264 * @param {'hint' | 'info' | 'warning' | 'error'} [type='info'] - The type of message, which determines the styling of the information block
2265 */2265 */
2266export function setInfoBlock(target, content, type = 'info') {2266export function setInfoBlock(target, content, type = 'info') {
2267 if (!content) {
2268 clearInfoBlock(target);
2269 return;
2270 }
2271
2267 const infoBlock = typeof target === 'string' ? document.querySelector(target) : target;2272 const infoBlock = typeof target === 'string' ? document.querySelector(target) : target;
2268 if (infoBlock) {2273 if (infoBlock) {
2269 infoBlock.className = `info-block ${type}`;2274 infoBlock.className = `info-block ${type}`;