<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>网页采集</title>
<link href="css/base.css" rel="stylesheet" type="text/css" />
<link href="css/title.css" rel="stylesheet" type="text/css" />
<script>
function goFolderBrowser() {
var ret = window.external.folderBrowser("选择保存路径");
if (ret != null) { 
document.getElementById("LocalPath").value = ret; 
}
}
function goXPath() {
var addr=document.getElementById("FirstPage").value;
if(addr==""){
alert("请设置第一页的网址!");
return;
}
var lnk="?xmls=index.xmls&method=request&url="+encodeURIComponent(addr)+"&BrowseMode="+document.getElementById("BrowseMode").value;
var html=window.external.get(lnk);
var ret = window.external.openHtmlXPath(html);
if (ret != null) {
 document.getElementById("XPath").value = ret; 
}
}
function goWork(){
var workType=document.getElementById("WorkType").value;
if(workType==0){
goWorkFirst();
goWorkEach();
}
if(workType==1){
goWorkFirst(); 
}
if(workType==2){ 
goWorkEach();
}

}
function goWorkFirst(){
document.getElementById("divStatus").innerHTML="第1页开始";
var addr=document.getElementById("FirstPage").value;
var lnk="?xmls=work.xmls&method=getLinks&url="+encodeURIComponent(addr)+"&xpath="+encodeURIComponent(document.getElementById("XPath").value)+"&ItemId="+encodeURIComponent(document.getElementById("ItemId").value)+"&BrowseMode="+document.getElementById("BrowseMode").value;
lnk+="&like="+encodeURIComponent(document.getElementById("LikeText").value);
var html=window.external.get(lnk);
document.getElementById("divStatus").innerHTML="第1页完成";
}
function goWorkEach(){

var startPage=document.getElementById("StartPage").value;
var endPage=document.getElementById("EndPage").value;
var urlFormat=document.getElementById("UrlFormat").value;

for(var i=startPage;i<=endPage;i++){
var addr=urlFormat.replace("{*Page}",i);
document.getElementById("divStatus").innerHTML="第"+startPage+"页开始";
var lnk="?xmls=work.xmls&method=getLinks&url="+encodeURIComponent(addr)+"&xpath="+encodeURIComponent(document.getElementById("XPath").value)+"&ItemId="+encodeURIComponent(document.getElementById("ItemId").value);
lnk+="&like="+encodeURIComponent(document.getElementById("LikeText").value)+"&BrowseMode="+document.getElementById("BrowseMode").value;
var html=window.external.get(lnk);
document.getElementById("divStatus").innerHTML="第"+startPage+"页完成";
}

}
</script>
</head>
<!--[if lt IE 9]>
<script src="js/html5shiv.js"></script>
<![endif]-->
<body>
<div class="bgcolor">
<div class="bg">
<header>
<div class="center">
<h2>网页采集</h2>
</div>
</header>
<div class="pic_main">
<div class="pic_left">
<span><a href="{%#path%}?xmls=index.xmls">项目列表 </a>&gt; <a href="{%#path%}?xmls=readx.xmls&ItemId={%$http.get(ItemId)%}">内容管理</a> &gt;采集目录&gt;{%@row[Title]%}</span>
<!--<div class="sanjiao"></div>-->
<div class="file_name clear"><form id="form1" name="form1" method="post" action="{%#path%}?xmls=work.xmls&method={%@method%}" style="padding:0;pading:0;">
<table class="clear nobg">
 
<tr>
<td class="t1">目录第一页</td>
<td class="t2"><input name="FirstPage" type="text" class="mulu" style="width:500px;" value="{%@row[FirstPage]%}" ></td>
</tr>
<tr>
<td class="t1">目录网址格式</td>
<td class="t2"><input id="UrlFormat" name="UrlFormat" type="text"   style="width:500px;"  class="mulu" value="{%@row[UrlFormat]%}" ></td>
</tr>
<tr>
<td class="t1">目录链接包含文字</td>
<td class="t2"><input id="LikeText" name="LikeText" type="text" class="mulu" value="{%@row[LikeText]%}" ></td>
</tr>
<tr>
<td class="t1">目录第二页开始页</td>
<td class="t2"><input id="StartPage" name="StartPage" type="text" class="number" value="{%@row[StartPage]%}"></td>
</tr>
<tr>
<td class="t1">目录结束页</td>
<td class="t2"><input id="EndPage"  name="EndPage" type="text" class="number" value="{%@row[EndPage]%}" ></td>
</tr>
<tr>
<td class="t1">标签路径</td>
<td class="t2"><input id="XPath" name="XPath" type="text" class="mulu" value="{%$web.htmlEncode(@row[XPath])%}" > <button type=“button” class="no-float"  onClick="goXPath()">选择</button></td>
</tr><tr>
 <td class="t1">模式</td>
<td class="t2">
{%<input type="select" value="1" name="WorkType" id="WorkType">
<data type="list" name="options">

<item key="1">第一页</item>
<item key="2">开始页-结束页</item>
<item key="0">所有</item>
</data>
</input>%} </td>
</tr>
 
<tr>
<td colspan="2" class="t2"> <input type="hidden" value="{%@row[BrowseMode]%}" name="BrowseMode" id="BrowseMode"/>
<input type="hidden" value="{%@row[ItemId]%}" name="ItemId" id="ItemId"/> 
<button type="button" class="button-center" onClick="goWork()">开始采集</button></td>
</tr>
<td colspan="2" class="t2" id="divStatus" style="color:#990000">  </td>
</tr>
</table>
</form>
</div>
</div>
</div>
</div>
</div>
</body>
</html>