PageSourceSearch

https://mlab.sh/assets/js/app.js

js mlab.sh collected 2026-09-24 12:50:27 UTC 22,275 bytes, 465 lines download raw bytes

1class App {
2    init() {
3        this.initComponents(), this.initPreloader(), this.initPortletCard(), this.initMultiDropdown(), this.initFormValidation(), this.initCounter(), this.initToggle(), this.initPassword(), this.initDismissible(), this.initSidenav()
4    }
5
6    initComponents() {
7        "function" == typeof lucide.createIcons && lucide.createIcons(), document.querySelectorAll('[data-bs-toggle="popover"]').forEach(e => {
8            new bootstrap.Popover(e)
9        }), document.querySelectorAll('[data-bs-toggle="tooltip"]').forEach(e => {
10            new bootstrap.Tooltip(e)
11        }), document.querySelectorAll(".offcanvas").forEach(e => {
12            new bootstrap.Offcanvas(e)
13        }), document.querySelectorAll(".toast").forEach(e => {
14            new bootstrap.Toast(e)
15        })
16    }
17
18    initPreloader() {
19        window.addEventListener("load", () => {
20            var e = document.getElementById("status");
21            let t = document.getElementById("preloader");
22            e && (e.style.display = "none"), t && setTimeout(() => t.style.display = "none", 350)
23        })
24    }
25
26    initPortletCard() {
27        // jQuery only ships in the full vendors bundle (charts + datatables pages).
28        // Every markup this method binds to (card-close / card-toggle /
29        // card-refresh / code-collapse) is unused across the app, so on the public
30        // bundle there is nothing to bind and $ is simply not there. Without this
31        // guard the ReferenceError aborts init() and takes the sidenav, the
32        // toggles and the dismissibles down with it.
33        if (typeof $ === "undefined") return;
34        $('[data-action="card-close"]').on("click", function (e) {
35            e.preventDefault();
36            let t = $(this).closest(".card");
37            t.fadeOut(300, function () {
38                t.remove()
39            })
40        }), $('[data-action="card-toggle"]').on("click", function (e) {
41            e.preventDefault();
42            var e = $(this).closest(".card"), t = $(this).find("i").eq(0), a = e.find(".card-body"),
43                i = e.find(".card-footer");
44            a.slideToggle(300), i.slideToggle(200), t.toggleClass("ti-chevron-up ti-chevron-down"), e.toggleClass("card-collapse")
45        });
46        var e = document.querySelectorAll('[data-action="card-refresh"]');
47        e && e.forEach(function (e) {
48            e.addEventListener("click", function (e) {
49                e.preventDefault();
50                var t, e = e.target.closest(".card").querySelector(".card-body");
51                e.style.position = "relative";
52                let a = e.querySelector(".card-overlay");
53                a || ((a = document.createElement("div")).classList.add("card-overlay"), (t = document.createElement("div")).classList.add("spinner-border", "text-primary"), a.appendChild(t), e.appendChild(a)), a.style.display = "flex", setTimeout(function () {
54                    a.style.display = "none"
55                }, 1500)
56            })
57        }), $('[data-action="code-collapse"]').on("click", function (e) {
58            e.preventDefault();
59            var e = $(this).closest(".card"), t = $(this).find("i").eq(0);
60            e.find(".code-body").slideToggle(300), t.toggleClass("ti-chevron-up ti-chevron-down")
61        })
62    }
63
64    initMultiDropdown() {
65        // Same as initPortletCard: no multi-level dropdown markup in the app.
66        if (typeof $ === "undefined") return;
67        $(".dropdown-menu a.dropdown-toggle").on("click", function () {
68            var e = $(this).next(".dropdown-menu"), e = $(this).parent().parent().find(".dropdown-menu").not(e);
69            return e.removeClass("show"), e.parent().find(".dropdown-toggle").removeClass("show"), !1
70        })
71    }
72
73    initFormValidation() {
74        document.querySelectorAll(".needs-validation").forEach(t => {
75            t.addEventListener("submit", e => {
76                t.checkValidity() || (e.preventDefault(), e.stopPropagation()), t.classList.add("was-validated")
77            }, !1)
78        })
79    }
80
81    initCounter() {
82        var e = document.querySelectorAll("[data-target]");
83        let t = new IntersectionObserver((e, r) => {
84            e.forEach(s => {
85                if (s.isIntersecting) {
86                    let e = s.target, t = e.getAttribute("data-target").replace(/,/g, ""), a = (t = parseFloat(t), 0),
87                        i, o = (i = Number.isInteger(t) ? Math.floor(t / 25) : t / 25, () => {
88                            a < t ? ((a += i) >
88 t && (a = t), e.innerText = n(a), requestAnimationFrame(o)) : e.innerText = n(t)
89                        });
90
91                    function n(e) {
92                        return e % 1 == 0 ? e.toLocaleString() : e.toLocaleString(void 0, {
93                            minimumFractionDigits: 2,
94                            maximumFractionDigits: 2
95                        })
96                    }
97
98                    o(), r.unobserve(e)
99                }
100            })
101        }, {threshold: 1});
102        e.forEach(e => t.observe(e))
103    }
104
105    initToggle() {
106        document.querySelectorAll("[data-toggler]").forEach(e => {
107            let t = e.querySelector("[data-toggler-on]"), a = e.querySelector("[data-toggler-off]"),
108                i = "on" === e.getAttribute("data-toggler"), o = () => {
109                    i ? (t?.classList.remove("d-none"), a?.classList.add("d-none")) : (t?.classList.add("d-none"), a?.classList.remove("d-none"))
110                };
111            t?.addEventListener("click", () => {
112                i = !1, o()
113            }), a?.addEventListener("click", () => {
114                i = !0, o()
115            }), o()
116        })
117    }
118
119    initPassword() {
120        document.querySelectorAll("[data-password]").forEach(e => {
121            let t = e.querySelector(".form-password"), a = e.querySelector(".password-eye-on"),
122                i = e.querySelector(".password-eye-off");
123            t && a && i && (i.classList.add("d-none"), a.addEventListener("click", () => {
124                t.type = "text", a.classList.add("d-none"), i.classList.remove("d-none")
125            }), i.addEventListener("click", () => {
126                t.type = "password", i.classList.add("d-none"), a.classList.remove("d-none")
127            }))
128        })
129    }
130
131    initDismissible() {
132        document.querySelectorAll("[data-dismissible]").forEach(t => {
133            t.addEventListener("click", () => {
134                var e = t.getAttribute("data-dismissible"), e = document.querySelector(e);
135                e && e.remove()
136            })
137        })
138    }
139
140    initSidenav() {
141        let n = document.querySelector(".side-nav");
142        if (n) {
143            n.querySelectorAll("li [data-bs-toggle='collapse']").forEach(e => {
144                e.addEventListener("click", e => e.preventDefault())
145            });
146            let o = n.querySelectorAll("li .collapse"), e = (o.forEach(e => {
147                e.addEventListener("show.bs.collapse", e => {
148                    let t = e.target, a = [], i = t.parentElement;
149                    for (; i && i !== n;) i.classList.contains("collapse") && a.push(i), i = i.parentElement;
150                    o.forEach(e => {
151                        e === t || a.includes(e) || new bootstrap.Collapse(e, {toggle: !1}).hide()
152                    })
153                })
154            }), window.location.href.split(/[?#]/)[0]), s = window.location.pathname.split("/").pop();
155            n.querySelectorAll(".side-nav-link[href]").forEach(t => {
156                var a = t.getAttribute("href");
157                if (a && (a === s || t.href === e)) {
158                    n.querySelectorAll("a.active, li.active, .collapse.show").forEach(e => {
159                        e.classList.remove("active", "show")
160                    }), t.classList.add("active");
161                    a = t.closest("li.side-nav-item");
162                    a && a.classList.add("active");
163                    let e = t.closest("li");
164                    for (; e && e !== n;) {
165                        e.classList.add("active");
166                        var i, o = e.closest(".collapse");
167                        e = o ? (o.classList.add("show"), (i = n.querySelector(`a[href="#${o.id}"]`)) && (i.setAttribute("aria-expanded", "true"), i = i.closest("li.side-nav-item")) && i.classList.add("active"), o.closest("li")) : e.parentElement
168                    }
169                }
170            }), setTimeout(() => {
171                var e = n.querySelector("li.active .active"),
172                    t = document.querySelector(".sidenav-menu .simplebar-content-wrapper");
173                if (e && t) {
174                    e = e.offsetTop - 300;
175                    if (100 < e) {
176                        var r = t;
177                        t = e;
178                        var l = 600;
179                        let o = r.scrollTop, s = t - o, n = 0;
180                        !function e() {
181                            var t, a, i;
182                            n += 20, r.scrollTop = (t = n, a = o, i = s, (t /= l / 2) < 1 ? i / 2 * t * t + a : -i / 2 * (--t * (t - 2) - 1) + a), n < l && setTimeout(e, 20)
183                        }()
184                    }
185                }
186            }, 200)
187        }
188    }
189}
190
191class LayoutCustomizer {
192    constructor() {
193        this.html = document.documentElement, this.config = {}
194    }
195
196    init() {
197        this.initConfig(), this.monochromeMode(), this.initSwitchListener(), this.initWindowSize(), this._adjustLayout(), this.setSwitchFromConfig(), this.openCustomizer()
198    }
199
200    initConfig() {
201        this.defaultConfig = JSON.parse(JSON.stringify(window.defaultConfig)), this.config = JSON.parse(JSON.stringify(window.config)), this.setSwitchFromConfig()
202    }
203
204    isFirstVisit() {
205        try {
206            return !localStorage.getItem("__user_has_visited__") && (localStorage.setItem("__user_has_visited__", "true"), !0)
207        } catch(e) { return !1 }
208    }
209
210    openCustomizer() {
211        var t = document.getElementById("theme-settings-offcanvas");
212        if (t && this.isFirstVisit()) {
213            let e = new bootstrap.Offcanvas(t);
214            setTimeout(() => {
215                e.show()
216            }, 1e3)
217        }
218    }
219
220    monochromeMode() {
221        var e = document.getElementById("monochrome-mode");
222        e && e.addEventListener("click", () => {
223            this.config.monochrome = !this.config.monochrome, this.config.monochrome ? this.html.classList.add("monochrome") : this.html.classList.remove("monochrome"), this.setSwitchFromConfig()
224        })
225    }
226
227    changeSkin(e) {
228        this.config.skin = e, this.html.setAttribute("data-skin", e), this.setSwitchFromConfig()
229    }
230
231    changeSidenavColor(e) {
232        this.config.sidenav.color = e, this.html.setAttribute("data-sidenav-color", e), this.setSwitchFromConfig()
233    }
234
235    changeSidenavSize(e, t = !0) {
236        this.html.setAttribute("data-sidenav-size", e), t && (this.config.sidenav.size = e, this.setSwitchFromConfig())
237    }
238
239    changeLayoutPosition(e) {
240        this.config.layout.position = e, this.html.setAttribute("data-layout-position", e), this.setSwitchFromConfig()
241    }
242
243    changeTheme(e) {
244        this.config.theme = e, this.html.setAttribute("data-bs-theme", e), this.setSwitchFromConfig()
245    }
246
247    changeTopbarColor(e) {
248        this.config.topbar.color = e, this.html.setAttribute("data-topbar-color", e), this.setSwitchFromConfig()
249    }
250
251    changeSidenavUser(e) {
252        (this.config.sidenav.user = e) ? this.html.setAttribute("data-sidenav-user", e) : this.html.removeAttribute("data-sidenav-user"), this.setSwitchFromConfig()
253    }
254
255    resetTheme() {
256        this.config = JSON.parse(JSON.stringify(window.defaultConfig)), this.changeSkin(this.config.skin), this.changeSidenavColor(this.config.sidenav.color), this.changeSidenavSize(this.config.sidenav.size), this.changeTheme(this.config.theme), this.changeLayoutPosition(this.config.layout.position), this.changeTopbarColor(this.config.topbar.color), this.changeSidenavUser(this.config.sidenav.user), this._adjustLayout()
257    }
258
259    setSwitchFromConfig() {
260        var e = this.config;
261        sessionStorage.setItem("__SIMPLE_CONFIG__", JSON.stringify(e)), document.querySelectorAll(".right-bar input[type=checkbox]").forEach(e => e.checked = !1);
262        ((e, t) => {
263            e = document.querySelector(e);
264            e && (e.checked = t)
265        })('input[name="sidebar-user"]', !0 === e.sidenav.user), [["data-skin", e.skin], ["data-bs-theme", e.theme], ["data-layout-position", e.layout.position], ["data-topbar-color", e.topbar.color], ["data-sidenav-color", e.sidenav.color], ["data-sidenav-size", e.sidenav.size]].forEach(([e, t]) => {
266            e = document.querySelector(`input[name="${e}"][value="${t}"]`);
267            e && (e.checked = !0)
268        })
269    }
270
271    initSwitchListener() {
272        var e = (e, t) => {
273                document.querySelectorAll(e).forEach(e => e.addEventListener("change", () => t(e)))
274            },
275            e = (document.querySelectorAll("button[data-skin]").forEach(e => e.addEventListener("click", () => this.changeSkin(e.getAttribute("data-skin")))), e('input[name="data-sidenav-color"]', e => this.changeSidenavColor(e.value)), e('input[name="data-sidenav-size"]', e => this.changeSidenavSize(e.value)), e('input[name="data-bs-theme"]', e => this.changeTheme(e.value)), e('input[name="data-layout-position"]', e => this.changeLayoutPosition(e.value)), e('input[name="data-topbar-color"]', e => this.changeTopbarColor(e.value)), e('input[name="sidebar-user"]', e => this.changeSidenavUser(e.checked)), document.getElementById("light-dark-mode")),
276            e = (e && e.addEventListener("click", () => {
277                var e = "light" === this.config.theme ? "dark" : "light";
278                this.changeTheme(e)
279            }), document.querySelector("#reset-layout")),
280            e = (e && e.addEventListener("click", () => this.resetTheme()), document.querySelector(".button-close-offcanvas"));
281        e && e.addEventListener("click", () => {
282            this.html.classList.remove("sidebar-enable"), this.hideBackdrop()
283        }), document.querySelectorAll(".button-collapse-toggle").forEach(e => {
284            e.addEventListener("click", () => {
285                var e = this.html.getAttribute("data-sidenav-size");
286                "offcanvas" === e ? (this.showBackdrop(), this.html.classList.toggle("sidebar-enable")) : this.changeSidenavSize({
287                    default: "collapse",
288                    collapse: "default"
289                }[e], !0)
290            })
291        })
292    }
293
294    showBackdrop() {
295        var e, t, a = document.createElement("div");
296        a.id = "custom-backdrop", a.className = "offcanvas-backdrop fade show", document.body.appendChild(a), document.body.style.overflow = "hidden", document.body.style.paddingRight = ((e = document.createElement("div")).style.visibility = "hidden", e.style.overflow = "scroll", e.style.width = "100px", e.style.height = "100px", document.body.appendChild(e), (t = document.createElement("div")).style.width = "100%", e.appendChild(t), t = e.offsetWidth - e.clientWidth, document.body.removeChild(e), t + "px"), a.addEventListener("click", () => {
297            this.html.classList.remove("sidebar-enable"), this.hideBackdrop()
298        })
299    }
300
301    hideBackdrop() {
302        var e = document.getElementById("custom-backdrop");
303        e && (document.body.removeChild(e), document.body.style.overflow = "", document.body.style.paddingRight = "")
304    }
305
306    _adjustLayout() {
307        var e = window.innerWidth, t = this.config.sidenav.size;
308        e <= 1199 ? this.changeSidenavSize("offcanvas", !1) : this.changeSidenavSize(t)
309    }
310
311    initWindowSize() {
312        window.addEventListener("resize", () => this._adjustLayout())
313    }
314}
315
316class Plugins {
317    init() {
318        this.initFlatPicker(), this.initTouchSpin()
319    }
320
321    initFlatPicker() {
322        document.querySelectorAll("[data-provider]").forEach(e => {
323            var t = e.getAttribute("data-provider"), a = e.attributes, i = {disableMobile: !0, defaultDate: new Date};
324            "flatpickr" === t ? (a["data-date-format"] && (i.dateFormat = a["data-date-format"].value), a["data-enable-time"] && (i.enableTime = !0, i.dateFormat += " H:i"), a["data-altFormat"] && (i.altInput = !0, i.altFormat = a["data-altFormat"].value), a["data-minDate"] && (i.minDate = a["data-minDate"].value), a["data-maxDate"] && (i.maxDate = a["data-maxDate"].value), a["data-default-date"] && (i.defaultDate = a["data-default-date"].value), a["data-multiple-date"] && (i.mode = "multiple"), a["data-range-date"] && (i.mode = "range"), a["data-inline-date"] && (i.inline = !0, i.defaultDate = a["data-default-date"].value), a["data-disable-date"] && (i.disable = a["data-disable-date"].value.split(",")), a["data-week-number"] && (i.weekNumbers = !0), flatpickr(e, i)) : "timepickr" === t && (i = {
325                enableTime: !0,
326                noCalendar: !0,
327                dateFormat: "H:i",
328                defaultDate: new Date
329            }, a["data-time-hrs"] && (i.time_24hr = !0), a["data-min-time"] && (i.minTime = a["data-min-time"].value), a["data-max-time"] && (i.maxTime = a["data-max-time"].value), a["data-default-time"] && (i.defaultDate = a["data-default-time"].value), a["data-time-inline"] && (i.inline = !0, i.defaultDate = a["data-time-inline"].value), flatpickr(e, i))
330        })
331    }
332
333    initTouchSpin() {
334        document.querySelectorAll("[data-touchspin]").forEach(e => {
335            var n = e.querySelector("[data-minus]"), r = e.querySelector("[data-plus]");
336            let l = e.querySelector("input");
337            if (l) {
338                let t = Number(l.min), a = Number(l.max ?? 0), i = Number.isFinite(t), o = Number.isFinite(a),
339                    s = () => Number.parseInt(l.value) || 0;
340                l.hasAttribute("readonly") || (n && n.addEventListener("click", () => {
341                    var e = s() - 1;
342                    (!i || e >= t) && (l.value = e.toString())
343                }), r && r.addEventListener("click", () => {
344                    var e = s() + 1;
345                    (!o || e <= a) && (l.value = e.toString())
346                }))
347            }
348        })
349    }
350}
351
352
353let ins = (e, t = 1) => {
354    var a = getComputedStyle(document.documentElement).getPropertyValue("--ins-" + e).trim();
355    return e.includes("-rgb") ? `rgba(${a}, ${t})` : a
356};
357
358function debounce(e, t) {
359    let a;
360    return function () {
361        clearTimeout(a), a = setTimeout(e, t)
362    }
363}
364
365class CustomChartJs {
366    static instances = [];
367
368    constructor({selector: e, options: t = () => ({})}) {
369        if (e) {
370            this.selector = e, this.getOptions = "function" == typeof t ? t : () => t, this.element = null, this.chart = null;
371            try {
372                this.render(), CustomChartJs.instances.push(this)
373            } catch (e) {
374                console.error("CustomChartJs: Initialization error", e)
375            }
376        } else console.warn("CustomChartJs: 'selector' is required.")
377    }
378
379    static getDefaultOptions() {
380        var e = getComputedStyle(document.body).fontFamily.trim();
381        return {
382            responsive: !0,
383            maintainAspectRatio: !1,
384            layout: {padding: {top: -10}},
385            scales: {
386                x: {
387                    ticks: {font: {family: e}, color: ins("secondary-color"), display: !0, drawTicks: !0},
388                    grid: {display: !1, drawBorder: !1},
389                    border: {display: !1}
390                },
391                y: {
392                    ticks: {font: {family: e}, color: ins("secondary-color")},
393                    grid: {display: !0, drawBorder: !1, color: ins("chart-border-color"), lineWidth: 1},
394                    border: {display: !1, dash: [5, 5]}
395                }
396            },
397            plugins: {
398                legend: {
399                    display: !0,
400                    position: "top",
401                    labels: {
402                        font: {family: e},
403                        color: ins("secondary-color"),
404                        usePointStyle: !0,
405                        pointStyle: "circle",
406                        boxWidth: 8,
407                        boxHeight: 8,
408                        padding: 15
409                    }
410                }, tooltip: {enabled: !0, titleFont: {family: e}, bodyFont: {family: e}}
411            }
412        }
413    }
414
415    render() {
416        try {
417            var e, t, a, i;
418            this.element = this.selector instanceof HTMLElement ? this.selector : document.querySelector(this.selector), this.element ? (this.chart && this.chart.destroy(), {
419                type: e,
420                data: t,
421                options: a,
422                plugins: i
423            } = this.getOptions(), this.chart = new Chart(this.element, {
424                type: e || "bar",
425                data: t,
426                options: {...structuredClone(CustomChartJs.getDefaultOptions()), ...a || {}},
427                plugins: i || []
428            }), window.addEventListener("resize", debounce(() => {
429                this.chart && this.chart.resize()
430            }, 200))) : console.warn(`CustomChartJs: No element found for selector '${this.selector}'`)
431        } catch (e) {
432            console.error(`CustomChartJs: Render error for '${this.selector}'`, e)
433        }
434    }
435
436    static rerenderAll() {
437        for (var e of CustomChartJs.instances) e.render()
438    }
439
440    static reSizeAll() {
441        for (var e of CustomChartJs.instances) e.chart && e.chart.resize()
442    }
443
444    static destroyAll() {
445        for (var e of CustomChartJs.instances) e.chart && e.chart.destroy();
446        CustomChartJs.instances = []
447    }
448}
449
450CustomChartJs.instances = [];
451let themeObserver = new MutationObserver(() => {
452    CustomChartJs.rerenderAll()
453}), menuObserver = (themeObserver.observe(document.documentElement, {
454    attributes: !0,
455    attributeFilter: ["data-skin", "data-bs-theme"]
456}), new MutationObserver(() => {
457    requestAnimationFrame(() => {
458        CustomChartJs.reSizeAll()
459    })
460}));
461menuObserver.observe(document.documentElement, {attributes: !0, attributeFilter: ["data-sidenav-size"]});
462
463document.addEventListener("DOMContentLoaded", () => {
464    new LayoutCustomizer().init();
465});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.