{"size": 1847, "ext": "js", "max_stars_repo_path": "public/customer/js/app.wishlist.js", "max_stars_repo_name": "Nucleus-Technologies/lima-t-jasino", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "public/customer/js/app.wishlist.js", "max_issues_repo_name": "Nucleus-Technologies/lima-t-jasino", "max_issues_repo_issues_event_min_datetime": "2021-03-09T13:22:47.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-26T15:53:59.000Z", "max_forks_repo_path": "public/customer/js/app.wishlist.js", "max_forks_repo_name": "Nucleus-Technologies/lima-t-jasino", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 4, "max_forks_count": null, "avg_line_length": 31.3050847458, "max_line_length": 106, "alphanum_fraction": 0.4753654575}
$(function() {

    // Add an outfit to the wishlist
    $('.btn-add-to-wishlist').on('click', function(e) {
        e.preventDefault();

        if (!$(this).hasClass('active')) {
            var outfit = $(this).parent().find('input[name=outfit]').val();

            var request = $.ajax({
                type: 'POST',
                url: '/users/wishlist/outfit-' + outfit + '/store',
                data: $(this).parent('form').serialize()
            });

            request.done(function(response) {
                if (response.status) {
                    $(this).addClass('active');

                    fadeAlert((response.status) ? 'success' : 'danger', response.msg);
                } else {
                    fadeAlert('danger', response.msg);
                }
            });

            request.fail(function() {
                fadeAlert('danger', "An script error occured while adding this outfit to your wishlist!");
            });
        }

    });

    // Remove an outfit from the wishlist
    $('.btn-remove-from-wishlist').on('click', function(e) {
        e.preventDefault();

        var wishlist = $(this).parent().find('input[name=wishlist]').val();

        var request = $.ajax({
            type: 'POST',
            url: '/users/wishlist/line-' + wishlist + '/destroy',
            data: $(this).parent('form').serialize()
        });

        request.done(function(response) {
            if (response.status) {
                $('#wishlist_inner').fadeOut();
                refresh_wishlist();
                $('#wishlist_inner').fadeIn();
            } else {
                fadeAlert('danger', response.msg);
            }
        });

        request.fail(function() {
            fadeAlert('danger', "An script error occured while removing this outfit from your cart!");
        });
    });
});