(function(){var a,g=function(b){$.post("?app=spider&controller=manager&action=testRule",b,function(d){d.state?ct.ok(d.info):ct.error(d.error)},"json")};window.App={init:function(){a=document.getElementById("ruleForm");$(a.listType).click(function(){var c=this.value==1?"hide":"show";$(this).parents("tbody:first").next("tbody")[c]();$(a.contentUrl).next("button")[c]()});var b=$("#replacement");b.find(">tr:gt(0)").each(function(){var c=$(this),e=$('<a href="javascript:;">\u5220\u9664</a>').click(function(){c.remove()});
c.find("td:last").append(e)});var d=$('<a href="javascript:;">\u6dfb\u52a0</a>').click(function(){var c=b.find(">tr:last"),e=c.clone();e.find("th").html("&nbsp;");e.find("textarea").val("");var f=$('<a href="javascript:;">\u5220\u9664</a>').click(function(){e.remove()});e.find("td:last").html(f);c.after(e)});b.find(">tr:first>td:last").append(d);$(a).ajaxForm(function(c){c.state?ct.confirm(c.info+"\uff0c\u7ee7\u7eed\u7f16\u8f91\u6b64\u89c4\u5219\uff1f",null,function(){ct.assoc.close()}):ct.error(c.error)})},
addSite:function(){ct.form("\u6dfb\u52a0\u7f51\u7ad9","?app=spider&controller=manager&action=addSite",280,100,function(b){if(b.state){b=new Option(b.data.name,b.data.siteid);a.siteid.options.add(b);return b.selected=true}})},testEnterRule:function(){var b=["url="+encodeURIComponent(a.listUrl.value),"pattern="+encodeURIComponent(a.enterPattern.value)].join("&");g(b)},testListRule:function(){var b=["url="+encodeURIComponent(a.contentUrl.value),"pattern="+encodeURIComponent(a.urlPattern.value)].join("&");
g(b)},testGetList:function(){var b=["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",
b,function(d){var c=$("<div></div>").html(d||"").dialog({autoOpen:true,bgiframe:true,modal:false,height:500,width:500,title:"\u83b7\u53d6\u5217\u8868\u6d4b\u8bd5",close:function(){c.dialog("destroy").remove()}})})},testGetDetail:function(){var b=["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],d=a["replacement[source][]"],c=a["replacement[target][]"];if(d.nodeType){b.push("replacement[source][]="+encodeURIComponent(d.value));b.push("replacement[target][]="+encodeURIComponent(c.value))}else for(var e=0,f=d.length;e<f;e++){b.push("replacement[source][]="+encodeURIComponent(d[e].value));b.push("replacement[target][]="+encodeURIComponent(c[e].value))}$.post("?app=spider&controller=manager&action=testGetDetail",
b.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()}})})}}})();
