<script type="text/javascript">
    $(document).ready(function () {
        $('.create_ucs').click(function (e) {
            if (confirm('确定开启此课吗?')) {
                e.preventDefault();
                var url = $(this).attr('data-confirm');
                $.post(url).done(function (data) {
                    alert(data['message']);
                    window.location.href = data['new_url'];
                });
            }
        });

        $('.pass_ucs').click(function (e) {
            if (confirm('确定通过此课吗?')) {
                e.preventDefault();
                var url = $(this).attr('data-confirm');
                $.post(url).done(function (data) {
                    alert(data['message']);
                    window.location.href = data['new_url'];
                });
            }
        });

        $('.close_ucs').click(function (e) {
            if (confirm('此操作将清空课件学习时间，是否继续?')) {
                e.preventDefault();
                var url = $(this).attr('data-confirm');
                $.post(url).done(function (data) {
                    alert(data['message']);
                    window.location.href = data['new_url'];
                });
            }
        });

    });

    function save_minus_live_mins(ucs_id) {
        var mins = $("#minus_live_mins_" + ucs_id).val();
        var url = "{% url 'bee_django_course:save_ucs_minus_live_mins' %}";
        $.post(url, {"ucs_id": ucs_id, "mins": mins}).done(function (data) {
            alert(data['msg']);
            if (data.error == 0) {
                location.reload();
            }
        });
    }

</script>