(function(){var a,f=function(c){$.post("?app=spider&controller=manager&action=testRule",c,function(b){b.state?ct.ok(b.info):ct.error(b.error)},"json")};window.App={init:function(){a=document.getElementById("ruleForm");$(a.listType).click(function(){var b=this.value==1?"hide":"show";$(this).parents("tbody:first").next("tbody")[b]();$(a.contentUrl).next("button")[b]()});var c=$("#replacement");$("#replaceAdder").click(function(){var b=c.find(">tr:last"),d=b.clone();d.find("th").html("&nbsp;");d.find("textarea").val("");
var e=$('<a href="javascript:;">\u5220\u9664</a>').click(function(){if(b==d)b=d.prev();d.remove()});d.find("td:last").html(e);b.after(d);b=d});$(a).ajaxForm(function(b){b.state?ct.confirm(b.info+"\uff0c\u7ee7\u7eed\u6dfb\u52a0\u89c4\u5219\uff1f",null,function(){ct.assoc.close()}):ct.error(b.error)})},addSite:function(){ct.form("\u6dfb\u52a0\u7f51\u7ad9","?app=spider&controller=manager&action=addSite",280,100,function(c){if(c.state){c=new Option(c.data.name,c.data.siteid);a.siteid.options.add(c);return c.selected=
true}})},testEnterRule:function(){var c=["url="+encodeURIComponent(a.listUrl.value),"pattern="+encodeURIComponent(a.enterPattern.value)].join("&");f(c)},testListRule:function(){var c=["url="+encodeURIComponent(a.contentUrl.value),"pattern="+encodeURIComponent(a.urlPattern.value)].join("&");f(c)},testGetList:function(){var c=["charset="+$(a.charset).filter(":checked").val(),"url="+encodeURIComponent(a.listUrl.value),"listType="+$(a.listType).filter(":checked").val(),"listStart="+encodeURIComponent(a.listStart.value),
"listEnd="+encodeURIComponent(a.listEnd.value),"urlPattern="+encodeURIComponent(a.urlPattern.value),"listLimitLength="+encodeURIComponent(a.listLimitLength.value),"listNextPage="+encodeURIComponent(a.listNextPage.value)].join("&");$.post("?app=spider&controller=manager&action=testGetList",c,function(b){var d=$("<div></div>").html(b||"").dialog({autoOpen:true,bgiframe:true,modal:false,height:500,width:500,title:"\u83b7\u53d6\u5217\u8868\u6d4b\u8bd5",close:function(){d.dialog("destroy").remove()}})})},
testGetDetail:function(){var c=["charset="+$(a.charset).filter(":checked").val(),"url="+encodeURIComponent(a.contentUrl.value),"rangeStart="+encodeURIComponent(a.rangeStart.value),"rangeEnd="+encodeURIComponent(a.rangeEnd.value),"titleStart="+encodeURIComponent(a.titleStart.value),"titleEnd="+encodeURIComponent(a.titleEnd.value),"contentStart="+encodeURIComponent(a.contentStart.value),"contentEnd="+encodeURIComponent(a.contentEnd.value),"nextPage="+encodeURIComponent(a.nextPage.value),"authorStart="+
encodeURIComponent(a.authorStart.value),"authorEnd="+encodeURIComponent(a.authorEnd.value),"sourceStart="+encodeURIComponent(a.sourceStart.value),"sourceEnd="+encodeURIComponent(a.sourceEnd.value),"pubdateStart="+encodeURIComponent(a.pubdateStart.value),"pubdateEnd="+encodeURIComponent(a.pubdateEnd.value),"allowTags="+encodeURIComponent(a.allowTags.value),"saveRemoteImg="+a.saveRemoteImg.checked],b=a["replacement[source][]"],d=a["replacement[target][]"];if(b.nodeType){c.push("replacement[source][]="+
encodeURIComponent(b.value));c.push("replacement[target][]="+encodeURIComponent(d.value))}else for(var e=0,g=b.length;e<g;e++){c.push("replacement[source][]="+encodeURIComponent(b[e].value));c.push("replacement[target][]="+encodeURIComponent(d[e].value))}$.post("?app=spider&controller=manager&action=testGetDetail",c.join("&"),function(h){var i=$("<div></div>").html(h||"").dialog({autoOpen:true,bgiframe:true,modal:false,title:"\u83b7\u53d6\u5185\u5bb9\u6d4b\u8bd5",height:500,width:500,close:function(){i.dialog("destroy").remove()}})})}}})();
