mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
utility: let setInfoBlock also clear
This commit is contained in:
@ -2260,10 +2260,15 @@ export function arraysEqual(a, b) {
|
||||
/**
|
||||
* Updates the content and style of an information block
|
||||
* @param {string | HTMLElement} target - The CSS selector or the HTML element of the information block
|
||||
* @param {string | HTMLElement} content - The message to display inside the information block (supports HTML) or an HTML element
|
||||
* @param {string | HTMLElement?} content - The message to display inside the information block (supports HTML) or an HTML element
|
||||
* @param {'hint' | 'info' | 'warning' | 'error'} [type='info'] - The type of message, which determines the styling of the information block
|
||||
*/
|
||||
export function setInfoBlock(target, content, type = 'info') {
|
||||
if (!content) {
|
||||
clearInfoBlock(target);
|
||||
return;
|
||||
}
|
||||
|
||||
const infoBlock = typeof target === 'string' ? document.querySelector(target) : target;
|
||||
if (infoBlock) {
|
||||
infoBlock.className = `info-block ${type}`;
|
||||
|
Reference in New Issue
Block a user