<!--#include file="../../p_inc/Include_func.asp"-->
<!--#include file="../inc/public.asp"-->
<!--#include file="../inc/openconn.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新闻分类页面生成</title>
</head>
<body>
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-color: #E4EDF9;
}
body,td,th,p{
	font-size: 12px;
}
-->
</style>
<script>
function scrollWindow(){this.scroll(0, 6500000);sett=setTimeout('scrollWindow()',1);}
scrollWindow();
function scrollWindow2(){clearTimeout(sett)}
document.ondblclick=scrollWindow2;
</script>

<%
response.Buffer=true
Server.ScriptTimeOut=9999999

IF G_moshi="" Then
	response.Write "<b>动态模式无需生成！</b>"
	IF request("qt_a1")="a" Then
	Else
		response.Write "<meta http-equiv=""Refresh"" content=""1;URL=../qingtiandy_News/index.asp"">"
	End IF
	response.End()	
End IF


'response.Write "正在统计，请稍等........."
'response.Flush()

IF G_JING_TAI_Print_Time="" Then G_JING_TAI_Print_Time=500

typeid3_str=""
set rs_y=server.createobject("adodb.recordset")
if request("all")="all" then
	rs_y.open ("select typeid,typename from qingtiandy_Ntype1 where typehide=1 order by typeno asc"),conn,1,1
	typeid3_str=""
	Do While Not rs_y.Eof
		Set rs_z=conn.execute("select Count(id) from qingtiandy_News where n_type1="&rs_y(0))
		typeid3_str=typeid3_str&rs_y(0)&","&rs_z(0)&"|||"
		rs_y.movenext
	Loop
	
	Set rs_z=conn.execute("select Count(id) from qingtiandy_News ")
	typeid3_str=typeid3_str&"0,"&rs_z(0)&"|||"
		
	typeid3_str=PrintArray(typeid3_str,"|||")
ElseIF request("all")="day" then
	today_sql="select n_type1 from qingtiandy_News where year(n_date)="&year(now) &" and month(n_date)="&month(now)&" and day(n_date)="&day(now)&" group by n_type1"
	Set rs_today=server.CreateObject(G_RS)
	rs_today.open today_sql,conn,1,1
	typeid1_str=""
	Do While Not rs_today.Eof
		typeid1_str=typeid1_str&rs_today(0)&","
		rs_today.Movenext
	Loop
	IF typeid1_str="" Then
		Response.Write "<b>今日无更新类别！</b>"
		Response.End()
	End IF
	typeid1_str=PrintArray(typeid1_str,",")
	rs_y.open ("select typeid,typename from qingtiandy_Ntype1 where typehide=1 And typeid in("&typeid1_str&") order by typeno asc"),conn,1,1
	typeid3_str=""
	Do While Not rs_y.Eof
		Set rs_z=conn.execute("select Count(id) from qingtiandy_News where n_type1="&rs_y(0))
		typeid3_str=typeid3_str&rs_y(0)&","&rs_z(0)&"|||"
		rs_y.movenext
	Loop
	typeid3_str=PrintArray(typeid3_str,"|||")
	IF request("tag")<>"yes" Then
		response.Write "<a href='?tag=yes&all=day'><b>点此继续生成</b></a> <a href='javascript:void(0)'  onClick=""{if(confirm('该模式一个分类只生成最前面的3页,后面的不再生成,是否生成?')){;this.href='?tag=yes&all=day&xpage=1';return true;}return false;}""><b>高速生成</b></a>"
		Response.End()
	End IF			
ElseIF request("q_id")<>"" Then
	q_id=request("q_id")
	Set rs_z=conn.execute("select Count(id) from qingtiandy_News where n_type1="&q_id)
	typeid3_str=q_id&","&rs_z(0)	
ElseIF request("all")="my" then	
	IF Session("makelisthtml_typeid")="" Then
		response.Write "请先选择新闻类别！"	
		response.End()		
	Else
		typeid3_str=Session("makelisthtml_typeid")
	End IF
Else
	response.Write "请先选择新闻类别！"	
	response.End()
end if

'response.Write "OK!"

'************** 生成HTML页 开始 ***************

%>

<p id="qingtian_id"></p>
<p id="qingtian_id2"></p>
<p></p>
<script>
var sett;





var typeid3
typeid3="<%=typeid3_str%>";
typeid3_arr=typeid3.split("|||")




var xmlHttp
function qingtiandy_cxhr()
{
	try{
		xmlHttp=new XMLHttpRequest();
		}
	catch(e){
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}	
}

function qingtiandy_$(id){
	return document.getElementById(id);	
}


	
var iii=0

function Printout(ii,ik){
	if(ii<typeid3_arr.length){
		var r_i,r_i
		r_i=typeid3_arr[ii]
		r_i_arr=r_i.split(",")
		
		iii=ii	
		
		qingtiandy_cxhr();	
		var url="Ajax_makelistNews.asp";
		var t_post="typeid2_c="+r_i_arr[0]+"&l_k="+ik+"&totalpage=1&xpage=<%=Request("xpage")%>";
		xmlHttp.open("post",url,true);
		xmlHttp.onreadystatechange=qingtiandy_ok
		xmlHttp.setRequestHeader("Content-Length",t_post.length);
		xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
		xmlHttp.send(t_post);
	}
	else{
		document.getElementById('qingtian_id2').innerHTML="<b>生成完毕！</b>"	
	}
}

//typeid2_c&"|||"&l_k&"|||"&totalpage

function qingtiandy_ok(){
	if(xmlHttp.readyState==4)
	{	
		if (xmlHttp.status==200)
		{
			var temp_x=xmlHttp.responseText;
			if (temp_x!=""){
				var temp_x_arr
				temp_x_arr=temp_x.split("|||")
				document.getElementById('qingtian_id').innerHTML="<br><b>(<span onclick=Printout("+iii+","+(parseInt(temp_x_arr[1]))+") style='cursor:pointer; text-decoration:underline'>刷新</span>)已生成/要生成的新闻分类页面条数: <font color=#FF0000>"+temp_x_arr[1]+"</font>/<font color=#FF0000><b>"+temp_x_arr[2]+"</b></font>/<font color=#FF0000>"+(iii+1)+"</font>/<font color=#FF0000><b>"+typeid3_arr.length+"</b></font>  "	
				if(parseInt(temp_x_arr[1])<parseInt(temp_x_arr[2]))
					sett=window.setTimeout("Printout("+iii+","+(parseInt(temp_x_arr[1])+1)+")",<%=G_JING_TAI_Print_Time%>);
				else
					sett=window.setTimeout("Printout("+(iii+1)+",1)",<%=G_JING_TAI_Print_Time%>);			
			}
		}
	}	
}
Printout(0,1)
</script>
