{"size": 1939, "ext": "js", "max_stars_repo_path": "resources/js/app.js", "max_stars_repo_name": "QuintenvandenHerik/BaseApplication", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "resources/js/app.js", "max_issues_repo_name": "QuintenvandenHerik/BaseApplication", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "resources/js/app.js", "max_forks_repo_name": "QuintenvandenHerik/BaseApplication", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 23.9382716049, "max_line_length": 146, "alphanum_fraction": 0.5203713254}
require('./bootstrap');

import Alpine from 'alpinejs';

window.Alpine = Alpine;

Alpine.start();

// Start jQuery
window.onload = function() {
    if (!window.$) {
        // jQuery is not loaded!
        alert("jQuery is not loaded!");
    }

    // Start Modal
    // DOM Elements
    const modalBackdrop = $('#modal-backdrop');
    // Modal vars
    let lastActivatedModal;

    $("#create-module").click(function() {
        toggleModal("#create-module-modal");
        console.log("I am Working");
    });

    modalBackdrop.click(function(e) {
        if (e.target === this) {
            toggleModal(lastActivatedModal);
        }
    });

    function toggleModal(modalID){
        $("body").toggleClass("overflow-hidden");
        if (lastActivatedModal) {
            $(lastActivatedModal).toggleClass("hidden");
            $("#modal-backdrop").toggleClass("hidden");
            unset(lastActivatedModal);
            return;
        }

        $(modalID).toggleClass("hidden");
        modalBackdrop.toggleClass("hidden");
        lastActivatedModal = modalID;
    }
    // End Modal

    // Start Form Submit
    $("form").submit(function(e) {
        // TODO: fix only allowed forms
        if($(this).attr('action').includes('login') || $(this).attr('action').includes('register') || $(this).attr('action').includes('logout')) {
            return;
        }
        e.preventDefault();
        let formData = $(this).serializeArray();
        $.ajax({
            url: $(this).attr('action'),
            type:'POST',
            data: formData,
            success: function(msg)
            {
                console.log(msg);
            },
            error: function(error)
            {
                console.log(error)
            }
        });
    });
    // End Form Submit

    // Start App
    function unset(variable) {
        variable = null

        return variable;
    }
    // End App
}
// End jQuery
