<!--#include file="../conn.asp"-->
<!--#include file="admin_check.asp"-->
<!--#include file="../INC/Function.asp"-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>管理页面</title>
<link id="maincss" rel="stylesheet" href="images/css/admin_style_<%= AdminSkin %>.css" type="text/css" media="all" />
</head>
<body leftmargin="0" bottommargin="0" rightmargin="0" topmargin="5" marginheight="0" marginwidth="0" bgcolor="#DDEEFF">
<%
Call chkFlag(2)

Dim AskD
Set AskD = Server.CreateObject("KwAsk.FunAsk")
  opendb
If Trim(Request.Form("act"))<>"" then
   Call Loading("正在生成，请等待……")
   Response.Flush()
   Call CrClass(0)
   Call AskD.BuildFile(Server.MapPath("../Js/class.js"),level)
   Response.Write("<script>loading.style.display='none';</script>")
   Call SendMsg("生成分类JS成功！")
Else
   Call Main()
End If  
closedb

Set AskD = Nothing

Sub Main()
%>
<table class="tableBorder" cellspacing="1" cellpadding="2" width="96%" align="center" border="0">
<tr>
		<th height="25" align="left">生成分类前台调用JS</th>
  </tr>
  <form action="" method="post"><input name="act" type="hidden" value="11" />
  <tr>
    <td class="TableRow2">生成该JS的目的是为了在前台提问页面选择提问分类时无需读取数据库，从而减少服务器资源浪费，提高系统运行速度！</td>
  </tr>
  <tr>
    <td class=tablerow1><font color="red">注意：每次修改添加或删除分类后即需生成，其它时间无需使用。</font></td>
  </tr>
  <tr>
    <td align="center" class=tablerow1><input type="submit" name="button5" id="button5" value="确认生成"></td></tr>
  </form>
</table>
<%
End Sub

Dim level
Sub CrClass(num)
dim rs,vlevel,tlevel
Set rs=conn.execute("select * from "&predb&"Class where esNum="&num&" order by esPai ASC")
 If not(rs.eof and rs.bof) then 
     if num=0 then
	    vlevel="//vlevel(n) 赋值 n 为所属的ClassID,亦即自己的esNum"&vbcrlf
	    tlevel="//tlevel(n) 文本 n 为所属的ClassID,亦即自己的esNum"&vbcrlf    
	    vlevel=vlevel&"vlevel="""
	    tlevel=tlevel&"tlevel="""
	 else
	    vlevel="vlevel"&num&"="""
	    tlevel="tlevel"&num&"="""
	 end if

    do while not rs.eof
        vlevel=vlevel&rs("ClassId")&"*"
	    tlevel=tlevel&rs("ClassName")&"*"
		Call CrClass(rs("ClassId"))
    rs.movenext
    loop
		 vlevel=left(vlevel,len(vlevel)-1)
		 tlevel=left(tlevel,len(tlevel)-1)
		 vlevel=vlevel&""""&vbcrlf
		 tlevel=tlevel&""""&vbcrlf
 End If
  rs.close
  set rs=nothing
level=level&vlevel&tlevel
End Sub

Sub Loading(str)
Response.Write ("<table id=""loading"" class=""tableBorder"" cellspacing=""1"" cellpadding=""2"" width=""96%"" align=""center"" border=""0"">" & vbCrLf)
Response.Write ("<tr>" & vbCrLf)
Response.Write ("<th height=""25"" align=""left"">" & str & "</th>" & vbCrLf)
Response.Write ("</tr>" & vbCrLf)
Response.Write ("<tr>" & vbCrLf)
Response.Write ("<td align=""center"" class=""TableRow2""><img src=""Images/loading.gif"" width=""300"" height=""6""></td>" & vbCrLf)
Response.Write ("</tr>" & vbCrLf)
Response.Write ("</table>" & vbCrLf)
End Sub
%>
<br>
</body>
</html>