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

Function dialog

src/dialogs/dialog.js:14–198  ·  view source on GitHub ↗

* Dialog box * @param {string} titleText Title text * @param {string} html HTML string * @param {string} [hideButtonText] Text for hide button * @param {string} [cancelButtonText] Text for cancel button * @returns {PromiseLike}

(titleText, html, hideButtonText, cancelButtonText)

Source from the content-addressed store, hash-verified

12 * @returns {PromiseLike}
13 */
14function dialog(titleText, html, hideButtonText, cancelButtonText) {
15 let waitFor = 0,
16 strOK = hideButtonText || strings.ok,
17 _onclick = () => {},
18 _onhide = () => {},
19 _then = () => {},
20 _onOk = _hide,
21 _onCancel = () => {};
22
23 const promiseLike = {
24 hide,
25 wait,
26 onclick,
27 onhide,
28 then,
29 ok,
30 cancel,
31 };
32
33 let cancelBtn;
34 let hideButton = typeof hideButtonText === "boolean" ? hideButtonText : false;
35
36 if (cancelButtonText) {
37 cancelBtn = tag("button", {
38 className: "disabled",
39 textContent: cancelButtonText,
40 onclick: () => {
41 _onCancel();
42 },
43 });
44 }
45
46 const okBtn = tag("button", {
47 className: "disabled",
48 textContent: strOK,
49 onclick: () => {
50 _onOk();
51 },
52 });
53 const body = tag("div", {
54 className: "message",
55 innerHTML: html,
56 onclick: __onclick,
57 });
58 const box = tag("div", {
59 className: "prompt box",
60 children: [
61 tag("strong", {
62 className: "title",
63 textContent: titleText,
64 }),
65 body,
66 ],
67 });
68 const mask = tag("span", {
69 className: "mask",
70 onclick: _hide,
71 });

Callers 4

sponsor.jsFile · 0.85
runFunction · 0.85
showFileInfoFunction · 0.85
rateBoxFunction · 0.85

Calls 5

_onCancelFunction · 0.85
decTimeFunction · 0.85
__thenFunction · 0.85
restoreThemeFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected