/**
 * 自定义弹窗取代系统confirm()弹窗
 * @param msg 显示的内容
 * @param btnContent 确认按钮内容
 * @param call  回调方法
 * @returns
 */	
function Confirm(msg,btnContent,call)
	{   
	    let alertFram = document.createElement("div");
	    $(alertFram).attr('id', 'confirmFram');
	    $(alertFram).attr('class', 'alert alert-block');
	    $(alertFram).width('400px');
	    $(alertFram).height('100px');   
	    $(alertFram).css({
	      "position":"absolute",
	      "left":"40%",
	      "top":"100px",
	      "background":"rgb(249, 249, 244)",
	      "margin-left":"-75px",
	      "text-align":"center",
	      "line-height":"50px",
	      "border-radius":"5px",
	      "border":"1px solid", 
	      "z-index": "1000",
	      });   
	    strHtml = ' <h4 class="alert-heading"></h4>';
	    strHtml += msg;
	    strHtml += "<p> <input type=\"button\"  style=\" width:70px; margin: 10px;\" class=\"btn btn-danger\" value="+btnContent+" onclick=\"ok()\" />";
	    strHtml += " <input type=\"button\" style=\" width:70px; \" class=\"btn btn-danger\" value=\"取消\" onclick=\"cancel()\" />";
	    $(alertFram).html(strHtml);
	    $('body').append(alertFram);
	 
	    	 this.ok = function()
			    {
			        $(alertFram).hide();
			        call && call(); 
			        return true;
			    }
			    this.cancel = function()
			    {
			       $(alertFram).hide();
			        return false;
			    }
	   return false;
	}
/*登录的Ajax*/
function ajaxLogin(formData){
	var ajaxSigninData = formData + "&isAjaxSignin=true";
	var CONTEXTPATH = "";
	var SERVLET_EXTENSION  = ".html";
	$.ajax({
		type:"POST",
		url:CONTEXTPATH + "/jforum" + SERVLET_EXTENSION + "?module=user&action=validateLogin&gid="+gid,
		data: ajaxSigninData,
		dataType:"json",
		global:false,
		success:function(data){
			switch (data.isSucc){
			case 1:
				// window.location.href = location.href;
				window.location.reload();
				break;
			case 2:
				alert(data.succText)
				break;
			case -1:
				  Confirm(data.succText,"我已验证",function(){ajaxLogin(formData)})
				break;

			default:
				break;
			}
		},
		error:function(){
			alert("登录失败");
		}
	});
}
/*登录的Ajax*/
function ajaxLogout(){
	$.ajax({
		type:"POST",
		url: "/",
		data: {
			rqType: "ajax",
			module: "loginAction",
			action: "logOut",
			gid: gid
		},
		dataType:"json",
		global:false,
		success:function(){
			window.location.reload();
		},
		error:function(){
			alert("注销失败");
		}
	});
}
//ajax删除排盘回复
function deletePaiPanRep(paipanReplyId){
	var pprepId={
		paipanRepId:paipanReplyId,
	};
	if(confirm("确定删除该回复吗？")){
		$.ajax({
			type:'post',
			url:constantData['CONTEXTPATH'] + "/jforum" + constantData['SERVLET_EXTENSION'] + "?module=audit&action=deletePaipanReply&gid="+ constantData['GID'],
			data:pprepId,
			dataType:"json",
			global:false,
			success:function(pid){
				if(typeof pid.msg=="undefined"){
					if( $("#paipanReply_"+paipanReplyId).siblings("div").size()==0){
						$("#paipanReply_"+paipanReplyId).parent().parent().parent().parent().parent().remove();
					}else{
						$("#paipanReply_"+paipanReplyId).remove();
					}
					alert("删除成功")
				}else{
					alert("删除失败：\n错误信息："+pid.msg);
					return;
				}
			}
		})
	}
}
//ajax删除对断语、排盘回复的回复
function deleteExprReply(exprReplyId,isPaiPanReply,replyType){
	var exprReply={
		exprReplyId:exprReplyId,
		isPaiPanReply:isPaiPanReply,
	};
	if(confirm("确定删除该回复吗？")){
		$.ajax({
			type:'post',
			url:constantData['CONTEXTPATH'] + "/jforum" + constantData['SERVLET_EXTENSION'] + "?module=audit&action=deleteExprReplyById&gid="+ constantData['GID'],
			data:exprReply,
			dataType:"json",
			global:false,
			success:function(data){
				if(typeof data=="number"){
					//$("."+data).remove();
					//$("#"+exprReplyId+"_"+replyType+"_content").css("background-color","wheat");
					$("#"+exprReplyId+"_"+replyType+"_delete_text").html("已删除");
					$("#"+exprReplyId+"_"+replyType+"_delete").hide();
					alert("删除成功");
				}else{
					alert("删除失败："+data.msg);
				}
			}
		})
	}
}
//ajax删除对Expr的子回复
function deleteSubReply(exprReplyId, subReplyId,isPaiPanReply,replyType){
	var ID={
		exprReplyId:exprReplyId,
		subReplyId:subReplyId,
		isPaiPanReply:isPaiPanReply
	};
	if(confirm("确定删除该回复吗？")){
		$.ajax({
			type:'post',
			url:constantData['CONTEXTPATH'] + "/jforum" + constantData['SERVLET_EXTENSION'] + "?module=audit&action=deleteSubReplyById&gid="+ constantData['GID'],
			data:ID,
			dataType:"json",
			global:false,
			success:function(data){
				if(typeof data=="number"){
					// $("."+data).remove();
					//$("#"+subReplyId+"_"+replyType+"_content").css("background-color","wheat");
					$("#"+subReplyId+"_"+replyType+"_delete_text").html("已删除");
					$("#"+subReplyId+"_"+replyType+"_delete").hide();
					alert("删除成功");
				}else{
					alert("删除失败："+data.msg);
				}
			}
		})
	}
}
