/**
 * Alpus APRS Single Product Admin JS
 * 
 * @since 1.1.0
 */
( function($) {
    var init = function() {
        var postID = $('#post_ID').val(),
            $status = $('#alpus-aprs-sp-status-description');

        setTimeout( function() {
            $.ajax({
                type: 'post',
                data: {
                    action: 'alpus_aprs_sp_info',
                    none: alpus_aprs_sp_admin_vars.nonce,
                    id: postID
                },
                url: alpus_aprs_sp_admin_vars.ajax_url,
                success: function ( res ) {

                    if ( res.success ) {
                        // Update current status.
                        if ( res.data.current ) {
                            $status.find('.current').html(res.data.current);
                        }

                        if ( res.data.total ) {
                            $status.find('.total').html(res.data.total);
                        }
                    }
                }
            });
        },
        200 );
    }
    
    $(document).ready(function() {
        init();
    });
} ) (jQuery);
