<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib uri="/WEB-INF/taglib/c.tld" prefix="c"%>
<%@ include file="../common/init.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>启明网上阅卷系统</title>
<link rel="stylesheet" type="text/css" href="${ctx}/static/mark/style/bootstrap.css">
<link rel="stylesheet" type="text/css" href="${ctx}/static/mark/style/mark.css"/>
<link rel="stylesheet" type="text/css" href="${ctx}/static/mark/style/overlay/style/overlay.css"/>
<link rel="stylesheet" type="text/css" href="${ctx}/static/mark/js/jqueryalert/jquery.alerts.css"/>
<script type="text/javascript" src="${ctx}/static/mark/js/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="${ctx}/static/mark/js/json2.js"></script>
<script type="text/javascript" src="${ctx}/static/mark/js/interface.js"></script>
<script type="text/javascript" src="${ctx}/static/mark/js/bootstrap.min.js"></script>
<script type="text/javascript" src="${ctx}/static/mark/js/jqueryalert/jquery.alerts.js"></script>
<script type="text/javascript" src="${ctx}/static/plugin/swfobject.js"></script>
<script type="text/javascript" src="${ctx}/static/plugin/swfplugin.js"></script>
</head>
<body>
	<div id="markBody" class="navbar">
		<div class="navbar-inner">
			<div class="container">
				<div class="nav-collapse collapse navbar-responsive-collapse">
					<span  class="nav nav-logo"><img src="${ctx}/static/school_logo/${school_logo}" /></span>
					<span class="nav nav-title">评卷员：<span id="marker"></span>&nbsp;&nbsp;<span id="libraryTypeStr"></span>&nbsp;&nbsp;评卷数：<span id="markCount" style="color: yellow;font-weight:900;font-size: 30px;"></span></span>
					<ul class="nav pull-right">
						<!-- <li>
						  <div class="btn-group" style="margin-top:15px;" >
		                      <input id="secretNo" type="text" class="input-small" placeholder="密号">
		                      <button class="btn" data-toggle="dropdown" onclick="findBySecretNo()">
		                                                                  提 取
		                      </button>
		                  </div>
						</li> -->
						<li class="mr-t mr1"><img src="${ctx}/static/admin/images/logo-mini.png" /></li>
						<li class="mr-t">
							<div class="btn-group">
			                <button class="btn dropdown-toggle" data-toggle="dropdown">问题卷 <span class="caret"></span></button>
				                <ul class="dropdown-menu">
				                  <li>
				                  	<a href="#">
				                  		<label class="radio">
									  	<input type="radio" name="problem" id="problem" value="0">
									  	试卷模糊
										</label>
									</a>
								  </li>
								  <li>
				                  	<a href="#">
				                  		<label class="radio">
									  	<input type="radio" name="problem" id="problem" value="1">
									  	答错位置
										</label>
									</a>
								  </li>
								  <li>
				                  	<a href="#">
				                  		<label class="radio">
									  	<input type="radio" name="problem" id="problem" value="2">
									  	无法判别
										</label>
									</a>
								  </li>
				                </ul>
				             </div>&nbsp;&nbsp;
						</li>
	                    <li class="divider-vertical"></li>
						<li><a href="#" onclick="findHistoryList()">回评</a></li>
	                    <li class="divider-vertical"></li>
	                    <li><a href="#" onclick="saveExample()">样卷</a></li>
	                    <li class="divider-vertical"></li>
	                    <li><a href="#" id="mymodal-button">标答</a></li>
	                    <li class="divider-vertical"></li>
	                    <li><a href="#" id="allpaper-button">全卷</a></li>
						<li><a href="${ctx }/mark/logout">退出</a></li>
					</ul>
				</div>
			</div>
			<div id="historydiv" class="span12 mr-t" style="height:50px;overflow-x:auto;overflow-y:hidden;display:none">
		      <div class=" mark-time" style="width:9999px;">
		       <ul id="timelist">
		       </ul>
		      </div>
		    </div>
		</div>
	</div>
	<div class="row-fluid mr-t">
		<div class="span9" style="z-index:-1;height:600px;">
			<div id="viewer" class="viewer mr-t"></div>
		</div>
		<div class="span3 pad-r">
			<div id="layer1" class="mark">
	        <div id="layer1_handle" class="mark-title">可移动</div>
	        <div id="layer1_content">
	          <div class="mark-content">
	              <p class="title"></p>
	                <ul id="markBlock">
	                </ul>
	                <p class="bottom">
	                	<button class="btn btn-small btn-primary mr1" type="button" onclick="saveMark()">提交</button>
	                	<button class="btn btn-small btn-primary mr1" type="button">全卷</button>
	                </p>
	             </div>
	        </div>
	     	</div>
		</div>
	     <div id="historyList" class="span3" style="display: none;">
			<table class="table table-bordered table-striped table-hover">
				<thead>
					<tr>
						<!-- <th width="10%">领取时间</th> -->
						<th width="30%">时间</th>
						<th width="20%">密号</th>
						<th width="30%">分值列表</th>
						<th width="20%">总分</th>
					</tr>
				</thead>
				<tbody id="history-tbody">
				</tbody>
			</table>
			<div class="pagination">
	              <ul>
	                <li><a href="#">上一页</a></li>
	                <!-- <li class="active"><a href="#">1</a></li>
	                <li><a href="#">2</a></li>
	                <li><a href="#">3</a></li>
	                <li><a href="#">4</a></li>
	                <li><a href="#">5</a></li> -->
	                <li><a href="#">下一页</a></li>
	             </ul>
	       </div>        
	    </div>
		<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display:none">
	      <div class="modal-header">
	        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
	        <h4 id="myModalLabel">答案</h4>
	      </div>
	      <div class="modal-body">
	        <p class="text-c"><img id="standardAnswer" src="" /></p>
	      </div>
	      <div class="modal-footer">
	        <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
	      </div>
	    </div>
	    <div id="allPaper" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="allPaperList" aria-hidden="true" style="display:none">
	      <div class="modal-header">
	        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
	        <h4 id="allPaperList">全卷</h4>
	      </div>
	      <div class="modal-body">
	        <p class="text-c"><img id="allPaper1" src="" /></p>
	      </div>
	      <div class="modal-footer">
	        <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
	      </div>
	    </div>
	    <div class="overlay"></div>
	  </div>
	  <div class="mark-footer mr-t"><p>试卷总量：<i id="blockToMarkCount"></i></p>　<p>已评数：<i id="blockMarkedCount"></i></p>　<p>未评数：<i id="blockMustMarkCount"></i></p>　<p>评卷进度：<i id="blockMarkedPercent"></i></p></div>
<script type="text/javascript">
var task;
var flag = true;
var key_code="";
var currentConfig = '';
$(document).ready(function(){
	initImageViewPluginDefault("${ctx}/static/plugin/", "viewer");
	$('#mymodal-button').click(function(){
		$('#myModal').modal('show');
	});
	$('#allpaper-button').click(function(){
		$('#allPaper').modal('show');
	});
});

//构造string endWith()方法
String.prototype.endWith=function(s){
  if(s==null||s==""||this.length==0||s.length>this.length)
     return false;
  if(this.substring(this.length-s.length)==s)
     return true;
  else
     return false;
  return true;
 }
 String.prototype.startWith=function(s){
  if(s==null||s==""||this.length==0||s.length>this.length)
   return false;
  if(this.substr(0,s.length)==s)
     return true;
  else
     return false;
  return true;
 }
 
 function creationComplete(){
	 $('#myModal').modal({
			show : false
		}).css({
		    width:'800px',
		    'margin-left': function () {
		       return -($(this).width() / 2);
		   }
		});
		$('#allPaper').modal({
			show : false
		}).css({
		    width:'800px',
		    'margin-left': function () {
		       return -($(this).width() / 2);
		   }
		});
	 getTask();
 }
 
 function loadComplete(){
	 $(".overlay").hide();
 }
 
 function refreshPictureConfig(config, urls){
	if(urls!=undefined && urls.length>0 && config!=undefined && config!=''){
		var imgServer="${imageServer}";
		for(var i=0;i<urls.length;i++){
			eval('config=config.replace(/\\{'+i+'\\}/, "'+(imgServer+urls[i])+'")');
		} 
		currentConfig=config;
		getSwfObject('ImageViewer').setJson(currentConfig);
	}
 }

 function getTask(){
	 //清空上次评卷数据
	 $("#standardAnswer").attr("href","");
	 $("#allPaper1").attr("href","");
	 $("#myModalLabel").html("");
	 $("#allPaperList").html("");
	 $(".overlay").show();
	 $.post('${ctx}/mark/gettask.json', "", function(obj){
		 if(obj.message!=null){
			 jAlert(obj.message, '消息');
			 if(obj.message == '无评卷任务'){
				 $("#marker").html(obj.marker);
				 $("#markCount").html(obj.markCount);
				 $("#blockToMarkCount").html(obj.blockToMarkCount+"份");
				 $("#blockMarkedCount").html(obj.blockMarkedCount+"份");
				 $("#blockMustMarkCount").html(obj.blockToMarkCount-obj.blockMarkedCount+"份");
				 $("#blockMarkedPercent").html(obj.markedPercent+"%");
			 }
			 return false;
		 }
		 	task = obj;
		 	//加载图片
			refreshPictureConfig(task.pictureConfig, task.pictureUrls);	

			$('#layer1').Draggable({
					zIndex : 20,
					ghosting : false,
					opacity : 0.7,
					handle : '#layer1_handle'
				});
				$("#layer1").show();

			$("#marker").html(obj.marker);
			if(obj.libraryType==0){
				$("#libraryTypeStr").html("样卷");
			}else if(obj.libraryType==1){
				$("#libraryTypeStr").html("试评");
			}else{
				$("#libraryTypeStr").html("正评");
			}
			$("#markCount").html(obj.markCount);
			$(".title").html("大题："+obj.blockTitle);
			$("#blockToMarkCount").html(obj.blockToMarkCount+"份");
			$("#blockMarkedCount").html(obj.blockMarkedCount+"份");
			$("#blockMustMarkCount").html(obj.blockToMarkCount-obj.blockMarkedCount+"份");
			$("#blockMarkedPercent").html(obj.markedPercent+"%");
			var s = "";
			var stepList = obj.markStepList;
			for(var i=0;i<stepList.length;i++){
				var levelLength = 0;
				if(stepList[i].markLevelList!=null){
					levelLength = stepList[i].markLevelList.length;
				}
				
				if(levelLength==0){
					s += "<li><em>"+parseInt(i+1)+".</em>";
					var scoreArray = stepList[i].scoreArray;
					for(var k=0;k<scoreArray.length;k++){
						s += "<a href='#' onclick='mark(this,"+scoreArray[k]+")'>"+scoreArray[k]+"</a>";
					}
		     		s +="</li>";
				}else{
					s += "<li><em>"+parseInt(i+1)+".</em><span class='rank'>";
	     			var level = stepList[i].markLevelList;
	     			for(var k=0;k<level.length;k++){
	     				s+= "<a id='leveScorelList"+level[k].min+"-"+level[k].max+"' href='#' onclick='level(this,"+parseInt(k+1)+")'>"+level[k].name+"</a>";
	     				s+= "<i id='levelScore"+parseInt(k+1)+"' class='fine' style='display: none;'>";
	     				var levelList = level[k].scoreList;
     					if(levelList!=null){
     						for(var j=0;j<levelList.length;j++){
    	     					s+= "<a href='#' onclick='levelMark(this,"+levelList[j]+")'>"+levelList[j]+"</a>";
    	     				}
     					}
	     				
	     				s+="</i>";
	     			}
	     			s+="<span class='temp'></span></span></li>";
				}
			}
			s+="<li  class='mr-l'>键盘分：<input id='keyValue' class='input-mini mini' type='text'/>&nbsp;&nbsp;合计：<i class='text-error'><strong id='count'>0分</strong></i></li>";
			
			$("#markBlock").html(s);
			
			$(".rank").each(function(){
				var rank = $(this);
				rank.find('i').appendTo(rank.find('.temp'));
			});
			//初始化标答
			var answerUrls = obj.answerUrls;
			var answerList = "" ;
			if(answerUrls.length>0){
				$("#standardAnswer").attr("src","${imageServer}"+answerUrls[0]);
			}else{
				$("#standardAnswer").attr("src","${ctx}/static"+'/images/no-answer.jpg');
			}
			for(var i=0;i<answerUrls.length;i++){
				answerList +="<a href='javascript:void(0)' onclick='changeAnswer("+answerUrls[i]+")'>"+parseInt(i+1)+"</a>";
			}
			$("#myModalLabel").html(answerList);
			//初始化全卷
			//if(obj.canViewTotal){
				var allPapers = obj.pictureUrls;
				var paperList = "" ; 
				if(allPapers.length>0){
					$("#allPaper1").attr("src","${imageServer}"+allPapers[0]);
				}else{
					$("#standardAnswer").attr("src","${ctx}/static"+'/images/no-allpaper.jpg');
				}
				for(var i=0;i<allPapers.length;i++){
					paperList +="<a href='javascript:void(0)' onclick='changePaper("+allPapers[i]+")'>"+parseInt(i+1)+"</a>";
				}
				$("#allPaperList").html(paperList);
			//}
			 //$(".overlay").hide();
		});
	 
 }
 
var count=parseFloat("0") ;
function mark(obj,score){
	$(obj).parent().find("a").each(function(){
		if($(this).hasClass("curr")){
			$(this).removeClass("curr");
		    count-=parseFloat($(this).html());
		}
		if(parseFloat($(this).html())==score){
			$(obj).addClass("curr");
			count+=parseFloat($(obj).html());
		}
	  });
	
	$("#count").html(count+"分");
}
function levelMark(obj,score){
	$(obj).parent().parent().find("a").each(function(){
		if($(this).hasClass("curr")){
			$(this).removeClass("curr");
		    count-=parseFloat($(this).html());
		}
		if(parseFloat($(this).html())==score){
			$(obj).addClass("curr");
			count+=parseFloat($(obj).html());
		}
	  });
	
	$("#count").html(count+"分");
}
function level(obj,index){
	$(obj).siblings("a").each(function(){
		if($(this).hasClass("curr")){
			$(this).removeClass("curr");
		}
	  });
	$(obj).addClass("curr");
	$("[id^=levelScore]").hide();
	$("#levelScore"+index).show(); 
	
}

	$(document).keyup(function(e){
		 if(e.which==48||e.which==96){
			key_code += "0";
			$("#keyValue").attr("value",key_code);
		}else if(e.which==49||e.which==97){
			key_code += "1";
			$("#keyValue").attr("value",key_code);
		}else if(e.which==50||e.which==98){
			key_code += "2";
			$("#keyValue").attr("value",key_code);
		}else if(e.which==51||e.which==99){
			key_code += "3";
			$("#keyValue").attr("value",key_code);
		}else if(e.which==52||e.which==100){
			key_code += "4";
			$("#keyValue").attr("value",key_code);
		}else if(e.which==53||e.which==101){
			key_code += "5";
			$("#keyValue").attr("value",key_code);
		}else if(e.which==54||e.which==102){
			key_code += "6";
			$("#keyValue").attr("value",key_code);
		}else if(e.which==55||e.which==103){
			key_code += "7";
			$("#keyValue").attr("value",key_code);
		}else if(e.which==56||e.which==104){
			key_code += "8";
			$("#keyValue").attr("value",key_code);
		}else if(e.which==57||e.which==105){
			key_code += "9";
			$("#keyValue").attr("value",key_code);
		}else if(e.which==110||e.which==190){
			key_code += ".";
			$("#keyValue").attr("value",key_code);
		}else if(e.which==13){
			
			if(flag){
				if(key_code=="."){
					key_code="0.5";
				}else if(key_code.toString().endWith(".")){
					key_code+="5";
				}else{
					key_code=key_code;
				}
				var score = parseFloat(key_code);
				var indexNo =-1;
				var block = $("#markBlock").find("li");
				for(var i=0;i<block.length;i++){
					var a = $(block[i]).find("a");
					for(var j=0;j<a.length;j++){
						if($(a[j]).hasClass("curr")){
							indexNo = i;
						}
					}
				} 
				if((indexNo+2)==block.length){
					indexNo=-1;
					flag = false;
					saveMark();
					key_code="";
					return false;
				}else{
					$(block[indexNo+1]).find("a").each(function(){
						var s1= $(this);
						if(s1.html()==score ){
							mark(s1,score);
							if(s1.parent().parent().hasClass("temp")){
								$("[id^=levelScore]").hide();
								s1.parent().show();
								
								s1.parent().parent().parent().find("[id^=leveScorelList]").each(function(){
									var s2 = $(this);
									var s = s2.attr("id");
									var str = s.substr(14,s.length);
									var strs= new Array(); 
									strs=str.split("-"); 
									if(parseFloat(score)>=parseFloat(strs[0])&& parseFloat(score)<=parseFloat(strs[1])){
										s2.addClass("curr");
									}
								});
							}
						}
					});
				}
				
				
				
				key_code="";
				$("#keyValue").attr("value","");
			}
			
			
		}else{
			key_code="";
			$("#keyValue").attr("value","");
		}
	});

function saveMark(){
	$("#viewer").removeClass("span6");
	$("#viewer").addClass("span9");
	var reason = $('input:radio[name=problem]:checked').val();
	if(reason!=null){
		jConfirm("确认将此份试卷设置为问题卷？", '确认', function(r) {
			if(r){
				var data ={
						libraryId:task.libraryId,
						libraryType:task.libraryType,
						blockId:task.blockId,
						markId:task.markId,
						secretNo:task.secretNo,
						self:task.self,
						previous:task.previous,
						back:task.back,
						problem:true,
						spent:task.spent,
						userType:task.userType,
						stage:task.stage,
						reason:reason
					}
					
					index = 0;
					var url='${ctx}/mark/savetask.json';
				    $.ajax( {
				    url : url,
				    type : "POST", 
				    data: data,
				    success : function(val) {
				    	//清空上次数据
				    	count=parseFloat("0") ;
						$("#libraryTypeStr").html("");
				    	//$("#markCount").html("");
				    	$("#markBlock").html("");
				    	$(".title").html("");
				    	$('input:radio[name=problem]').attr('checked',false);
				    	$("#history-tbody").html("");
				    	$("#historyList").hide();
				    	//取下一个任务
				    	if(task.markCount==task.mustMarkCount){
				    		jConfirm('您已评完分配的任务，需要继续评卷吗？', '提示', function(r) {
				    			getTask();
						    	flag = true;
							});
				    	}else{
				    		getTask();
					    	flag = true;
				    	}
				    },
					error:function(e){
				    	jAlert('通信发生错误，稍等片刻再重新提交！', '警告');
				    }
				    })
				}
		});
		
	}else{
		var keyValue = $("#keyValue").val();
		if(keyValue.length>0){
			var score = parseFloat(key_code);
			var indexNo =-1;
			var block = $("#markBlock").find("li");
			for(var i=0;i<block.length;i++){
				var a = $(block[i]).find("a");
				for(var j=0;j<a.length;j++){
					if($(a[j]).hasClass("curr")){
						indexNo = i;
					}
				}
			} 
			if((indexNo+2)==block.length){
				indexNo=-1;
				flag = false;
				saveMark();
				key_code="";
				return false;
			}else{
				$(block[indexNo+1]).find("a").each(function(){
					var s1= $(this);
					if(s1.html()==score ){
						mark(s1,score);
						if(s1.parent().parent().hasClass("temp")){
							$("[id^=levelScore]").hide();
							s1.parent().show();
							
							s1.parent().parent().parent().find("[id^=leveScorelList]").each(function(){
								var s2 = $(this);
								var s = s2.attr("id");
								var str = s.substr(14,s.length);
								var strs= new Array(); 
								strs=str.split("-"); 
								if(parseFloat(score)>=parseFloat(strs[0])&& parseFloat(score)<=parseFloat(strs[1])){
									s2.addClass("curr");
								}
							});
						}
					}
				});
			}
		}
		
		var index =0;
		var block = $("#markBlock").find("li");
		for(var i=0;i<block.length;i++){
			
			if($(block[i]).find(".fine").length>0){
				$(block[i]).find(".fine").each(function(){
					var is = $(this);
					is.find("a").each(function (){
						var as = $(this);
						if(as.hasClass("curr")){
							index++;
						}
					});
				});
			}else{
				if($(block[i]).find(".curr").length>0){
					index++;
				}
			}
		} 
		
		if((index+1)< block.length){
			jAlert('还有步骤没有给分', '警告');
			return false;
		}else{
			//jConfirm("总分为： <span style='color:#B94A48;size:14px;font-weight:bold;'>"+count+"</span>&nbsp;&nbsp;分,确认提交？", '确认', function(r) {
			//	if(r){}
			var block = $("#markBlock").find("li");
			var list = "";
			for(var i=0;i<block.length;i++){
				
				if($(block[i]).find(".fine").length>0){
					$(block[i]).find(".fine").each(function(){
						var is = $(this);
						is.find("a").each(function (){
							var as = $(this);
							if(as.hasClass("curr")){
								list +=as.html()+","
							}
						});
					});
				}else{
					$(block[i]).find("a").each(function(){
						var a = $(this);
						if(a.hasClass("curr")){
							list += a.html()+",";
						}
					});
				}
			}
			if(list.length>0){
				list = list.substring(0,list.length-1);
			}
			  
			task.totalScore = count;
			task.scoreList = list;
			var data ={
				libraryId:task.libraryId,
				libraryType:task.libraryType,
				blockId:task.blockId,
				markId:task.markId,
				secretNo:task.secretNo,
				self:task.self,
				previous:task.previous,
				back:task.back,
				problem:task.problem,
				totalScore: count,
				scoreList:list,
				spent:task.spent,
				userType:task.userType,
				stage:task.stage,
				markerCount:task.markerCount,
				case:task.case,
				number:task.number
			}
			index = 0;
			var url='${ctx}/mark/savetask.json';
		    $.ajax( {
		    url : url,
		    type : "POST", 
		    data: data,
		    success : function(val) {
		    	//清空上次数据
		    	count=parseFloat("0") ;
				$("#libraryTypeStr").html("");
		    	//$("#markCount").html("");
		    	$("#markBlock").html("");
		    	$(".title").html("");
		    	$('input:radio[name=problem]').attr('checked',false);
		    	$("#history-tbody").html("");
		    	$("#historyList").hide();
		    	//取下一个任务
		    	getTask();
		    	flag = true;
		    },
			error:function(e){
		    	jAlert('通信发生错误，稍等片刻再重新提交！', '警告');
		    }
			});
		}
	}
	
}

function showNumber(obj,historyTask){
	count=parseFloat("0") ;
	var tbody = $(obj).parent();
	$(tbody).find("tr").each(function(){
		$(this).removeClass("active");
	});
	
	$(obj).addClass("active");
	task = historyTask;
	//加载图片
	refreshPictureConfig(task.pictureConfig, task.pictureUrls);	
	//更新给分板
	var scoreList = historyTask.scoreList;
	var scores = scoreList.split(",");
	var lis = $("#markBlock").find("li");
	for(var i=0;i<lis.length;i++){
		var li = $(lis[i]);
		if(li.find("span[class='temp']").length>0){
			li.find(".fine").each(function(){
				var is = $(this);
				is.find("a").each(function(){
					var a = $(this);
					a.removeClass("curr");
					if(parseFloat(a.html())==parseFloat(scores[i])){
						a.addClass("curr");
						a.parent().show();
						
						a.parent().parent().parent().find("[id^=leveScorelList]").each(function(){
							var s2 = $(this);
							var s = s2.attr("id");
							var str = s.substr(14,s.length);
							var strs= new Array(); 
							strs=str.split("-"); 
							if(parseFloat(a.html())>=parseFloat(strs[0])&& parseFloat(a.html())<=parseFloat(strs[1])){
								s2.siblings("a").removeClass("curr");
								s2.addClass("curr");
							}
						});
						
						count += parseFloat(scores[i]);
					}
				});
			});
		}else{
			li.find("a").removeClass("curr");
			li.find("a").each(function(){
				if(parseFloat($(this).html())==parseFloat(scores[i])){
					mark($(this),scores[i]);
				}
			});
		}
	}
}

var pageNumber=1;
function findHistory(t){
	$("#viewer").removeClass("span9");
	$("#viewer").addClass("span6");
	$("#historyList").toggle();
	$("#history-tbody").html("");
	var data ={
		pageNumber:pageNumber,
		pageSize:10,
		time:t
	}
	var url='${ctx}/mark/gethistory.json';
    $.ajax( {
    url : url,
    type : "POST", 
    data: data,
    success : function(val) {
    	var str="";
    	var list = val;
    	for(var i=0;i<list.length;i++){
    		var resDate = new Date(list[i].markTime);
    		var resDateStr = resDate.getFullYear()+"-"+parseInt(resDate.getMonth()+1)+"-"+resDate.getDate()+" "+resDate.getHours()+":"+resDate.getMinutes()+":"+resDate.getSeconds();
    		var temp = JSON.stringify(list[i]);
    		str+="<tr onclick='showNumber(this,"+temp+")'>";
    		str+="<td>"+resDateStr+"</td>";
    		str+="<td>"+list[i].secretNo+"</td>";
    		str+="<td>"+list[i].scoreList+"</td>";
    		str+="<td>"+list[i].totalScore+"</td>";
    		str+="</tr>";
    	}
    	$("#history-tbody").html(str);
    },
	error:function(e){
    	jAlert('通信发生错误，稍等片刻再重新提交！', '警告');
    }
    })
}

 function findHistoryList(){
	$("#historydiv").toggle();
	var url='${ctx}/mark/historyList.json';
    $.ajax( {
    url : url,
    type : "POST", 
    success : function(list) {
    	var str='<li><i class="time-bg">时间表</i></li>';
    	for(var i=0;i<list.length;i++){
    		str+='<li onclick=findHistory("'+list[i].time+'")><a hidden="#">'+list[i].end+'</a></li>';
    	}
    	$("#timelist").html(str);
    },
	error:function(e){
    	jAlert('通信发生错误，稍等片刻再重新提交！', '警告');
    }
    })
}

function findBySecretNo(){
	var secretNo=$("#secretNo").val();
	if(secretNo==null||secretNo==''){
		alert("请填题块密号!");
	}else{
		$.post('${ctx}/mark/getSecretNo.json',{secretNo:secretNo},function(obj){
	    	count=parseFloat("0");
	    	//加载图片
	    	refreshPictureConfig(obj.pictureConfig, obj.pictureUrls);	
	    	//更新给分板
	    	var scoreList = obj.scoreList;
	    	var scores = scoreList.split(",");
	    	var lis = $("#markBlock").find("li");
	    	for(var i=0;i<lis.length;i++){
	    		var li = $(lis[i]);
	    		if(li.find("span[class='temp']").length>0){
	    			li.find(".fine").each(function(){
	    				var is = $(this);
	    				is.find("a").each(function(){
	    					var a = $(this);
	    					a.removeClass("curr");
	    					if(parseFloat(a.html())==parseFloat(scores[i])){
	    						a.addClass("curr");
	    						a.parent().show();
	    						
	    						a.parent().parent().parent().find("[id^=leveScorelList]").each(function(){
	    							var s2 = $(this);
	    							var s = s2.attr("id");
	    							var str = s.substr(14,s.length);
	    							var strs= new Array(); 
	    							strs=str.split("-"); 
	    							if(parseFloat(a.html())>=parseFloat(strs[0])&& parseFloat(a.html())<=parseFloat(strs[1])){
	    								s2.siblings("a").removeClass("curr");
	    								s2.addClass("curr");
	    							} 
	    						});
	    					}
	    				});
	    			});
	    		}else{
	    			li.find("a").removeClass("curr");
	    			li.find("a").each(function(){
	    				if(parseFloat($(this).html())==parseFloat(scores[i])){
	    					mark($(this),scores[i]);
	    				}
	    			});
	    		}
	    	}
	    	$('.mr-l').css('display','none');
	    	$('.bottom').css('display','none');
		});
	}
}

function changePageNumber(flag){
	if(pageNumber>1){
		if(flag==-1){
			pageNumber--;
		}else{
			pageNumber++;
		}
	}
}

function saveExample(){
	//将task设置成样卷状态
	jConfirm("确认将当前试卷设置成样卷？", '确认', function(r) {
		if(r){
			task.case=true;
			}
	})
	
}

function changeAnswer(url){
	$("#standardAnswer").attr("src","${imageServer}"+url);
}

function changePaper(url){
	$("#allpaper1").attr("src","${imageServer}"+url);
}
</script>
</body>
</html>
