%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home2/rezakur1/devita.rezakurnia.com/X9KQ7MW2RT8PY4ND6LV3JH5CG8BF2ZM7QW4/scene/
Upload File :
Create Path :
Current File : //home2/rezakur1/devita.rezakurnia.com/X9KQ7MW2RT8PY4ND6LV3JH5CG8BF2ZM7QW4/scene/scene0.js

function checkDeviceSupport() {
    const blocker = document.getElementById('deviceBlocker');

    const width = window.innerWidth;
    const height = window.innerHeight;

    const isPortrait = height > width;
    const isSmallScreen = width < 1024;

    blocker.style.display =
        (isPortrait || isSmallScreen)
            ? 'flex'
            : 'none';
}

/* ==========================
MODAL KODE AKSES
========================== */

window.openAccessModal = function () {
    const modal =
        document.getElementById('accessModal');

    if (modal) {
        modal.style.display = 'flex';
    }
};

window.closeAccessModal = function () {
    const modal =
        document.getElementById('accessModal');

    if (modal) {
        modal.style.display = 'none';
    }
};

/* ==========================
LOADING
========================== */

window.addEventListener('load', () => {

    const loader =
        document.getElementById('loadingScreen');

    checkDeviceSupport();

    setTimeout(() => {
        loader.classList.add('hidden');
    }, 1200);

    const verifyButton =
        document.getElementById('btnVerifyAccess');

    if (verifyButton) {
        verifyButton.addEventListener(
            'click',
            verifyAccessCode
        );
    }
});

window.addEventListener(
    'resize',
    checkDeviceSupport
);

/* ==========================
VERIFIKASI KODE
========================== */

async function verifyAccessCode() {

    const code =
        document
            .getElementById('accessCode')
            .value
            .trim();

    const error =
        document.getElementById(
            'accessError'
        );

    error.innerHTML = '';

    if (!code) {

        error.innerHTML =
            'Kode akses wajib diisi';

        return;
    }

    try {

        const response =
            await fetch(
                'https://dashboard.ionicliquidapplication.my.id/api/access-codes/verify',
                {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json',
                        'Accept': 'application/json',
                    },
                    body: JSON.stringify({
                        code: code,
                    }),
                }
            );

        const result =
            await response.json();

        if (!result.success) {

            error.innerHTML =
                result.message;

            return;
        }

        localStorage.setItem(
            'access_code',
            code
        );

        localStorage.setItem(
            'access_code_id',
            result.data.id
        );

        goTo('scene1');

    } catch (e) {

        console.error(e);

        error.innerHTML =
            'Gagal terhubung ke server';
    }
}

window.closeAccessModal = function () {

    document
        .getElementById('accessModal')
        .style.display = 'none';

    document
        .getElementById('accessError')
        .innerHTML = '';

    document
        .getElementById('accessCode')
        .value = '';
};

document.addEventListener('click', function (e) {

    const modal =
        document.getElementById('accessModal');

    if (
        e.target === modal
    ) {
        closeAccessModal();
    }
});

Zerion Mini Shell 1.0