<?php
require('global.php');
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $_SET['def_charset'] ?>">
<title>数据采集</title>
<script type="text/javascript" src="<?php echo W_P;?>images/js/qmecms.js"></script>
</head>
<script  type='text/javascript'>
var config = {charset:'{$_SET['def_charset']}',channelid : '{$channelid}',channeldir : '{$channeldir}',url : "{W_P}",web_path : "{$_SET[webpath]}"};
</script>
<script type="text/javascript">
var web_path = '';
var cookpre  = '';
</script>
<script type="text/javascript">
var rules     = '<?=intval( $_GET['rules']); ?>';
var channelid = '<?=intval( $_GET['channelid']); ?>';
function htmlCreateReady()
{
	htmlCreateGo();
	return true;
}

function htmlCreateGo()
{
	if( parent.index == parent.data.length )
	{
		if(parent.htmlFlag==0)
		{
			parent.htmlFlag = 1;
			parent.document.getElementById('submit').disabled = false;
			parent.document.getElementById('submit').value    = "开始采集链接数据";
			parent.document.getElementById('submit1').disabled = false;
			parent.document.getElementById('submit1').value    = "加载已有链接数据";
			parent.document.getElementById('divProcessing').style.display  = "block";
			setTimeout("parent.document.getElementById('message').innerHTML    = '好累啊！终于完成任务了'", 5000);
		}
		else
		{
			return true;
		}
	}
	if( parent.htmlFlag == 0)
	{
		htmlCreate( parent.data[parent.index]);
		parent.index++;
		parent.document.getElementById('loadhtml').style.width = parseInt(parent.index/parent.data.length*100) + '%';
		parent.document.getElementById('loadhtml').innerHTML = '<font color=green>'+parent.index+'</font>/<font color=green>'+parent.data.length+'</font>';
		return true;
	}
}

function htmlCreate( id)
{
	parent.document.getElementById('divProcessing').style.display  = "block";
	var link = "content.php?id="+id+"&rules="+rules+"&channelid="+channelid;
	AJAX.request( link,
	{
		method		: "get",
		onComplete	: function(json){
			parent.document.getElementById('divProcessing').style.display  = "none";
			try{
				if( parseInt(json.status) > 0){
					parent.showInfo(json)
				}
			}catch(e){}
			try{
				htmlCreateGo();
			}catch( e){};
			return true;
		}
	});
}
window.onload = htmlCreateReady();
</script>