<div class="blue-border-box">
  <div class="box-con">
    <h4 id = "compare-tips-1"></h4>
    <div class="box-con-a">
      <a href="javascript:void(0);" class="Blue-btn fl " onclick = "compare_code_btn(<%=homework.id%>,<%=courseid%>)">重新查重</a>
      <a href="javascript:void(0);" class="Blue-btn fl " onclick = "see_last_compare_code(<%=courseid%>,<%=homework.id%>)">查看结果</a>
    </div>
    <div class="cl"></div>
  </div>
</div>
</div>

<script type="text/javascript">
    //请求重新查重
    function compare_code_btn(homeworkid,courseid)
    {
        hideModal($(".blue-border-box"));
        test_repeat(homeworkid,courseid);

    }
    //查看结果
    function see_last_compare_code(courseid,homeworkid)
    {
        hideModal($(".blue-border-box"));
        var rootpath = getRootPath();
        var code_repeatpath = rootpath+"/courses/"+courseid+"/code_repeat?homework="+homeworkid;
        //新打开页面
        window.open(code_repeatpath);
    }

    var test_repeat = function(homeworkid,courseid){
        $.post(
                '/student_work/code_repeattest',
                {homework: homeworkid},
                function(data,status){
                    console.log("result = ");
                    console.log(data);

                    if (data.status == 0) {
                        $("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_2',:locals => {:des=>"查重完成，是否立即查看结果？",:status=>1, :homework=> homework,:courseid=> courseid})%>');
                        showModal('ajax-modal', '580px');
                        $('#ajax-modal').siblings().remove();
                        $('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal();' style='margin-left: 565px; margin-top:-10px;' class='resourceClose'></a>");
                        //$('#ajax-modal').parent().css("top","40%").css("left","50%");
                        $('#ajax-modal').parent().css("top","30%").css("left","50%").css("padding-top","10px").css("position","fixed");
                        $('#ajax-modal').parent().addClass("resourceUploadPopup");
                        $('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px");

                        function closeModal(){
                            hideModal($(".blue-border-box"));
                        }
                    }
                    else if (data.status == -1){
//                          confirm("对不起只支持java/c/c++的代码查重!");
                        $("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_2',:locals => {:des=>"对不起目前只支持java/c/c++的代码查重!",:status=>0, :homework=> homework,:courseid=> courseid})%>');
                        showModal('ajax-modal', '580px');
                        $('#ajax-modal').siblings().remove();
                        $('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal();' style='margin-left: 565px; margin-top:-10px;' class='resourceClose'></a>");
                        $('#ajax-modal').parent().css("top","30%").css("left","50%").css("padding-top","10px").css("position","fixed");
                        $('#ajax-modal').parent().addClass("resourceUploadPopup");
                        $('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px");

                        function closeModal(){
                            hideModal($(".blue-border-box"));
                        }

                    }
                    else if (data.status == -2){
//                          confirm("对不起该作业的作品过少不能查重!");
                        $("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_2',:locals => {:des=>"对不起该作业的作品过少不能查重!",:status=>0, :homework=> homework,:courseid=> courseid})%>');
                        showModal('ajax-modal', '580px');
                        $('#ajax-modal').siblings().remove();
                        $('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal();' style='margin-left: 565px; margin-top:-10px;' class='resourceClose'></a>");
                        $('#ajax-modal').parent().css("top","30%").css("left","50%").css("padding-top","10px").css("position","fixed");
                        $('#ajax-modal').parent().addClass("resourceUploadPopup");
                        $('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px");

                        function closeModal(){
                            hideModal($(".blue-border-box"));
                        }
                    }
                    return;
                }
        ).fail(function(xhr, status){
//                    confirm("对不起,服务器繁忙请稍后再试!");
                    $("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_2',:locals => {:des=>"对不起,服务器繁忙请稍后再试!",:status=>0, :homework=> homework,:courseid=> courseid})%>');
                    showModal('ajax-modal', '580px');
                    $('#ajax-modal').siblings().remove();
                    $('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal();' style='margin-left: 565px; margin-top:-10px;' class='resourceClose'></a>");
                    $('#ajax-modal').parent().css("top","30%").css("left","50%").css("padding-top","10px").css("position","fixed");
                    $('#ajax-modal').parent().addClass("resourceUploadPopup");
                    $('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px");

                    function closeModal(){
                        hideModal($(".blue-border-box"));
                    }
                    return;
                });
    };
</script>