<%@ page language="C#" autoeventwireup="true" inherits="admin_attachment_insert, kfenlei" %><%@ Register Src="../inc/adminTop.ascx" TagName="adminTop" TagPrefix="qth8" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>框分类信息系统 后台管理</title>
<link href="../css.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <div align="center">
<div class="main" align="left">
<qth8:adminTop ID="AdminTop1" runat="server" />
<div class="d01">
<div class="layui-btn" onclick="insertAttachment('/upload/')">开始导入</div>
<div id="attachment" class="cmdText"></div>
<script type="text/javascript">
var sPathArr=new Array();
sPathArr[0]="/upload/";
var iP=0;
var iC=1;

function insertAttachment(sPath)
{
	text("开始载入目录！<br />");
   setTimeout("searchDir(sPathArr[iP])", 1000);
}
function searchDir(sPath)
{

	$.get("insert.aspx",{s:"path",p:encodeURI(sPath),t:Math.random()},function(data,status)
    {
		var sPathArrTemp=data.split(',');
		for(i=0;i<sPathArrTemp.length;i++)
		{
			if(sPathArrTemp[i]!="")
			{
				sPathArr[iC]=sPathArrTemp[i];
				iC++;
				text(sPathArrTemp[i]+"<br />");
			}
		}
		iP++;
		if(sPathArr.length>iP)
		{
			text("<strong>->载入目录：</strong>"+sPathArr[iP]+"<br />");
			setTimeout("searchDir(sPathArr[iP])", 10);
		}
	   else
	   {
	   		text("->载入入完成！<br />");
			text("->开始导入文件！<br />");
			iC=0;
			iP=0;
			setTimeout("insertFile(0,0)", 10);
	   }
    });
}
function insertFile(dir,file)
{
	$.get("insert.aspx",{s:"file",p:encodeURI(sPathArr[dir]),f:file,t:Math.random()},function(data,status)
    {
		if(data!="")
		{
			text("-><strong>导入成功</strong>"+data+"<br />");
			iP++;
		}
		else
		{
			iC++;
			iP=0;
		}
		if(sPathArr.length>iC)
		{
			setTimeout("insertFile(iC,iP)", 10);
		}
		else
		{
			text("->导入完成！<br />");
		}
	});
}
function text(str)
{
	$("#attachment").html(str+$("#attachment").html());
	if($("#attachment").html().length>3000)
	{
		$("#attachment").html("");
	}
}
</script>
</div></div></div>
</body>
</html>
