summaryrefslogtreecommitdiff
path: root/assets/load.js
blob: ade61cb15cac0805f75fe8d7322ba865460d78ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
window.onload = async () => {
    setTimeout(() => {
        document.getElementById("loader-text").innerText = "Loading...";
        updateLoader();

        if (!isNodeJS) {
            document.getElementById("mobile-css").removeAttribute("disabled");
        }

        setTimeout(async () => {
            document.getElementById("loader-text").innerText = "Authenticating with the server...";
            updateLoader();
            loginStatus = JSON.parse(await (await window.fetch("https://money-v1.equestria.dev/Authentication/Test/")).text()).status;
            if (loginStatus === 1) {
                document.getElementById("loader-text").innerText = "Redirecting to login page...";
                updateLoader();
                console.info("Starting authentication procedure (Mobile)");
                location.href = "https://money-v1.equestria.dev/Authentication/Mobile2/"
            } else {
                console.info("Authenticated successfully");

                await plural();
                await refresh();
            }
        }, 1000)
    }, 1000)
}

let currentLoad = 0;
function updateLoader() {
    let step = 6.25;
    currentLoad = currentLoad + step;

    document.getElementById("loader-img").style.background = "linear-gradient(-90deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0) " + (100 - currentLoad) + "%, var(--mdc-theme-primary) " + (100 - currentLoad) + "%, var(--mdc-theme-primary) 100%)";
}