<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ExaminationMoblie.aspx.cs" Inherits="RM.Web.Training.Exam.ExaminationMoblie" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Examination_Title")%></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=2.0, user-scalable=no" />

    <link href="Themes/Css/ExamGlobal.css" rel="stylesheet" type="text/css" />
    <script src="/Themes/Scripts/jquery-1.8.2.min.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/artDialog/artDialog.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/artDialog/iframeTools.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/FunctionJS.js" type="text/javascript"></script>
    <link href="/Themes/Scripts/artDialog/skins/opera.css" rel="stylesheet" type="text/css" />
    <link href="/Training/Exam/Themes/Css/ExaminationCss.css" rel="stylesheet" type="text/css" />
    <link type="text/css" href="/Themes/Styles/mobile_index.css" rel="stylesheet" />    
    <script type="text/javascript" src="/Training/Learn/m/ckplayer/ckplayer.js" charset="utf-8"></script>
    <script src="/Live/swfobject.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/jQuery.path2html.js" type="text/javascript"></script>
    <style type="text/css">
    .cor5,.exam_result label,.exam_Title{ font-size:16px; line-height:25px;  }    
    .exam_result input{ margin-top:6px; }
    .exam_result li{ padding-left:5px; }
    .activeQuetion{ display:block;}
    </style>

    <script type="text/javascript">
        //        $("input[type=checkbox],input[type=radio],input[type=text],textarea").attr("disabled", "disabled"); //把答题锁住
        var resultKey = $("#submitExam3").attr("resultKey"); //xml文件路径
        var pageError = true; //表示页面是否有错误，默认true表示有
        $(function () {
            //把经常变换的对象预留出来
            resultKey = $("#submitExam3").attr("resultKey"); //xml文件路径
            var $currQueCount = $("#currQueCount"); //答题情况
            var $exam_Num = $("#exam_Num"); //题目编号
            var $exam_Type = $("#exam_Type"); //题目类型
            var $exam_Score = $("#exam_Score"); //题目分值
            var $list = $(".ques_Context"); //题目对象
            var $linkList = $(".curr_State>li>a"); //右侧题目编号列表
            var $pageBody = $("body"); //body对象
            var $examItem = $("#examItem"); //左侧题目对象
            var $surplusDate = $("#surplusDate"); //剩余时间的html对象
            if (!$list || $list.length < 1 || !$linkList || $linkList.length < 1) {//页面有错误
                return;
            }
            pageError = false;
            $list.first().addClass("activeQuetion");
            $linkList.first().addClass("currLinkNum");
            function triggerText() {//触发textarea的blur事件
                var $currText = $(".activeQuetion").find("textarea");
                if ($(".activeQuetion").find("textarea").length > 0) $currText.blur();
            }
            $("#upQuestion").click(function () {//上一题
                //triggerText();
                var $tempObj = $(".activeQuetion");
                var $tempNumObj = $(".currLinkNum");
                if ($tempObj.prev().length < 1) {
                    showFaceMsg('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterList_mysyt")%>');
                } else {
                    $tempObj.removeClass("activeQuetion").prev().addClass("activeQuetion");
                    $tempNumObj.removeClass("currLinkNum").prev().addClass("currLinkNum");
                }
            });
            $("#nextQuesion").click(function () {//下一题
                //triggerText();
                var $tempObj = $(".activeQuetion");
                var $tempNumObj = $(".currLinkNum");
                if ($tempObj.next().length < 1) {
                    showFaceMsg('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterList_myxyt")%>');
                } else {
                    $tempObj.removeClass("activeQuetion").next().addClass("activeQuetion");
                    $tempNumObj.removeClass("currLinkNum").next().addClass("currLinkNum");
                }
            });
            $linkList.click(function () { //右侧题目列表
                //triggerText();
                $(".activeQuetion").removeClass("activeQuetion");
                $(".currLinkNum").removeClass("currLinkNum");
                $(this).addClass("currLinkNum");
                $list.eq(parseInt($(this).text()) - 1).addClass("activeQuetion");
            });
            $(".exam_result>li").hover(function () {//选项的悬浮
                if ($(this).has("textarea").length > 0) return;
                $(this).addClass("hoverLi");
            }, function () {
                if ($(this).has("textarea").length > 0) return;
                $(this).removeClass("hoverLi");
            });

            //阻止事件冒泡的通用函数  
            function stopBubble(e) {
                // 如果传入了事件对象，那么就是非ie浏览器  
                if (e && e.stopPropagation) {
                    //因此它支持W3C的stopPropagation()方法  
                    e.stopPropagation();
                } else {
                    //否则我们使用ie的方法来取消事件冒泡  
                    window.event.cancelBubble = true;
                }
            }
            $(".exam_result>li>input:radio").change(function () {//radio选项的选中样式改变
                $(this).parent().parent().children("li").removeClass("checkedInput");
                $(this).parent().addClass("checkedInput");
                postback($(this).parent().parent().children("li"), $(this).attr("name"), $(this).attr("data"), $surplusDate.text(), resultKey, $(".activeQuetion").index());

            });
            $(".exam_result>li>input[type=checkbox]").change(function () {//checkbox选项的选中样式改变
                if ($(this).is(":checked")) {
                    $(this).parent().addClass("checkedInput");
                } else {
                    $(this).parent().removeClass("checkedInput");
                }
                var data = "";
                $(this).parent().parent().children("li").children("input:checked").each(function () {
                    data += $(this).attr("data");
                });
                postback($(this).parent().parent().children("li"), $(this).attr("name"), data, $surplusDate.text(), resultKey, $(".activeQuetion").index());
            });

            $(".exam_result>li>input[type=text]").blur(function () {
                var data = "";
                $(this).parent().parent().children("li").children("input:text").each(function () {
                    data += $(this).val();
                });
                postback($(this).parent().parent().children("li"), $(this).attr("name"), data, $surplusDate.text(), resultKey, (divindex == -1) ? $(".activeQuetion").index() : divindex);
            });

            $(".exam_Title>input[type=text]").blur(function () {
                var data = "";
                $(this).parent().children("input:text").each(function () {
                    data += $(this).val() + "、";
                });
                data = data.length > 0 ? data.substring(0, data.length - 1) : "";
                postback($(this).parent().parent().children("li"), $(this).attr("name"), data, $surplusDate.text(), resultKey, $(".activeQuetion").index());
            });

            $(".exam_result>li>textarea").blur(function () {
                postback($(this), $(this).attr("name"), $(this).val(), $surplusDate.text(), resultKey, $(".activeQuetion").index());
            });

            $("label").click(function (e) {//阻止事件冒泡，如果不阻止则单击li触发label的click()，然后label又触发li的click，冒泡无限循环了
                stopBubble(e);
            });
            $(".exam_result>li").click(function (e) {//li单击事件
                $(this).children("label").click();
            });
            function postback(objList, questionKey, itemKey, overplus, resultKey, currIndex) {
                $(objList).attr("disabled", "disabled"); //锁住选项
                $.ajax({
                    url: "/Training/Exam/ReplyQuesion.ashx",
                    type: "post",
                    data: { "replay": itemKey, "queKey": questionKey, "resultKey": resultKey, "overplus": overplus },
                    dataType: "text",
                    success: function (data) {
                        if (data) {
                            if (parseInt(data) < 0) {
                                showTipsMsg('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterList_sjtjyc")%>', 2000, 5);
                            } else {//答题成功
                                if (parseInt(data) == 0) {//取消回答
                                    $linkList.eq(currIndex).removeAttr("style");
                                    $currQueCount.text(parseInt($currQueCount.text()) - 1);
                                } else {//回答成功
                                    $linkList.eq(currIndex).css({ "background-color": "#a0ff76", "color": "black" });
                                    $currQueCount.text(data);
                                }
                            }
                        } else {
                            showWarningMsg('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterList_wlljyc")%>');
                        }
                        $(objList).removeAttr("disabled"); //释放选项
                    },
                    error: function () {
                        showWarningMsg('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterList_wlljyc")%>');
                        $(objList).removeAttr("disabled");
                    }
                });
            }

            $("#submitExam3").click(function () {//提交试卷按钮
                showConfirmMsg('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Examination_tijiao")%>', function () {
                    //window.location = "/Training/tiku/frame.aspx?retURL=/Training/Exam/Report_mobile.aspx?exam=Not&key=" + resultKey;            
                    window.location = "/Training/Exam/Report_mobile.aspx?exam=Not&key=" + resultKey;
                });
            });
        });
        /*
        *@Discription : 倒计时
        */
        var minute; //剩余分钟
        var second = 0; //剩余秒钟
        var interValObj; //计时方法
        window.onload = function () {//页面加载完成开始倒计时
            $surplusDate = $("#surplusDate");
            minute = parseInt($("#surplusDate").text());
            second = $("#surplusDate").text().split(":")[1];
            interValObj = window.setInterval(setRemainTime, 1000);
        }
        function setRemainTime() { //倒计时方法
            if (pageError)//页面有错误
                return;
            if (minute == 0 && second == 0) {
                window.clearInterval(interValObj);
                $surplusDate.text("00:00");
                showFaceMsg('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Examination_sjdxtzdjj")%>');
                //window.location = "/Training/tiku/frame.aspx?retURL=/Training/Exam/Report_mobile.aspx?Not=exam&key=" + resultKey;
                window.location = "/Training/Exam/Report_mobile.aspx?Not=exam&key=" + resultKey;
                //                window.parent.window.history.go(-1); //跳转页面
            } else {
                second -= 1;
                if (second < 0) {
                    second = 59;
                    minute -= 1;
                }
                var djstime = (minute.toString().length == 1 ? "0" + minute : minute) + ":" + (second.toString().length == 1 ? "0" + second : second);
                $surplusDate.text(djstime);
                if (djstime == "05:00") {
                    showTipsMsg('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Exam_kssysj")%>', 3000, 3);
                }
            }
        }
        var mathcontent = "";
        function mathshow(mathname) {
            mathcontent = mathname;
            //alert(mathcontent);
            $("#mathquill").show();
        }
        //光标处插入图片
        function funInsertTopic(textObj, textStr) {
            textObj.focus();

            var topic = textStr, value = textObj.value, index = value.indexOf(topic);
            if (index === -1) {
                //匹配
                funTextAsTopic(textObj, topic);
            }
            value = textObj.value;
            index = value.indexOf(topic);
            if (textObj.createTextRange) {
                var range = textObj.createTextRange();
                range.moveEnd("character", (index + textStr.length) - value.length);
                range.moveStart("character", index);
                range.select();
            } else {
                textObj.setSelectionRange(index, index + textStr.length);
                textObj.focus();
            }
        };
        function funTextAsTopic(textObj, textFeildValue) {
            if (textObj.createTextRange) {
                var caretPos = document.selection.createRange().duplicate();
                document.selection.empty();
                caretPos.text = textFeildValue;
            } else if (textObj.setSelectionRange) {
                var rangeStart = textObj.selectionStart;
                var rangeEnd = textObj.selectionEnd;
                var tempStr1 = textObj.value.substring(0, rangeStart);
                var tempStr2 = textObj.value.substring(rangeEnd);
                textObj.value = tempStr1 + textFeildValue + tempStr2;
                textObj.blur();
            }
        };
        function Tshow() {
            $("#toolBar").toggle();
        }
        function Thide() {
            $("#toolBar").hide();
        }        
    </script>
    
</head>
<body style="min-height:550px;" >
    <form id="form1" runat="server" action="/Training/Exam/ExaminationMoblie.aspx" > 
    <div style="margin:0 auto;">
    <div class="mid_head_tit" style="height:30px">
        <h3 class="h3 fs14 cor1" style="height:30px;padding-top:4px; padding-left:5px;overflow:hidden;" runat="server" id="ExaminationPaperTitle"></h3>
    </div>
	<div style="width:300px; margin:0 auto;">

    <div id="container" class="pb120" style="padding-bottom:120px;">
        <div id="examItem" class="pb60" style=" width:96%; margin-top:2px; padding:2%; background-color:#fff; " style="padding-bottom:120px;">
            <div id="ei_Container" style=" font-size:18px; padding:10px; "  >
                    <%=QuestionHtml.ToString() %>                
            </div>
            <div class="mb10 ml10"  id="btnContainer">
            	<a href="#" style=" padding:8px 10px;"  id="upQuestion" class="background5">
                &nbsp;<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterList_syt")%>&nbsp;</a>
            	<a href="#" style=" padding:8px 10px;" id="nextQuesion" class="background5">
                &nbsp;<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterList_xyt")%>&nbsp;</a>
            </div>
                
            <div class="promptContext">
                <label class="asterisk">
                    *
                </label>
                <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Examination_tsdjxxjkdtxzdah")%><br />
                &nbsp;&nbsp;<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Examination_djsybottom")%>
            </div>
        </div>
        <div id="toolBar" style=" position:absolute; top:0; right:0; display:none;">
            <ul id="currState" style=" display:none;">            
                <li id="prot_Title"><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Examination_kssysj")%></li>
           
            </ul>
            
            <div id="currStateInfo">
                <div class="ans_State"><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Examination_dtqk")%></div>
               <div style=" text-align:right;"><span onclick="Thide()"><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Close")%></span></div>
                <ul class="curr_State">
                    <li>
                        <%=LinkStateHtml.ToString() %>
                    </li>
                </ul>
                <div class="promptContext">
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Examination_dgdtmxshs")%><br />
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Examination_wdgdxsbs")%></div>
            </div>
        </div>
        <div class="clear">
        </div>
    </div>
  </div>
  
<div style=" padding-top:5px;  width:100%; position:fixed; bottom:0px; background-color:White; border-top:1px #ccc solid;">
    <table width="100%"><tr><td style=" width:33%;"> &nbsp; <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ExamStatisticsList_datetime")%>：<span  id="surplusDate" runat="server" style=" font-size:16px;">00:00</span></td>
    <td style=" width:33%; text-align:center; "><center> <div  style=" width:50px; border:1px #ccc solid; background-color:#f4f4f4;" onclick="Tshow()">
       <label id="currQueCount" runat="server" onclick="Tshow()">
                        0</label>/<label id="sumQueCount" onclick="Tshow()"><%=SumCount %></label></div></center></td>
    <td style=" width:33%; text-align:right; ">
            <a href="javascript:void(0)" style="background:red; color:#fff; padding:5px 15px; " id="submitExam3" resultkey="<%=resultKey %>"  class="white"> <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Exam_qdjj")%> </a> &nbsp; </td>
            
    </tr></table>
</div>
 <div id="mathquill" style=" width:600px; position:absolute; left:0; bottom:0; background-color:White; display:none; z-index:9999;">
         <iframe  src="/Training/TrainingTest/gs/mathdialog.html" width="600" scrolling="no"  frameborder="0" style=" padding:0;"></iframe>
    </div>
    </div>
      </form>
        <script type="text/javascript">
            var i = 0;
            $(".annex").each(function () {
                $(this).attr("id", "aa" + i);
                var fileUrl = $(this).html(); // text();
                window.path2html("aa" + i, fileUrl);
                i++;
            });
            var j = 0;
            $("annex").each(function () {
                $(this).attr("id", "aa" + j);
                var fileUrl = $(this).text();
                window.path2html("aa" + j, fileUrl);
                j++;
            });


            $("img").each(function (i) {
                var imgsrc = $(this).attr("src");
                if (imgsrc.indexOf("image") < 0 && imgsrc.indexOf("/Resources/SharesFiles") < 0 && imgsrc.indexOf("/Resources/ExamImportWord") < 0) {
                    $(this).attr("src", "/Resources/ExamImportWord/" + imgsrc);
                    imgsrc = "/Resources/ExamImportWord/" + imgsrc;
                }
            });

    </script>

</body>
</html>
