<%@ Page Inherits="Caicai.Framework.UI.Admin.CreateHtml" %>
<!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">
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link type="text/css" href="style.css" rel="stylesheet" rev="stylesheet" media="all" />
<script type="text/javascript" src="../files/common/jquery.js"></script>
<script type="text/javascript" charset="gb2312">
function html(name,countall,count,button)
{
	$.ajax
	({
		url:"?random=" + Math.random(),
		data:"action=one&name=" + escape(name),
		dataType:"json",
		beforeSend:function(XMLHttpRequest)
		{
			$("#result").html("正在生成...<br />");
		},
		success: function(msg) 
		{
			//$("#result").append(msg[0].name + " 生成成功...<br />");
			$("#result").html(msg[0].name + " 生成成功...<br />");

			if(countall == count)
			{
				$("#result").html("<span style='color:red;font-weight:700;'>共计" + countall + "个页面,全部生成完毕！</span><br />");
				button.attr("disabled","");
			}
		}
	});
}

$(function()
{
	$("#ButtonOne").click(function()
	{
		var $this = $(this);
		$this.attr("disabled","disabled"); 
		//html($("#pagename").val(),1,1,$this);
		
		var pagename = $("#pagename").val().split("\n");
		var countall = pagename.length;

		for(i=0; i<countall; i++)
		{
			html(pagename[i],countall,i+1,$this);
		}
		return false;
	});

	$(".html").click(function()
	{
		html($(this).text(),1,0,$(this));
		return false;
	});

	$("#ButtonDelete").click(function()
	{
		var $this = $(this);
		$this.attr("disabled","disabled"); 

		$.ajax
		({
			url:"?random=" + Math.random(),
			data:"action=delete",
			dataType:"json",
			beforeSend:function(XMLHttpRequest)
			{
				$("#result").html("正在删除...<br />");
			},
			success: function(msg) 
			{
				$("#result").html("共删除计"+ msg[0].count +"个页面...");
				$this.attr("disabled","");
			}
		});
		return false;
	})
});
</script>
<style type="text/css">
#progress {border:1px solid #ccc; height:5px; padding:1px;}
#progress div {background:#3366FF; height:5px; width:0;}
</style>
</head>
<body id="html">
<form id="form1" runat="server">
<table class="table">
<tr>
	<td style="padding:8px;"><div id="result" style="float:right;">点击下面按钮进行生成页面...</div><a href="?action=all" target="html" class="abutton">生成全部页</a><a href="#" class="abutton" id="ButtonDelete">删除全部页</a></td>
</tr>
<tr>
	<td><iframe width="100%" height="180" frameborder="0" id="html" name="html" src=""></iframe></td>
</tr>
<tr>
	<td style="padding:10px 0;"><textarea id="pagename" style="height:100px;">sitemap.xml
</textarea></td>
</tr>
<tr>
	<td><input type="button" value=" 生成指定页 " id="ButtonOne" class="button"></td>
</tr>
<tr>
	<td><a href="#" class="html">sitemap.xml</a></td>
</tr>
</table>
</form>
</body>
</html>