<%@ page contentType="text/html; charset=GBK"%>
<%@ page import="java.sql.*,gbase.db.*,gbase.util.*" %>
<%@ include file="../checkLogin.jsp" %>
<SCRIPT language="JavaScript" src="../js/util.js"></SCRIPT>
<LINK href="../css/css.css" rel=stylesheet>
<SCRIPT language=JavaScript>
 function ceshi(Num){
    var content=document.form1.content.value;
    var huoqv="";
    if(Num==5)
      huoqv=document.form1.title_start_str.value;
    else if(Num==6)
      huoqv=document.form1.title_end_str.value;
    else if(Num==7)
      huoqv=document.form1.content_start_str.value;
    else if(Num==8)
      huoqv=document.form1.content_end_str.value;
    else if(Num==15)
      huoqv=document.form1.next_page_start_str.value;  
    else if(Num==16)
      huoqv=document.form1.next_page_end_str.value;  
    else if(Num==19)
      huoqv=document.form1.page_start_str.value;  
    else if(Num==20)
      huoqv=document.form1.page_end_str.value;    
      
    if(huoqv=="")
      alert("测试无效！代码为空！");
    else if(content.indexOf(huoqv)<0)
      alert("测试无效！网页没有这些代码。");
    else if(content.indexOf(huoqv)>0 && content.lastIndexOf(huoqv)>0 && content.indexOf(huoqv)!=content.lastIndexOf(huoqv))
      alert("测试失败！代码有重复,开始或结束至少有一处代码是唯一才有效！");
    else
      alert("测试成功！代码在页面是唯一的。");
   }     
 var openurl=0;
 function CheckForm(){
    if (document.form1.Content.value.length > 200000){
        document.form1.Content.value="";
    }
 }
 function setFileFields(weburl){   
    if (openurl==0){
        str="<iframe id='IFrame1' marginwidth=0 marginheight=0 frameborder=0  width='785' height='400' src="+weburl+"></iframe>";
        objFiles.innerHTML=str;
        openurl=1
    }
 }
var tID=0;
function ShowTabs(ID){
  if(ID!=tID){
    TabTitle[tID].className='title5';
    TabTitle[ID].className='title6';
    Tabs[tID].style.display='none';
    Tabs[ID].style.display='';
    tID=ID;
  }
}
</SCRIPT>
<%
DBOperation theDBOperation = new DBOperation();

String id = request.getParameter("id") == null ? "" :request.getParameter("id");
String action = request.getParameter("action") == null ? "" :request.getParameter("action");
String titlepage_url = "";
String content="";
String listurl = "";
String web_encoding="GBK";
String list_start_str="";    
String list_end_str="";    
String href_start_str="";    
String href_end_str="";    
String hreftype="0";    
String rehrefurlstr="";   
String title_start_str="";    
String title_end_str="";    
String content_start_str="";    
String content_end_str="";    
String content_page_type="0";    
String next_page_start_str="";    
String next_page_end_str="";    
String page_start_str="";    
String page_end_str="";    
String page_url_start_str="";    
String page_url_end_str="";    

if(action.equals("update") || action.equals("view"))
{
String sql = "select * from web_collection  where id="+id+"";
ResultSet rs =theDBOperation.getResultSet(sql);
if(rs.next())
{
listurl=rs.getString("listurl")==null?"":rs.getString("listurl");
web_encoding=rs.getString("web_encoding")==null?"":rs.getString("web_encoding");
list_start_str=rs.getString("list_start_str")==null?"":rs.getString("list_start_str");
list_end_str=rs.getString("list_end_str")==null?"":rs.getString("list_end_str");  
href_start_str=rs.getString("href_start_str")==null?"":rs.getString("href_start_str");    
href_end_str=rs.getString("href_end_str")==null?"":rs.getString("href_end_str");    
hreftype=rs.getString("hreftype")==null?"0":rs.getString("hreftype");    
rehrefurlstr=rs.getString("rehrefurlstr")==null?"":rs.getString("rehrefurlstr");    

title_start_str=rs.getString("title_start_str")==null?"":rs.getString("title_start_str"); 
title_end_str=rs.getString("title_end_str")==null?"":rs.getString("title_end_str");     
content_start_str=rs.getString("content_start_str")==null?"":rs.getString("content_start_str");     
content_end_str=rs.getString("content_end_str")==null?"":rs.getString("content_end_str");     
content_page_type=rs.getString("content_page_type")==null?"0":rs.getString("content_page_type");     
next_page_start_str=rs.getString("next_page_start_str")==null?"":rs.getString("next_page_start_str");     
next_page_end_str=rs.getString("next_page_end_str")==null?"":rs.getString("next_page_end_str");     
page_start_str=rs.getString("page_start_str")==null?"":rs.getString("page_start_str");     
page_end_str=rs.getString("page_end_str")==null?"":rs.getString("page_end_str");     
page_url_start_str=rs.getString("page_url_start_str")==null?"":rs.getString("page_url_start_str");     
page_url_end_str=rs.getString("page_url_end_str")==null?"":rs.getString("page_url_end_str");    
}
}
CollectionManager theCollectionManager=new CollectionManager();
titlepage_url=theCollectionManager.getListUrl_ContentUrl(listurl,web_encoding,list_start_str,list_end_str,href_start_str,href_end_str,hreftype,rehrefurlstr);
System.out.println("titlepage_url:"+titlepage_url);
content=theCollectionManager.getUrlContent(titlepage_url,web_encoding);
content=content.replaceAll("</TEXTAREA>","&lt;/TEXTAREA>");
content=content.replaceAll("</textarea>","&lt;/textarea>");
content=content.replaceAll("</Textarea>","&lt;/Textarea>");
%>
<html>
<head>
<title>
采编项目管理
</title>
</head>
<body leftmargin="0" topmargin="0">

<!--导航-->
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
       <tr>
		<td width="100%" height="20"  bgcolor="#eeeeee" class="p2">您当前所在的位置>>采编项目管理</td>
	   </tr>
       <tr>
          <td width="100%" height="2"> <img border="0" src="../images/spacer.gif" width="1" height="3"></td>
       </tr>
    </table>
<!--标题-->
<BR>
&nbsp;&nbsp;采编项目设置步骤：
<A href="web_collection_content1.jsp?action=view&id=<%=id%>">基本设置</A>
&gt;&gt; <A href="web_collection_content2.jsp?action=view&id=<%=id%>">列表设置</A> 
<%if(action.equals("update")){%> 
&gt;&gt; <A href="web_collection_content3.jsp?action=update&id=<%=id%>"><FONT color=red>正文设置</FONT></A> 
&gt;&gt; 采样测试
<%} else {%>
&gt;&gt; <A href="web_collection_content3.jsp?action=view&id=<%=id%>"><FONT color=red>正文设置</FONT></A> 
&gt;&gt; 采样测试
<%}%> 
&gt;&gt; 完成设置
<BR><BR>
<font color='red'>这是分析后所得到其中一个内容页URL：</font>
<%=titlepage_url%>
&nbsp;&nbsp; <a href='<%=titlepage_url%>' target='_blank'><font color=red>请检查是否正确</a>。</font><br>
<div align="center">
   <table border="0" width="100%" cellspacing="0" cellpadding="0" height="28">
	<tr align=middle height=24>
	        <td valign="bottom" align="right" width="7"></td>
		<TD class=title6 id=TabTitle onclick=ShowTabs(0) width="60">基本设置</TD>
                <TD class=title5 id=TabTitle onclick=ShowTabs(1) width="60">分页设置</TD>
                <TD class=title5 id=TabTitle onclick=ShowTabs(2) width="60">代码预览</TD>
                <TD class=title5 id=TabTitle onclick="ShowTabs(3);setFileFields('<%=titlepage_url%>')" width="60">网页预览</TD>
		<td valign="bottom" align="right"></td>
	</tr>
	<tr>
		<td bgcolor="#2C9CC4" colspan="8"><img border="0" src="../images/bline_3.gif" width="1" height="4"></td>
	</tr>
</table>
</div><br>

<FORM name=form1 action="web_collection_save3.jsp" method=post>
<input name="action" type="hidden" value="<%=action%>">
<input name="id" type="hidden" value="<%=id%>">
<input name="titlepage_url" type="hidden" value="<%=titlepage_url%>">
<table width="90%" class="p1" border="0" cellSpacing="1" cellPadding="3" align="center" bgColor="#cccccc">
        <TBODY id=Tabs>
        <TR>
          <TD bgColor=#e9f0f4 align=right width=120>标题开始代码：<BR><BR><BR><BR><BR><BR>标题结束代码：</TD>
          <TD onmouseover='vbscript:me.bgcolor="#F5F5F5"' onmouseout='vbscript:me.bgcolor="#FFFFFF"' bgColor=#ffffff>
             <TEXTAREA style="WIDTH: 450px; HEIGHT: 100px" name=title_start_str><%=title_start_str%></TEXTAREA>&nbsp;<FONT color=red>*</FONT><INPUT onclick=ceshi(5) type=button value=测试代码><BR>
             <TEXTAREA style="WIDTH: 450px; HEIGHT: 100px" name=title_end_str><%=title_end_str%></TEXTAREA>&nbsp;<FONT color=red>*</FONT><INPUT onclick=ceshi(6) type=button value=测试代码></TD></TR>
        <TR>
          <TD bgColor=#e9f0f4 align=right width=120>正文开始代码：
            <P>　</P>
            <P>　</P>正文结束代码：</TD>
          <TD onmouseover='vbscript:me.bgcolor="#F5F5F5"' onmouseout='vbscript:me.bgcolor="#FFFFFF"' bgColor=#ffffff>
            <TEXTAREA style="WIDTH: 450px; HEIGHT: 100px" name=content_start_str><%=content_start_str%></TEXTAREA>&nbsp;<FONT color=red>*</FONT><INPUT onclick=ceshi(7) type=button value=测试代码><BR>
            <TEXTAREA style="WIDTH: 450px; HEIGHT: 100px" name=content_end_str><%=content_end_str%></TEXTAREA>&nbsp;<FONT color=red>*</FONT><INPUT onclick=ceshi(8) type=button value=测试代码></TD></TR>
        </TBODY>
        <TBODY id=Tabs style="DISPLAY: none">
        <TR>
          <TD bgColor=#e9f0f4 align=right width=120>正文分页设置：</TD>
          <TD onmouseover='vbscript:me.bgcolor="#F5F5F5"' onmouseout='vbscript:me.bgcolor="#FFFFFF"' bgColor=#ffffff>
          <INPUT onclick="javascript:NewsPaing1.style.display='none';NewsPaing2.style.display='none'" type=radio CHECKED value=0 name=content_page_type>不采集正文分页&nbsp; 
          <INPUT onclick="javascript:NewsPaing1.style.display='';NewsPaing2.style.display='none'" type=radio value=1 name=content_page_type>从源代码中获取“下一页”URL&nbsp; 
          <INPUT onclick="javascript:NewsPaing1.style.display='none';NewsPaing2.style.display=''" type=radio value=2 name=content_page_type>从源代码中获取分页URL </TD></TR>
        <TR id=NewsPaing1 style="DISPLAY: none">
          <TD bgColor=#e9f0f4 align=right width=120>正文分页“下一页”<BR>URL开始代码：</FONT><BR><BR><BR><BR><BR><BR>正文分页“下一页”<BR>URL结束代码：</FONT></TD>
          <TD onmouseover='vbscript:me.bgcolor="#F5F5F5"' onmouseout='vbscript:me.bgcolor="#FFFFFF"' bgColor=#ffffff>
          <TEXTAREA style="WIDTH: 450px; HEIGHT: 100px" name=next_page_start_str><%=next_page_start_str%></TEXTAREA>&nbsp;
          <INPUT onclick=ceshi(15) type=button value=测试代码><BR>
          <TEXTAREA style="WIDTH: 450px; HEIGHT: 100px" name=next_page_end_str><%=next_page_end_str%></TEXTAREA>&nbsp;
          <INPUT onclick=ceshi(16) type=button value=测试代码></TD></TR>
        <TR id=NewsPaing2 style="DISPLAY: none">
          <TD bgColor=#e9f0f4 align=right width=120>分页代码开始：<BR><BR><BR><BR><BR><BR>分页代码结束：<BR><BR><BR><BR><BR><BR>分页URL开始代码：<BR>分页URL结束代码：</TD>
          <TD onmouseover='vbscript:me.bgcolor="#F5F5F5"' onmouseout='vbscript:me.bgcolor="#FFFFFF"' bgColor=#ffffff>
          <TEXTAREA style="WIDTH: 450px; HEIGHT: 100px" name=page_start_str><%=page_start_str%></TEXTAREA>&nbsp;
          <INPUT onclick=ceshi(19) type=button value=测试代码><BR>
          <TEXTAREA style="WIDTH: 450px; HEIGHT: 100px" name=page_end_str><%=page_end_str%></TEXTAREA>&nbsp;
          <INPUT onclick=ceshi(20) type=button value=测试代码><BR>
          <INPUT maxLength=200 size=50 name=page_url_start_str value="<%=page_url_start_str%>"><BR>
          <INPUT maxLength=200 size=50 name=page_url_end_str  value="<%=page_url_end_str%>"></TD></TR>
        </TBODY>
        <TBODY id=Tabs style="DISPLAY: none">
        <TR>
          <TD onmouseover='vbscript:me.bgcolor="#F5F5F5"' onmouseout='vbscript:me.bgcolor="#FFFFFF"' bgColor=#ffffff>
          <TEXTAREA style="WIDTH: 785px; HEIGHT: 400px" name=content><%=content%></TEXTAREA></TD></TR>
        </TBODY>
        <TBODY id=Tabs style="DISPLAY: none">
        <TR onmouseover='vbscript:me.bgcolor="#F5F5F5"' onmouseout='vbscript:me.bgcolor="#FFFFFF"' bgColor=#ffffff>
        <TD id=objFiles align=middle></TD></TR>
        </TBODY>
  
  </TABLE><BR>
<CENTER>
<INPUT id=ItemID type=hidden value=2 name=ItemID> 
<INPUT id=NeedSave type=hidden value=True name=NeedSave> 
<INPUT id=Action type=hidden value=Step2 name=Action> 
<INPUT type=button value="上一步" name=prebutton onclick="window.location.href='web_collection_content2.jsp?action=view&id=<%=id%>'"></TD>&nbsp;&nbsp; 
<input type="button" value="重  填" onclick = "document.form1.reset();">&nbsp;&nbsp; 
<INPUT type=button   value="下一步" name=next1 onclick = "javascript: if(check_validate(this.form)){this.form.submit();}"></TD> 
</CENTER>
</FORM>
</body>
<Script Language="javaScript">
    function  check_validate(theForm) {
        if (isSpace(theForm.title_start_str.value)) {
            alert("标题开始代码不能为空！");
            theForm.title_start_str.focus();
            return false;
        }
        if (isSpace(theForm.title_end_str.value)) {
            alert("标题结束代码不能为空！");
            theForm.title_end_str.focus();
            return false;
        }
        if (isSpace(theForm.content_start_str.value)) {
            alert("正文开始代码不能为空！");
            theForm.content_start_str.focus();
            return false;
        }
        if (isSpace(theForm.content_end_str.value)) {
            alert("正文结束代码不能为空！");
            theForm.content_end_str.focus();
            return false;
        }
        if(getRadioValue('content_page_type')=='1')
        {
          if (isSpace(theForm.next_page_start_str.value)) {
            alert("选择正文分页设置为'从源代码中获取“下一页”URL'时，正文分页“下一页”URL开始代码不能为空！");
            theForm.next_page_start_str.focus();
            return false;
          }
          if (isSpace(theForm.next_page_end_str.value)) {
            alert("选择分页类型为'从源代码中获取下一页的URL'时，正文分页“下一页”URL结束代码不能为空！");
            theForm.next_page_end_str.focus();
            return false;
          }
        }
        
        if(getRadioValue('content_page_type')=='2')
        {
          if (isSpace(theForm.page_start_str.value)) {
            alert("选择正文分页设置为'从源代码中获取分页URL'时，分页代码开始不能为空！");
            theForm.page_start_str.focus();
            return false;
          }
          if (isSpace(theForm.page_end_str.value)) {
            alert("选择正文分页设置为'从源代码中获取分页URL'时，分页代码结束不能为空！");
            theForm.page_end_str.focus();
            return false;
          }
          if (isSpace(theForm.page_url_start_str.value)) {
            alert("选择正文分页设置为'从源代码中获取分页URL'时，分页URL开始代码不能为空！");
            theForm.page_url_start_str.focus();
            return false;
          }
          if (isSpace(theForm.page_url_end_str.value)) {
            alert("选择正文分页设置为'从源代码中获取分页URL'时，分页URL结束代码不能为空！");
            theForm.page_url_end_str.focus();
            return false;
          }
        }
        return true;
    }
    function  onChange_hreftype(hreftype_value)
    { if(hreftype_value=='0')
      {
      HttpUrl1.style.display='none';
      }
      else
      {
      HttpUrl1.style.display='';
      }
    }
    
    function  onChange_content_page_type(content_page_type_value)
    { if(content_page_type_value=='0')
      {
      NewsPaing1.style.display='none';
      NewsPaing2.style.display='none';
      }
      else if(content_page_type_value=='1')
      {
      NewsPaing1.style.display='';
      NewsPaing2.style.display='none';
      }
      else if(content_page_type_value=='2')
      {
      NewsPaing1.style.display='none';
      NewsPaing2.style.display='';
      }
    }
    function  modify_init(content_page_type)
    { 
        RadioChecked('content_page_type',content_page_type);  
        onChange_content_page_type(content_page_type);
    }      
    modify_init('<%=content_page_type%>');
</Script>
</html>
