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

Function create

src/dialogs/loader.js:42–106  ·  view source on GitHub ↗

* Creates new loading dialog * @param {string} titleText Title text * @param {string} [message] Loading message * @param {LoaderOptions} [options] Loader options * @returns {Loader}

(titleText, message = "", options = {})

Source from the content-addressed store, hash-verified

40 * @returns {Loader}
41 */
42function create(titleText, message = "", options = {}) {
43 if (!message && titleText) {
44 message = titleText;
45 titleText = "";
46 }
47
48 const $oldLoader = tag.get("#__loader");
49 const $oldMask = tag.get("#__loader-mask");
50
51 if ($oldLoader) $oldLoader.remove();
52
53 const $message = Ref();
54 const $titleSpan = Ref();
55
56 const $mask = $oldMask || <span className="mask" id="__loader-mask"></span>;
57 const $dialog = $oldLoader || (
58 <div className="prompt alert" id="__loader">
59 <strong ref={$titleSpan} className="title">
60 {titleText}
61 </strong>
62 <span className="message loader">
63 <span className="loader" innerHTML={createTailSpinSvg()}></span>
64 <div
65 ref={$message}
66 className="message"
67 innerHTML={DOMPurify.sanitize(message)}
68 style={{ whiteSpace: "pre-wrap" }}
69 ></div>
70 </span>
71 </div>
72 );
73
74 const { timeout, oncancel } = options;
75 if (typeof oncancel === "function") {
76 onCancelCallback = oncancel;
77 }
78
79 if (typeof timeout === "number") {
80 setTimeout(() => {
81 $dialog.append(
82 <div className="button-container">
83 <button onclick={destroy}>{strings.cancel}</button>
84 </div>,
85 );
86 }, timeout);
87 }
88
89 if (!$oldLoader) {
90 actionStack.freeze();
91 document.body.append($dialog, $mask);
92 restoreTheme(true);
93 }
94
95 return {
96 setTitle(title) {
97 $titleSpan.textContent = title;
98 },
99 setMessage(message) {

Callers

nothing calls this directly

Calls 4

restoreThemeFunction · 0.85
appendMethod · 0.80
getMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected