Source: xui/Alert.js

/**
 * An alert dialog box.
 * <p>Part of the XUI module which, for now, has an undocumented API.
 */
export class Alert extends Dialog {
    static showError(message, reference=null) {
        Alert.showAlert("error", message, reference);
    }
    
    static showWarning(message, reference=null) {
        Alert.showAlert("warning", message, reference);
    }
    
    static showInfo(message, reference=null) {
        Alert.showAlert("info", message, reference);
    }
    
    static showAlert(type, message, reference=null) {
        let alert = new Alert(type, message);
        alert.open("center", reference);
    }

    constructor(type, message, options={}) {
        super(Object.assign({ title: "-", movable: true,
                              template: Alert.TEMPLATE,
                              buttons: { label: "OK", action: "okAction" } },
                            options));

        let title = "Error";
        let iconClass = "xui-alert-error-icon";
        let iconContent = StockIcon["minus-circled"];
        switch (type) {
        case "warning":
            title = "Warning";
            iconClass = "xui-alert-warning-icon";
            iconContent = StockIcon["attention"];
            break;
        case "info":
        case "information":
            title = "Information";
            iconClass = "xui-alert-info-icon";
            iconContent = StockIcon["info-circled"];
            break;
        case "confirm":
            title = "Confirm";
            iconClass = "xui-alert-confirm-icon";
            iconContent = StockIcon["question"];
            break;
        }
        this.titleText.textContent = title;

        let pane = this.contentPane.firstElementChild;
        let icon = pane.firstElementChild;
        icon.classList.add(iconClass);
        icon.textContent = iconContent;

        let msg = pane.lastElementChild;
        if (message.startsWith("<html>")) {
            message = message.substring(6);
        } else {
            message = Util.escapeHTML(message);
            if (message.indexOf('\n') >= 0) {
                message = message.replaceAll('\n', "<br>");
            }
        }
        msg.innerHTML = message;
    }

    okAction() {
        this.close();
    }
}

Alert.TEMPLATE = document.createElement("template");
Alert.TEMPLATE.innerHTML = `
<div class="xui-alert-pane">
  <div class="xui-alert-icon"></div>
  <div class="xui-alert-message"></div>
</div>
`;