MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / alert

Function alert

src/dialogs/alert.js:11–74  ·  view source on GitHub ↗

* Alert dialog * @param {string} titleText Title text * @param {string} message Alert message * @param {function():void} [onhide] Callback function

(titleText, message, onhide)

Source from the content-addressed store, hash-verified

9 * @param {function():void} [onhide] Callback function
10 */
11function alert(titleText, message, onhide) {
12 if (!message && titleText) {
13 message = titleText;
14 titleText = "";
15 }
16
17 const regex = /(https?:\/\/[^\s]+)/g;
18 if (regex.test(message)) {
19 message = message.replace(regex, function (url) {
20 return `<a href='${url}'>${url}</a>`;
21 });
22 }
23
24 const titleSpan = tag("strong", {
25 className: "title",
26 textContent: titleText,
27 });
28 const messageSpan = tag("span", {
29 className: "message scroll",
30 innerHTML: DOMPurify.sanitize(message),
31 });
32 const okBtn = tag("button", {
33 textContent: strings.ok,
34 onclick: hide,
35 });
36 const alertDiv = tag("div", {
37 className: "prompt alert",
38 children: [
39 titleSpan,
40 messageSpan,
41 tag("div", {
42 className: "button-container",
43 child: okBtn,
44 }),
45 ],
46 });
47 const mask = tag("span", {
48 className: "mask",
49 onclick: hide,
50 });
51
52 actionStack.push({
53 id: "alert",
54 action: hideAlert,
55 });
56
57 app.append(alertDiv, mask);
58 restoreTheme(true);
59
60 function hideAlert() {
61 alertDiv.classList.add("hide");
62 restoreTheme();
63 setTimeout(() => {
64 app.removeChild(alertDiv);
65 app.removeChild(mask);
66 }, 300);
67 }
68

Callers 15

createTerminalMethod · 0.85
setupTerminalHandlersMethod · 0.85
initEncodingsFunction · 0.85
errorFunction · 0.85
PluginIncludeFunction · 0.85
buyFunction · 0.85
setTerminalThemeFunction · 0.85
pasteCopiedItemsFunction · 0.85
contextMenuHandlerFunction · 0.85
renameFileFunction · 0.85
index.jsFile · 0.85
sponsor.jsFile · 0.85

Calls 2

restoreThemeFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected