MCPcopy Index your code
hub / github.com/pyscript/pyscript / _createAlertBanner

Function _createAlertBanner

core/src/exceptions.js:76–109  ·  view source on GitHub ↗
(
    message,
    level,
    messageType = "text",
    logMessage = true,
)

Source from the content-addressed store, hash-verified

74 * @param {any} [logMessage=true] An additional flag for whether the message should be sent to the console log.
75 */
76export function _createAlertBanner(
77 message,
78 level,
79 messageType = "text",
80 logMessage = true,
81) {
82 switch (`log-${level}-${logMessage}`) {
83 case "log-error-true":
84 console.error(message);
85 break;
86 case "log-warning-true":
87 console.warn(message);
88 break;
89 }
90
91 const content = messageType === "html" ? "innerHTML" : "textContent";
92 const banner = assign(document.createElement("div"), {
93 className: `alert-banner py-${level}`,
94 [content]: message,
95 });
96
97 if (level === "warning") {
98 const closeButton = assign(document.createElement("button"), {
99 id: "alert-close-button",
100 innerHTML: CLOSEBUTTON,
101 });
102
103 banner.appendChild(closeButton).addEventListener("click", () => {
104 banner.remove();
105 });
106 }
107
108 document.body.prepend(banner);
109}

Callers

nothing calls this directly

Calls 4

assignFunction · 0.85
errorMethod · 0.80
warnMethod · 0.80
removeMethod · 0.45

Tested by

no test coverage detected