<!--#include file="../inc/config.asp"-->
<!--#include file="../inc/conn.asp"-->
<!-- #include file="inc/Session.asp" -->
<!-- #include file="inc/checkrole.asp" -->
<!-- #include file="inc/function.asp" -->
<%
dim rs,genJs,CatalogCache,funjs
genJs="var Catalog_arr=["
set rs=server.CreateObject("adodb.recordset")
rs.open "select id,title,parentid from catalogs where parentID="&PlugIn_InfoId&" order by id asc",conn,3,1
if not rs.eof and not rs.bof then
	CatalogCache=rs.GetRows()
end if
rs.close
set rs=nothing
if isarray(CatalogCache) then
	for i=0 to ubound(CatalogCache,2)
		'genJs=genJs&"["""&CatalogCache(0,i)&""","""&CatalogCache(1,i)&""","""&CatalogCache(2,i)&"""]"
		'if(i<ubound(CatalogCache,2)) then
			'genJs=genJs&","
		'end if
		set rs=server.CreateObject("adodb.recordset")
		rs.open "select id,title,parentid from catalogs where parentID="&CatalogCache(0,i)&" order by id asc",conn,3,1
		while not rs.eof
			genJs=genJs&"["""&rs(0)&""","""&rs(1)&""","""&rs(2)&"""]"			
			if not rs.eof then
				genJs=genJs&","
			end if
			rs.movenext
		wend
		rs.close
		set rs=nothing		
	next
	genJs=left(genJs,len(genJs)-1)
end if
genJs=genJs&"];"&Chr(10)
funjs=ReadFromTextFile(server.MapPath("js/catalog_func.js"))
genJs=genJs&funjs
call SaveTextFile(server.MapPath("/js/catalogs.js"),genJs)
call connclose()
'response.Write("<script>alert('成功生成JS文件，保存至：/js/catalogs.js');history.back();</script>")
%>