/*
 |--------------------------------------------------------------------------
 | SkyCaiji (蓝天采集器)
 |--------------------------------------------------------------------------
 | Copyright (c) 2018 https://www.skycaiji.com All rights reserved.
 |--------------------------------------------------------------------------
 | 使用协议  https://www.skycaiji.com/licenses
 |--------------------------------------------------------------------------
 */
'use strict';function prompt_success(msg){toastr.success(msg?msg:'')}
function prompt_error(msg){toastr.error(msg?msg:'')}
function ajax_check_userpwd(ajaxSet){var oldSuccess=ajaxSet.success;ajaxSet.success=function(data){if(data.data&&data.data._check_pwd_){if(data.msg){toastr.error(data.msg)}
var msg='<div style="text-align:left;"><div style="margin-bottom:15px;">该操作需要验证您的登录密码</div>'+'<input class="form-control" type="password" id="confirm_ipt_check_pwd" placeholder="登录密码" />'+'<div style="margin-top:15px;"><select class="form-control" id="confirm_ipt_check_skip" style="display:inline;width:auto;height:auto;padding:0;margin-right:3px;">';for(var i=0;i<=24;i++){msg+='<option value="'+i+'">'+i+'</option>'}
msg+='</select>小时内不再验证</div></div>';confirmRight({closeAfterFunc:!0,yes:'确定',no:'取消',msg:msg},function(){var ajaxSetData=isNull(ajaxSet.data)?{}:ajaxSet.data;var checkPwd=$('#confirm_ipt_check_pwd').val();var checkSkip=$('#confirm_ipt_check_skip').val();if(typeof(ajaxSetData)=='object'){ajaxSetData._check_pwd_=checkPwd;ajaxSetData._check_skip_=checkSkip}else{ajaxSetData=ajaxSetData?(ajaxSetData+'&'):'';ajaxSetData+='_check_pwd_='+encodeURIComponent(checkPwd);ajaxSetData+='&_check_skip_='+encodeURIComponent(checkSkip)}
ajaxSet.data=ajaxSetData;ajaxSet.success=oldSuccess;ajax_check_userpwd(ajaxSet)});$('#confirm_ipt_check_skip').val(admincpOp.getConfig('check_skip'));$('#confirm_ipt_check_skip').bind('change',function(){admincpOp.config('check_skip',$(this).val())});$('#confirm_ipt_check_pwd').bind('keyup',function(event){if(event.keyCode=="13"){$('#confirm_right .cr-btn-yes').trigger("click")}})}else{if(oldSuccess&&typeof(oldSuccess)=='function'){oldSuccess(data)}}};ajaxOpen(ajaxSet)}
var admincpOp={getConfig:function(key){var cpConfig=window.site_config.admincp;cpConfig=cpConfig?cpConfig:{};return key?cpConfig[key]:cpConfig},init:function(){var bodyWidth=$(document.body).width();var cpConfig=admincpOp.getConfig(null);if(cpConfig.skin){$('body').removeClass('skin-blue').addClass(cpConfig.skin)}
var menuOpts={};if(bodyWidth>767){if(cpConfig.mini==1){$('body').addClass('sidebar-collapse').addClass('sidebar-mini')}
if(cpConfig.narrow==1){$('body').addClass('layout-boxed')}
menuOpts={animationSpeed:300};if(window.navigator.userAgent.indexOf('MSIE')>-1){menuOpts={animationSpeed:0}}}else{menuOpts={animationSpeed:0}}
$('.sidebar-menu').tree(menuOpts);$(document).ready(function(){$('#treeview_skins').bind('click',function(){if($('#sidebar_skins').html().length<=0){admincpOp.skins()}});if(bodyWidth>767){if(cpConfig.mini==1){$('#chk_sidebar_mini').prop('checked',!0)}
$('#chk_sidebar_mini').bind('click',function(){var setMini=$(this).is(':checked')?1:0;admincpOp.config('mini',setMini,function(){if(setMini){$('body').addClass('sidebar-collapse').addClass('sidebar-mini')}else{$('body').removeClass('sidebar-collapse').removeClass('sidebar-mini')}})});$('.sidebar-toggle[data-toggle="push-menu"]').bind('click',function(){$('body').addClass('sidebar-mini')});if(cpConfig.narrow==1){$('#chk_sidebar_narrow').prop('checked',!0)}
$('#chk_sidebar_narrow').bind('click',function(){var setNarrow=$(this).is(':checked')?1:0;admincpOp.config('narrow',setNarrow,function(){if(setNarrow){$('body').addClass('layout-boxed')}else{$('body').removeClass('layout-boxed')}})})}else{$('#chk_sidebar_mini').parents('li').eq(0).hide();$('#chk_sidebar_narrow').parents('li').eq(0).hide()}
if($('#menu_backstage_task').length>0){$('#menu_backstage_task').bind('click',function(){windowModal('采集任务',ulink('admin/backstage/backstageTask'),{lg:1})});winBackstageTask.count()}})},config:function(op,val,successFunc){ajaxOpen({type:'post',url:ulink('backstage/admincp'),data:{op:op,val:val},success:function(data){if(successFunc&&typeof(successFunc)=='function'){successFunc()}}})},skins:function(){var skinList={'blue':{'name':window.tpl_lang.skin_blue,'top_l_style':'background:#367fa9','top_r_class':'bg-light-blue','left_style':'background: #222d32','right_style':'background: #f4f5f7'},'black':{'name':window.tpl_lang.skin_black,'top_style':'box-shadow: 0 0 2px rgba(0,0,0,0.1)','top_l_style':'background: #fefefe','top_r_style':'background: #fefefe','left_style':'background: #222','right_style':'background: #f4f5f7'},'purple':{'name':window.tpl_lang.skin_purple,'top_l_class':'bg-purple-active','top_r_class':'bg-purple','left_style':'background: #222d32','right_style':'background: #f4f5f7'},'green':{'name':window.tpl_lang.skin_green,'top_l_class':'bg-green-active','top_r_class':'bg-green','left_style':'background: #222d32','right_style':'background: #f4f5f7'},'red':{'name':window.tpl_lang.skin_red,'top_l_class':'bg-red-active','top_r_class':'bg-red','left_style':'background: #222d32','right_style':'background: #f4f5f7'},'yellow':{'name':window.tpl_lang.skin_yellow,'top_l_class':'bg-yellow-active','top_r_class':'bg-yellow','left_style':'background: #222d32','right_style':'background: #f4f5f7'},'blue-light':{'name':window.tpl_lang.skin_blue_light,'top_l_style':'background: #367fa9','top_r_class':'bg-light-blue','left_style':'background: #f9fafc"','right_style':'background: #f4f5f7'},'black-light':{'name':window.tpl_lang.skin_black_light,'top_style':'box-shadow: 0 0 2px rgba(0,0,0,0.1)','top_l_style':'background: #fefefe','top_r_style':'background: #fefefe','left_style':'background: #f9fafc','right_style':'background: #f4f5f7'},'purple-light':{'name':window.tpl_lang.skin_purple_light,'top_l_class':'bg-purple-active','top_r_class':'bg-purple','left_style':'background: #f9fafc','right_style':'background: #f4f5f7'},'green-light':{'name':window.tpl_lang.skin_green_light,'top_l_class':'bg-green-active','top_r_class':'bg-green','left_style':'background: #f9fafc','right_style':'background: #f4f5f7'},'red-light':{'name':window.tpl_lang.skin_red_light,'top_l_class':'bg-red-active','top_r_class':'bg-red','left_style':'background: #f9fafc','right_style':'background: #f4f5f7'},'yellow-light':{'name':window.tpl_lang.skin_yellow_light,'top_l_class':'bg-yellow-active','top_r_class':'bg-yellow','left_style':'background: #f9fafc','right_style':'background: #f4f5f7'},};var html='<ul class="list-unstyled clearfix">';for(var skin in skinList){var skinSet=skinList[skin];html+='<li style="float:left; width: 33.33333%; padding: 5px;">'+'<a href="javascript:void(0)" data-skin="skin-'+skin+'" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">'+'<div style="'+(skinSet.top_style?skinSet.top_style:'')+'">'+'<span style="display:block; width: 20%; float: left; height: 7px; '+(skinSet.top_l_style?skinSet.top_l_style:'')+'" class="'+(skinSet.top_l_class?skinSet.top_l_class:'')+'"></span>'+'<span class="'+(skinSet.top_r_class?skinSet.top_r_class:'')+'" style="display:block; width: 80%; float: left; height: 7px; '+(skinSet.top_r_style?skinSet.top_r_style:'')+'"></span></div>'+'<div><span style="display:block; width: 20%; float: left; height: 20px; '+(skinSet.left_style?skinSet.left_style:'')+'"></span><span style="display:block; width: 80%; float: left; height: 20px; '+(skinSet.right_style?skinSet.right_style:'')+'"></span>'+'</div>'+'</a>'+'<p class="text-center no-margin">'+skinSet.name+'</p>';+'</li>'}
html+='</ul>';$('#sidebar_skins').html(html);$('#sidebar_skins li a[data-skin]').bind('click',function(){var skin=$(this).attr('data-skin');admincpOp.config('skin',skin,function(){for(var i in skinList){i='skin-'+i;$('body').removeClass(i)}
$('body').addClass(skin)})})}};var globalOp={insertAtCaret:function(myField,myValue){myField=$(myField);var curObj=myField[0];if(document.selection){myField.focus();var sel=document.selection.createRange();sel.text=myValue;sel.select()}else if(curObj.selectionStart||curObj.selectionStart=='0'){var startPos=curObj.selectionStart;var endPos=curObj.selectionEnd;var restoreTop=curObj.scrollTop;var value=myField.val();value=value.substring(0,startPos)+myValue+value.substring(endPos,value.length);myField.val(value);myField.focus();curObj.selectionStart=startPos+myValue.length;curObj.selectionEnd=startPos+myValue.length}else{myField.val(myField.val()+myValue);myField.focus()}},urlUsertoken:function(){return'_usertoken_='+encodeURIComponent(window.site_config.usertoken)},openStoreUrl:function(url){if(url.indexOf('clientinfo=')<0&&window.site_config.clientinfo){url+=(url.indexOf('?')>-1?'&':'?')+'clientinfo='+encodeURIComponent(window.site_config.clientinfo)}
window.open(url,'_blank')},eleExchange:function(box,move,ele,options){if(!isObject(options)){options={}}
if(!window.ele_exchange_is_touch){window.ele_exchange_is_touch=1;if('ontouchstart' in window||navigator.maxTouchPoints){window.ele_exchange_is_touch=2}}
if(window.ele_exchange_is_touch==2){$(box).on('click',move,function(){var obj=$(this).parents(ele).eq(0);var next=obj.next(ele);if(next.length>0){next.after(obj)}})}else{var curTrTds={};$(box).on('mousedown',move,function(){var obj=$(this).parents(ele).eq(0);if(obj.is('tr')){curTrTds={};obj.children('th,td').each(function(index){curTrTds[index]={width:$(this).width(),colspan:toInt($(this).attr('colspan')),hidden:$(this).is(':hidden')?true:!1}})}});var sOpts={items:ele,handle:move,axis:'y',start:function(event,ui){if(ui&&ui.item){var obj=$(ui.item[0]);if(obj.is('tr')){obj.children('th,td').each(function(index){var curTrTd=curTrTds[index];if(isObject(curTrTd)){$(this).width(curTrTd.width);if(curTrTd.colspan>0){$(this).attr('colspan',curTrTd.colspan)}
if(curTrTd.hidden){$(this).hide()}}});$('.ui-sortable-placeholder').children('th,td').each(function(index){var curTrTd=curTrTds[index];if(isObject(curTrTd)){$(this).width(curTrTd.width);if(curTrTd.colspan>0){$(this).attr('colspan',curTrTd.colspan)}
if(curTrTd.hidden){$(this).hide()}}})}}}};for(var i in options){sOpts[i]=options[i]}
$(box).sortable(sOpts)}},visualizeData:function(data){var cacheData=data;data=isNull(data)?'':data;var options={lg:1,hidden_func:function(){window.win_visualize_data=null}};if(dataIsJson(data)){var jsonId='json_'+generateUUID();modal('JSON解析','<div id="'+jsonId+'"></div>',options);var jsonTreeFunc=function(){window.tool_json_tree.treeId='#'+jsonId;window.tool_json_tree.load(data)};if(window.tool_json_tree){jsonTreeFunc()}else{$.getScript(window.site_config.pub+'/static/js/admin/tool_json_tree.js',jsonTreeFunc)}}else{options.loaded_func=function(){data=data.replace(/<script[^<>]*>[\s\S]*?<\/script>/ig,'');data=data.replace(/<meta[^<>]*charset[^<>]*>/i,'');var ifrId='#myModalIframe';$(ifrId).bind('load',function(){if($(ifrId).contents().find('body').html().length<=0){$(ifrId).contents().find('body').html(data)}});$(ifrId).contents().find('body').html(data)};var title='HTML预览';if(data&&data.indexOf('<pre>')===0){title='HTML代码'}
windowIframe(title,'',options)}(function(data){if(data){$('#myModal .modal-footer .close').addClass('btn btn-default').removeClass('close');$('#myModal .modal-footer').prepend('<button type="button" class="btn btn-info btn-back" data-dismiss="modal">返回</button>');$('#myModal .modal-footer .btn-back').bind('click',function(){globalOp.visualizeData(data)})}})(window.win_visualize_data);window.win_visualize_data=cacheData},showPanelCollapse:function(id){$(id).parent().find('a[data-toggle][href="'+id+'"]').attr('aria-expanded',!0).removeClass('collapsed');$(id).addClass('in').attr('aria-expanded',!0).attr('style','')},inputSelectCustom:function(sltObj,iptName,onOptions,customName,changeFunc){customName=customName?customName:'custom';var onChangeFunc=function(curObj,iptEle){var ipt=$(curObj).parents('.input-select-custom').eq(0).find(iptEle);if($(curObj).val()==customName){ipt.show()}else{ipt.hide()}
if(changeFunc&&typeof(changeFunc)=='function'){changeFunc()}};if(sltObj&&iptName){$(sltObj).bind('change',function(){onChangeFunc(this,'[name="'+iptName+'"]')})}else if(onOptions&&typeof(onOptions)=='object'){$(onOptions.box).on('change',onOptions.slt,function(){onChangeFunc(this,onOptions.ipt)})}},cpEasyBrowser:function(url,pageSource,inputUrls){pageSource=pageSource?pageSource:'';inputUrls=inputUrls?inputUrls:{};var data={type:'browser_url',page_source:pageSource,test_url:url,input_urls:inputUrls};data=JSON.stringify(data);window.top.postMessage(data,'*')},cpBrowserUrl:function(collId,pageSource,testUrl,inputedUrls){inputedUrls=inputedUrls?inputedUrls:{};var url='cpattern_test/browser?coll_id=_collid_&page_source=_source_&test_url=_url_';if(inputedUrls){for(var i in inputedUrls){url+='&'+i+'='+encodeURIComponent(inputedUrls[i])}}
url=ulink(url,{'_collid_':collId,'_source_':pageSource,'_url_':testUrl});return url},loadFormConfig:function(formObj,config,namePre){if(formObj&&isObject(config)){namePre=namePre?namePre:'';for(var i in config){var eleVal=config[i];var eleValIsArr=isObject(eleVal)?true:!1;var eleName=namePre?(namePre+'['+i+']'):i;var eleObj=$(formObj).find('[name="'+eleName+'"]');if(eleObj.length>0){var eleTag=eleObj.eq(0).prop('tagName').toLowerCase();if(eleTag=='input'){var eleType=eleObj.eq(0).attr('type').toLowerCase();if(eleType=='radio'||eleType=='checkbox'){eleObj.each(function(){if($(this).val()==eleVal){$(this).trigger('click')}})}else{eleObj.val(eleVal)}}else if(eleTag=='textarea'){eleObj.val(eleVal)}else if(eleTag=='select'){eleObj.val(eleVal).trigger('change')}}else{var isConfig=!0;eleObj=$(formObj).find('[name="'+eleName+'[]"]');if(eleObj.length>0){var eleTag=eleObj.eq(0).prop('tagName').toLowerCase();var eleType=eleObj.eq(0).attr('type').toLowerCase();if(eleTag=='input'&&eleType=='checkbox'){isConfig=!1;eleObj.each(function(){var curVal=$(this).val();if(eleValIsArr){if(eleVal.indexOf(curVal)>-1){$(this).prop('checked',!0)}}else{if(curVal==eleVal){$(this).prop('checked',!0)}}})}}
if(isConfig){globalOp.loadFormConfig(formObj,eleVal,eleName)}}}}},tipsCurlPost:function(){var tips='<p>表单数据：模拟form表单输入的数据</p><p>表单上传：模拟form表单输入并上传的数据</p>'+'<p>JSON数组：以json格式发送数据，可在“发送数据”的“值”中直接输入json字符串。在“名称”中填入json数组键名，子节点名称使用.分隔，例如：a.b.c。根节点名称可使用###表示</p>';confirmRight({msg:tips,yes:'确定',width:500,textAlign:'left'})},editorCodeIfr:function(ifrEle,options){options=isObject(options)?options:{};if(options.set_value!=null&&typeof(options.set_value)!='undefined'){$(document).ready(function(){$(ifrEle).attr('src','');$(ifrEle).attr('src',ulink('develop/editor_code'));$(ifrEle).off('load').bind('load',function(){if(options.set_value&&$(ifrEle)[0].contentWindow.editor_code_op){$(ifrEle)[0].contentWindow.editor_code_op.set(options.set_value)}})})}else if(options.get_value){var ifrEle=$(ifrEle)[0];var val='';if(ifrEle&&ifrEle.contentWindow.editor_code_op){val=ifrEle.contentWindow.editor_code_op.get()}
return val}},collectorWindow:function(title,uri,uriVals,options){options=options?options:{};options.backdrop_static=1;title=isNull(title)?'':title;title+='<div class="loading-sm" style="margin-left:5px;"></div>';window.win_collector_window_params={title:title,uri:uri,uriVals:uriVals,options:options};windowModal(title,ulink('admin/collector/echo_msg?op=run'),{lg:options.lg})}};var pluginApiOp={load:function(params){params=params?params:{};var cacheParams=params;var boxObj=$(params.boxObj);var appObj=boxObj.find(params.appObj);var appApp=params.appApp?params.appApp:'';var appConfig=isObject(params.appConfig)?params.appConfig:{};var namePre=params.namePre?params.namePre:'config';var winCacheName='win_cache_plugin_api_'+params.module;boxObj.find('.plugin-api-refresh').off('click').bind('click',function(){window[winCacheName]=null;appObj.removeAttr('data-is-loaded');appObj.html('');cacheParams.show_refresh=1;pluginApiOp.load(cacheParams);return!1});if(!appObj.attr('data-change-ops')){appObj.attr('data-change-ops',1);appObj.bind('change',function(){var curVal=$(this).val();if(curVal){var sltOption=$(this).find('option:selected');var ops=sltOption.attr('data-ops');ops=decode_urlbase2json(ops);var html='';if(isObject(ops)){for(var i in ops){var op=ops[i];if(isObject(op)){var userOp=op.user;var nameKey=namePre+'['+op.name_key+']';var defaultVal=userOp['default'];html+='<div class="form-group plugin-api-op"><label>'+htmlspecialchars(op.name)+(userOp.required?'<span style="color:red;font-weight:bold;margin-left:5px;">*</span>':'')+'</label>';if(userOp.tag=='text'){html+='<textarea name="'+nameKey+'" rows="2" class="form-control"';if(defaultVal||defaultVal===0){html+=' placeholder="默认：'+htmlspecialchars(defaultVal)+'"'}
html+='"></textarea>'}else if(userOp.tag=='radio'){defaultVal=toInt(defaultVal);html+='<div class="input-group"><label class="radio-inline"><input type="radio" name="'+nameKey+'" value="1"'+(defaultVal>0?' checked="checked"':'')+'>是</label>'+'<label class="radio-inline"><input type="radio" name="'+nameKey+'" value="0"'+(defaultVal<=0?' checked="checked"':'')+'>否</label></div>'}else if(userOp.tag=='select'){html+='<select name="'+nameKey+'" class="form-control"><option value="">请选择</option>';if(isObject(userOp.tag_select)){for(var tsi in userOp.tag_select){html+='<option value="'+htmlspecialchars(tsi)+'"'+(defaultVal==tsi?' selected="selected"':'')+'>'+htmlspecialchars(userOp.tag_select[tsi])+'</option>'}}
html+='</select>'}
var tipsSltFields='';if(!params.isTest&&params.module=='process'&&userOp.tag=='text'){tipsSltFields='可以<select class="p-m-apiapp-field"><option value="">插入字段</option></select>'}
if(op.desc){tipsSltFields=tipsSltFields?('，'+tipsSltFields):'';html+='<p class="help-block">'+htmlspecialchars(op.desc)+tipsSltFields+'</p>'}else{html+='<p class="help-block">'+tipsSltFields+'</p>'}
html+='</div>'}}}
var opListObj=boxObj.find('.plugin-api-op-list');opListObj.html(html);if(html){opListObj.show()}else{opListObj.hide()}
if(params.module=='process'){if(window.c_pattern&&window.c_pattern.cpProcess){window.c_pattern.cpProcess.txt_insert_field(opListObj,'.p-m-apiapp-field',function(sltObj){return $(sltObj).parents('.plugin-api-op').eq(0).find('textarea')})}}
globalOp.loadFormConfig(boxObj,appConfig,namePre)}})}
var setAppVal=function(){appObj.val(appApp).trigger('change')};var setAppOptions=function(opts){var html='<option value="">--请选择--</option>';html=html+(opts?opts:'');appObj.html(html)}
if(appObj.attr('data-is-loaded')){setAppVal()}else{if(params.cache&&window[winCacheName]){appObj.attr('data-is-loaded',1);setAppOptions(window[winCacheName]);setAppVal()}else{var appUrl=ulink('collector/plugin_api?module=_module_',{'_module_':params.module});ajaxOpen({type:'GET',dataType:'json',url:appUrl,async:params.cache?false:!0,success:function(data){if(appObj.attr('data-is-loaded')){setAppVal()}else{appObj.attr('data-is-loaded',1);if(data.code==1){var html='';var apps=data.data;if(isObject(apps)){for(var app in apps){var appData=apps[app];if(isObject(appData)){html+='<option value="'+app+'" data-ops="'+encode_json2urlbase(appData.ops)+'">'+htmlspecialchars(appData.name+'（'+app+'）')+'</option>'}}}
setAppOptions(html);if(params.cache){window[winCacheName]=html}}}
if(params.show_refresh){toastr.success('已刷新')}},error:function(xhr,status,error){appObj.removeAttr('data-is-loaded');toastr.error('接口插件载入失败：'+status+' '+error+' <a href="'+appUrl+'" target="_blank" style="color:#ddd;">查看详细</a>')},complete:function(xhr,status){setAppVal()}})}}}};var pluginFuncOp={load:function(params){params=params?params:{};var cacheParams=params;var boxObj=$(params.boxObj);var funcObj=boxObj.find(params.funcObj);var paramObj=params.paramObj?boxObj.find(params.paramObj):null;var funcVal=params.funcVal?params.funcVal:'';var winCacheName='win_cache_plugin_func_'+params.module;boxObj.find('.plugin-func-refresh').off('click').bind('click',function(){window[winCacheName]=null;funcObj.removeAttr('data-is-loaded');funcObj.find('[data-is-func]').remove();cacheParams.show_refresh=1;pluginFuncOp.load(cacheParams);return!1});if(paramObj&&paramObj.length>0){if(!funcObj.attr('data-change-pla')){funcObj.attr('data-change-pla',1);funcObj.bind('change',function(){var reStrFunc=function(str){if(str){var regLineR=new RegExp("\\\\r",'g');var regLineN=new RegExp("\\\\n",'g');str=str.replace(regLineR,"\r").replace(regLineN,"\n")}else{str=''}
return str};paramObj=boxObj.find(params.paramObj);var placeholder=paramObj.attr('data-placeholder');placeholder=reStrFunc(placeholder);if($(this).val()){var sltOption=$(this).find('option:selected');var funcPrams=sltOption.attr('data-params');funcPrams=funcPrams?funcPrams:'';var funcComment=sltOption.attr('data-comment');funcComment=funcComment?funcComment:'';if(funcPrams||funcComment){if(funcPrams){placeholder+="\r\n函数参数："+reStrFunc(funcPrams)}
if(funcComment){placeholder+="\r\n函数注释："+reStrFunc(funcComment)}}}
var rows=3;if(placeholder){var regLine=new RegExp("[\\r\\n]+",'g');var matchLine=placeholder.split(regLine);if(matchLine&&typeof(matchLine)=='object'){rows=parseInt(matchLine.length)+1}}
if(rows>8){rows=8}
if(rows<3){rows=3}
paramObj.attr('placeholder',placeholder).attr('rows',rows)})}}
var setFuncVal=function(){funcObj.val(funcVal).trigger('change')};var optEptObj=funcObj.find('option[value=""]');if(optEptObj.length<=0){optEptObj=null}
if(funcObj.attr('data-is-loaded')){setFuncVal()}else{if(params.cache&&window[winCacheName]){funcObj.attr('data-is-loaded',1);if(optEptObj){optEptObj.after(window[winCacheName])}else{funcObj.append(window[winCacheName])}
setFuncVal()}else{var funcUrl=ulink('collector/plugin_func?module=_module_',{'_module_':params.module});ajaxOpen({type:'GET',dataType:'json',url:funcUrl,async:params.cache?false:!0,success:function(data){if(funcObj.attr('data-is-loaded')){setFuncVal()}else{funcObj.attr('data-is-loaded',1);if(data.code==1){var html='';var apps=data.data;if(apps&&typeof(apps)=='object'){for(var app in apps){var appData=apps[app];appData=appData?appData:{};var methods=appData.methods;if(methods){html+='<optgroup label="'+htmlspecialchars(appData.name+'（'+app+'）')+'" data-is-func="1">';for(var m in methods){var mMethod=methods[m];mMethod=mMethod?mMethod:{};html+='<option value="'+app+':'+m+'" data-params="'+(mMethod.params?mMethod.params:'')+'" data-comment="'+(mMethod.comment?mMethod.comment:'')+'">'+m+'：'+(mMethod.comment_cut?mMethod.comment_cut:'')+'</option>'}
html+='</optgroup>'}}}
if(optEptObj){optEptObj.after(html)}else{funcObj.append(html)}
if(params.cache){window[winCacheName]=html}}}
if(params.show_refresh){toastr.success('已刷新')}},error:function(xhr,status,error){funcObj.removeAttr('data-is-loaded');toastr.error('函数插件载入失败：'+status+' '+error+' <a href="'+funcUrl+'" target="_blank" style="color:#ddd;">查看详细</a>')},complete:function(xhr,status){setFuncVal()}})}}},addHtml:function(params,module){if(!isObject(params)){params={}}
var funcData=isObject(params.funcData)?params.funcData:{};var funcName=params.funcName?params.funcName:'';var funcParamName=params.funcParamName?params.funcParamName:'';var tplId=params.tplId?params.tplId:'';tplId='#'+tplId;var listId=params.listId?params.listId:'';listId='#'+listId;var funcId=params.funcId?params.funcId:'';var html=$(tplId).html();html=$(html);var randId=generateUUID();funcName=funcName.replace('{id}',randId);funcParamName=funcParamName.replace('{id}',randId);funcId=funcId.replace('{id}',randId);html.find('[data-func-a]').attr('href','#'+funcId).html('使用函数'+(funcData.func?('：'+funcData.func):''));html.find('[data-func-panel]').attr('id',funcId);html.find('[data-func-func]').attr('name',funcName);html.find('[data-func-func-param]').attr('name',funcParamName).val(funcData.func_param?funcData.func_param:'');$(listId).append(html);var loadParams={'boxObj':funcId?$('#'+funcId):html.find('[data-func-panel]'),'module':module,'funcObj':'[name="'+funcName+'"]','paramObj':'[name="'+funcParamName+'"]','funcVal':funcData.func};pluginFuncOp.load(loadParams)},initHtml:function(listObj){$(listObj).on('click','a[data-func-insert]',function(){var val=$(this).attr('data-func-insert');if(val){var obj=$(this).parents('[data-func-box]').eq(0).find('textarea[data-func-func-param]');globalOp.insertAtCaret(obj,obj.val()?("\r\n"+val):val)}});$(listObj).on('click','a[data-func-remove]',function(){var curObj=$(this);confirmRight('确定删除？',function(){curObj.parents('[data-func-box]').eq(0).remove()})});globalOp.eleExchange(listObj,'a[data-func-move]','[data-func-box]')},tips:function(module){var tips='';if(module=='process'||module=='contentSign'){tips='<p>如需扩展系统函数，请在根目录/data/config.php中添加配置：</p>'+"<p>'EXTEND_PROCESS_FUNC'=&gt;array('PHP函数名'=&gt;'描述')</p>"+'<p>如需扩展插件函数，可创建<a href="'+ulink('develop/func?module='+module)+'" target="_blank">函数插件</a></p>'}else if(module=='processIf'){tips='<p>选择函数，取反可获取函数结果的相反值</p>'+'<p>默认将当前字段作为参数传入，如需传入多个参数，一行一个值，可输入任何内容或调用字段</p>'+'<p>请按函数传参，否则运行出错！</p>'+'<p>如需扩展系统函数，请在根目录/data/config.php中添加配置：</p>'+"<p>'EXTEND_PROCESS_IF'=&gt;array('PHP函数名'=&gt;'描述')</p>"+'<p>如需扩展插件函数，可创建<a href="'+ulink('develop/func?module=processIf')+'" target="_blank">函数插件</a></p>'}else if(module=='downloadImg'||module=='downloadFile'){window.open(ulink('develop/func?module='+module));return!1}
confirmRight({msg:tips,yes:'确定',width:500,textAlign:'left'})}};var collectorEchoMsg={config:{},processes:{},close_non_stop:!1,end_set_timeout:null,run:function(config){collectorEchoMsg.config=isObject(config)?config:{};collectorEchoMsg.processes={};collectorEchoMsg.close_non_stop=!1;var winParams=window.win_collector_window_params;winParams=isObject(winParams)?winParams:{};var uri=winParams.uri?winParams.uri:'';var uriVals=isObject(winParams.uriVals)?winParams.uriVals:{};var options=isObject(winParams.options)?winParams.options:{};var winProcessBox=$('#myModal #win_cem_process_box').clone();if(uri){var title=winParams.title+'<small style="margin-left:10px;">日志读取间隔<input type="number" class="form-control input-sm" style="display:inline;width:40px;height:20px;padding:1px 2px 1px 2px;margin:0px 3px 0px 3px;" id="win_cem_interval" value="'+collectorEchoMsg.get_interval()+'" />秒<button type="button" class="btn btn-default btn-xs" id="win_cem_interval_btn" style="margin-left:3px;">保存</button>';var closeFuncs=new Array();if(!isNull(options.close_func)){if(isObject(options.close_func)){closeFuncs=options.close_func}else{closeFuncs.push(options.close_func)}}
closeFuncs.push(function(){if(!collectorEchoMsg.close_non_stop){collectorEchoMsg.stop_all()}});options.close_func=closeFuncs;windowIframe(title,'',options);$('#myModal #myModalIframe').hide();$('#myModal #win_cem_interval_btn').bind('click',function(){collectorEchoMsg.set_interval($('#win_cem_interval').val())});var runUrl=ulink(uri,uriVals);ajaxOpen({type:'get',url:runUrl,dataType:'json',async:!0,success:function(data){if(data.code==1){var processes=data.data?data.data:{};var collectorKey=processes.collector_key?processes.collector_key:'';var processKeys=isObject(processes.process_keys)?processes.process_keys:[];var processNum=processKeys.length;if(!collectorKey||processNum<=0){return}
$('#myModal .modal-body').append(winProcessBox);if(processNum>1){$('#myModal .modal-body').addClass('win-cem-process-body')}
var processNavHtml='';for(var i=0;i<processNum;i++){processNavHtml+='<li><a href="javascript:;" data-collector-process="'+collectorKey+'-'+processKeys[i]+'">进程'+processKeys[i]+'</a></li>'}
$('#win_cem_process_nav').html(processNavHtml);$('#win_cem_process_nav [data-collector-process]').bind('click',function(){collectorEchoMsg.process($(this).attr('data-collector-process'))});runUrl+=(runUrl.indexOf('?')>-1?'&':'?')+'collector_key='+collectorKey;$('#myModal #myModalIframe').attr('src',runUrl);window.setTimeout(function(){collectorEchoMsg.process(collectorKey+'-'+processKeys[0])},200)}else{ajaxDataMsg(data);$('#myModal').modal('hide')}}})}},process:function(collectorProcess){if(!collectorProcess){return}
if(!collectorEchoMsg.processes[collectorProcess]){collectorEchoMsg.processes[collectorProcess]={}}
$('#win_cem_process_nav li').removeClass('active');$('#win_cem_process_nav').find('[data-collector-process="'+collectorProcess+'"]').parents('li').eq(0).addClass('active');$('#myModal .win-cem-ifr-box').hide();var ifrId='win_cem_ifr_'+collectorProcess;var ifr=document.getElementById(ifrId);if(!ifr){ifr=document.createElement('iframe');$(ifr).attr('id',ifrId);$(ifr).attr('frameborder','0');$(ifr).attr('scrolling','yes');$(ifr).bind('load',function(){collectorEchoMsg.processes[collectorProcess].line=0;collectorEchoMsg.processes[collectorProcess].html='';collectorEchoMsg.read(collectorProcess)});var box=document.createElement('div');$(box).addClass('win-cem-ifr-box');$(box).append(ifr);$('#myModal .modal-body').append(box)}else{collectorEchoMsg.read(collectorProcess)}
$(ifr).parents('.win-cem-ifr-box').eq(0).show()},read:function(collectorProcess){if(!collectorProcess){return}
if(!collectorEchoMsg.processes[collectorProcess]){return}
var interval=collectorEchoMsg.get_interval();var ifrId='win_cem_ifr_'+collectorProcess;if(collectorEchoMsg.processes[collectorProcess].read_timeout){window.clearTimeout(collectorEchoMsg.processes[collectorProcess].read_timeout)}
var startTime=new Date().getTime();var readFunc=function(){collectorEchoMsg.processes[collectorProcess].read_ajax=ajaxOpen({type:'get',dataType:'json',async:!0,url:ulink('admin/collector/echo_msg?op=read&collector_process=_c_p_&line=_line_&start=_start_&end=_end_',{'_c_p_':collectorProcess,'_line_':collectorEchoMsg.processes[collectorProcess].line,'_start_':startTime,'_end_':(new Date().getTime())}),success:function(data){if(data.code==1&&data.data){var line=toInt(data.data.line);if(line>0){collectorEchoMsg.processes[collectorProcess].line=line;collectorEchoMsg.ifr_html(collectorProcess,data.data.html);if(data.data.js){$('#'+ifrId).contents().find('head').append(data.data.js)}}}},complete:function(){collectorEchoMsg.processes[collectorProcess].read_timeout=window.setTimeout(function(){if($('#'+ifrId).is(':visible')){if(!collectorEchoMsg.processes[collectorProcess].end){readFunc()}}},interval*1000)}})};readFunc()},ifr_html:function(collectorProcess,html){html=html?html:'';var cpHtml=collectorEchoMsg.processes[collectorProcess].html;cpHtml=cpHtml?cpHtml:'';cpHtml+=html;collectorEchoMsg.processes[collectorProcess].html=cpHtml;var ifrBody=$('#win_cem_ifr_'+collectorProcess).contents().find('body').get(0);ifrBody.innerHTML=cpHtml},end:function(collectorProcess,errorMsg){if(collectorEchoMsg.end_set_timeout){window.clearTimeout(collectorEchoMsg.end_set_timeout)}
if(collectorProcess){if(errorMsg){errorMsg='<div style="color:red;font-weight:bold;margin:5px 0;" id="win_cem_error">'+url_base64decode(errorMsg)+'</div>';collectorEchoMsg.ifr_html(collectorProcess,errorMsg)}
var endAll=!1;var statusFunc=function(){var interval=collectorEchoMsg.get_interval();ajaxOpen({type:'get',dataType:'json',async:!0,url:ulink('admin/collector/echo_msg?op=status&collector_process=_cpkey_',{'_cpkey_':collectorProcess}),success:function(data){if(data.code==1){var statusList=data.data;if(isObject(statusList)){var pStatus=isObject(statusList.processes)?statusList.processes:{};$('#win_cem_process_nav').find('[data-collector-process]').each(function(){var cpkey=$(this).attr('data-collector-process');var pkey=cpkey?cpkey.split('-'):[];pkey=pkey[1]?pkey[1]:'';if(pkey&&!pStatus[pkey]){collectorEchoMsg.stop_process(cpkey);$(this).css('color','green')}});if(!statusList.main){endAll=!0;$('#myModal .modal-title').find('.loading-sm').remove()}}}},complete:function(){collectorEchoMsg.end_set_timeout=window.setTimeout(function(){var curKey=$('#win_cem_process_nav li.active').find('[data-collector-process]').attr('data-collector-process');if(collectorProcess==curKey){if(collectorEchoMsg.processes[collectorProcess].end){if(!endAll){statusFunc()}}}},interval*1000)}})};statusFunc()}},set_interval:function(num){ajaxOpen({type:'get',dataType:'json',async:!0,url:ulink('admin/collector/echo_msg?op=set_interval&interval=_num_',{'_num_':num}),success:function(data){ajaxDataMsg(data)}})},get_interval:function(){var interval=toInt(collectorEchoMsg.config.interval);interval=interval<=0?2:interval;return interval},stop_all:function(){var processes=collectorEchoMsg.processes;var cpKey='';if(processes){for(var key in processes){cpKey=key;collectorEchoMsg.stop_process(key)}}
if(collectorEchoMsg.end_set_timeout){window.clearTimeout(collectorEchoMsg.end_set_timeout)}
ajaxOpen({type:'get',url:ulink('admin/collector/echo_msg?op=stop&collector_process=_cpkey_',{'_cpkey_':cpKey}),dataType:'json',async:!0,success:function(data){}})},stop_process:function(collectorProcess){if(isObject(collectorEchoMsg.processes[collectorProcess])){collectorEchoMsg.processes[collectorProcess].end=1;if(collectorEchoMsg.processes[collectorProcess].read_ajax){collectorEchoMsg.processes[collectorProcess].read_ajax.abort()}
if(collectorEchoMsg.processes[collectorProcess].read_timeout){window.clearTimeout(collectorEchoMsg.processes[collectorProcess].read_timeout)}}},echo_url_msg:function(data){var fid='ifr_collectorEchoMsg_show_url_data';if(!document.getElementById(fid)){$('body').append('<form id="'+fid+'" action="'+ulink('collector/echo_url_msg')+'" method="post" target="_echo_url_msg" style="display:none;"><input type="text" name="_usertoken_" value="'+window.site_config.usertoken+'" /><textarea name="data"></textarea></form>')}
if(!isObject(data)){data={}}
data=JSON.stringify(data);$('#'+fid).find('[name="data"]').val(data);$('#'+fid).submit()},};var winBackstageTask={count:function(delay){delay=toInt(delay);var countFunc=function(){ajaxOpen({type:'get',dataType:'json',async:!0,url:ulink('admin/backstage/backstageTask?op=count'),success:function(data){if(data.code==1&&data.data){var count=toInt(data.data.count);count=count>0?count:'';$('#menu_backstage_task .label').text(count)}else{$('#menu_backstage_task .label').text('')}}})};if(delay>0){window.setTimeout(countFunc,delay)}else{countFunc()}},collected_set_timeout:null,init:function(){$('#win_backstage_task a[href^="#win_bk_tasks_nav_"]').bind('click',function(){var curTaskType=$($(this).attr('href')).attr('data-task-type');winBackstageTask.tasks(curTaskType)});$('#win_backstage_task a[href="#win_bk_tasks_nav_0"]').trigger('click');$('#myModal').on('hidden.bs.modal',function(e){winBackstageTask.count()})},tasks:function(taskType,url){$('#win_bk_tasks_nav_'+taskType).html('<div class="loading-sm"></div>');ajaxOpen({type:'get',dataType:'json',async:!0,url:(url?url:ulink('admin/backstage/backstageTask?op=tasks'+taskType)),success:function(data){if(data.code==1&&data.data){var count0=toInt(data.data.count0);var count1=toInt(data.data.count1);$('#win_backstage_task').find('a[href="#win_bk_tasks_nav_0"]').find('span').text(count0);$('#win_backstage_task').find('a[href="#win_bk_tasks_nav_1"]').find('span').text(count1);$('#win_backstage_task').find('a[href="#win_bk_tasks_nav_'+taskType+'"]').tab('show');$('#win_bk_tasks_nav_'+taskType).html(data.data.html)}else{$('#win_bk_tasks_nav_'+taskType).html('无任务')}
winBackstageTask.count();winBackstageTask.status()}})},init_tasks:function(taskType){taskType=toInt(taskType);$('#win_bk_tasks_box_'+(taskType==0?1:0)).html('');$('[id^="win_bk_tasks_box_"] a[data-parent^="#win_bk_tasks_box_"]').bind('click',function(){var curTaskId=$($(this).attr('href')).attr('data-task-id');var curTaskType=$(this).parents('[id^="win_bk_tasks_nav_"]').eq(0).attr('data-task-type');winBackstageTask.collected(curTaskId,curTaskType)});$('[id^="win_bk_tasks_box_"] .fa-remove').bind('click',function(){var obj=$(this);var curTaskId=$(this).attr('data-task-id');ajaxOpen({type:'get',dataType:'json',async:!0,url:ulink('admin/task/bkdelete?id='+curTaskId),success:function(data){obj.parents('.panel').remove();var spanObj=$('#win_backstage_task').find('a[href="#win_bk_tasks_nav_'+taskType+'"]').find('span');var spanCount=spanObj.text();spanCount=spanCount?parseInt(spanCount):0;spanCount=spanCount>0?(spanCount-1):0;spanObj.text(spanCount)}})});$('#win_bk_tasks_box_'+taskType+' .pagination').addClass('pagination-sm');$('#win_bk_tasks_box_'+taskType+' .pagination a').bind('click',function(){var curTaskType=$(this).parents('[id^="win_bk_tasks_nav_"]').eq(0).attr('data-task-type');winBackstageTask.tasks(curTaskType,$(this).attr('href'));return!1})},collected:function(taskId,taskType,url){if(winBackstageTask.collected_set_timeout){window.clearTimeout(winBackstageTask.collected_set_timeout)}
if(!url){url=ulink('admin/backstage/backstageTask?op=collected&tid='+taskId)}
ajaxOpen({type:'get',dataType:'html',async:!0,url:url,success:function(data){$('#win_bk_collected_'+taskId).html(data)},complete:function(){if(!isNull(taskType)&&0==toInt(taskType)){winBackstageTask.collected_set_timeout=window.setTimeout(function(){var isEnd=$('#win_bk_tasks_box_0').find('a[href="#win_bk_collected_'+taskId+'"]').attr('data-is-end');var isVisible=$('#win_bk_tasks_box_0 #win_bk_collected_'+taskId).is(':visible');if(!isEnd&&isVisible){winBackstageTask.collected(taskId,taskType,url)}else{window.clearTimeout(winBackstageTask.collected_set_timeout)}},3000)}}})},init_collected:function(taskStatus,taskId){$('[id^="win_bk_collected_"] .pagination').addClass('pagination-sm');$('[id^="win_bk_collected_"] .pagination a').bind('click',function(){var curTaskId=$(this).parents('[id^="win_bk_collected_"]').eq(0).attr('data-task-id');var curTaskType=$(this).parents('[id^="win_bk_tasks_nav_"]').eq(0).attr('data-task-type');winBackstageTask.collected(curTaskId,curTaskType,$(this).attr('href'));return!1});if(taskStatus&&taskId){winBackstageTask.set_task_end(taskId,taskStatus);winBackstageTask.count();winBackstageTask.status()}},set_task_end:function(taskId,status){if(taskId&&status){$('#win_bk_tasks_box_0').find('a[href="#win_bk_collected_'+taskId+'"]').attr('data-is-end','1').find('.is_loading').html('<small>'+status+'</small>')}},status_set_timeout:null,status:function(isLoop){if(!isLoop){window.clearTimeout(winBackstageTask.status_set_timeout)}
var taskIds=[];$('#win_bk_tasks_box_0').find('[id^="win_bk_collected_"]').each(function(){var taskId=$(this).attr('data-task-id');taskIds.push(taskId)});if(taskIds.length>0){ajaxOpen({type:'post',dataType:'json',async:!0,data:{tids:taskIds},url:ulink('admin/backstage/backstageTask?op=status'),success:function(data){var statusList=data.data;if(isObject(statusList)){for(var tid in statusList){if(statusList[tid]){winBackstageTask.set_task_end(tid,statusList[tid])}}}
var isVisible=$('#win_bk_tasks_box_0').is(':visible');var isEnd=!0;$('#win_bk_tasks_box_0').find('a[href^="#win_bk_collected_"]').each(function(){if(!$(this).attr('data-is-end')){isEnd=!1;return!1}});if(!isEnd&&isVisible){winBackstageTask.status_set_timeout=window.setTimeout(function(){winBackstageTask.status(!0)},3000)}else{window.clearTimeout(winBackstageTask.status_set_timeout)}}})}}};var ruleInsertSign={match:function(toObj,options){if(!options){options={}}
var sign=window.tpl_lang.sign_match;var group='(?<nr{:id}>[\\s\\S]*?)';if(options.only){sign=sign.replace('{:id}','');var curVal=$(toObj).val();if(curVal.indexOf(sign)<0&&curVal.indexOf('(?<nr>')<0&&curVal.indexOf('(?<content>')<0){if(options.group){sign=group.replace('{:id}','')}
globalOp.insertAtCaret($(toObj),sign)}else{toastr.error('存在'+sign+'或捕获组')}}else{var regSign=new RegExp(sign.replace('{:id}','(\\w*)').replace('[','\\[').replace(']','\\]'),'g');var regZimu=new RegExp("^([a-zA-Z]+)(\\d+)$",'i');var regP=new RegExp("\\(\\?<(?:content|nr)(\\w*)>",'g');var list=null;var max=0;var zm='';while((list=regSign.exec($(toObj).val()))!=null){var num=0;if(options.zimu){var zimu=regZimu.exec(list[1]);if(zimu){zm=zimu[1];num=parseInt(zimu[2])}}else{num=parseInt(list[1])}
if(num>max){max=num}}
list=null;while((list=regP.exec($(toObj).val()))!=null){var num=0;if(options.zimu){var zimu=regZimu.exec(list[1]);if(zimu){zm=zimu[1];num=parseInt(zimu[2])}}else{num=parseInt(list[1])}
if(num>max){max=num}}
if(options.group){sign=group}
var signId='';if(options.zimu){if(!zm){var ranNum=Math.ceil(Math.random()*25);zm=String.fromCharCode(('A').charCodeAt(0)+ranNum);ranNum=Math.ceil(Math.random()*25);zm+=String.fromCharCode(('a').charCodeAt(0)+ranNum)}
signId=zm+(max+1)}else{signId=max+1}
sign=sign.replace('{:id}',signId);globalOp.insertAtCaret($(toObj),sign)}},matchN:function(fromObj,toObj,options){if(!options){options={}}
var sign=window.tpl_lang.sign_match;var rule='';if(fromObj){rule=$(fromObj).val()}else if(options.rule){rule=options.rule}
var reP=new RegExp("\\(\\?<(?:content|nr)(\\w*)>.*?\\)",'g');rule=rule.replace(reP,sign.replace('{:id}',"$1"));var regSign=new RegExp(sign.replace('{:id}','(\\w*)').replace('[','\\[').replace(']','\\]'),'g');var list=null;var hasSign=!1;var returnList=new Array();while((list=regSign.exec(rule))!=null){hasSign=!0;var each=list[0];if(!toObj){returnList.push(each)}else if($(toObj).is('select')){if($(toObj).find('option[value="'+each+'"]').length<=0){$(toObj).append('<option value="'+each+'">'+each+'</option>')}}else{if($(toObj).val().indexOf(each)<0){globalOp.insertAtCaret($(toObj),each)}}}
if(!hasSign){if(options.def){sign=sign.replace('{:id}','');if(!toObj){returnList.push(sign)}else if($(toObj).is('select')){if($(toObj).find('option[value="'+sign+'"]').length<=0){$(toObj).append('<option value="'+sign+'">'+sign+'</option>')}}else{if($(toObj).val().indexOf(sign)<0){globalOp.insertAtCaret($(toObj),sign)}}}}
if(!toObj){return returnList}},wildcard:function(toObj,options){if(!options){options={}}
var wildcard=window.tpl_lang.sign_wildcard;if(options.only){if($(toObj).val().indexOf(wildcard)<0){globalOp.insertAtCaret($(toObj),wildcard)}}else{globalOp.insertAtCaret($(toObj),wildcard)}},tips:function(isPage,isPn){isPage=isPage==1?true:!1;isPn=isPn==1?true:!1;var tips='<p>1、规则中的特殊字符：<b>^$.*+|?[]{}()</b> 必须加上“\\”才能转义为字符，否则会识别为正则符号</p><p>2、[内容]标签的标识可由数字、字母及下划线组成</p>';if(isPage){if(isPn){tips+='<p>3、分页[内容]标签不可全局调用，只能在当前分页中调用</p>'}else{tips+='<p>3、页面级别：多级页 &gt; 多级页子页 &gt; 内容页 &gt; 关联页 &gt; 关联页子页</p>';tips+='<p>4、[内容]标签可全局调用，但只能调用比自己级别高的页面中的标签，即内容页可调用多级页中的标签而不能调用关联页中的标签</p>';tips+='<p>5、同一页面中有相同标识的[内容]标签时，后面的标签会覆盖前面的同名标签。不同页面中有相同标识的[内容]标签时，低级别页面会覆盖高级别页面中的同名标签</p>'}}
confirmRight({msg:tips,yes:'确定',width:500,textAlign:'left'})},tool_tips:function(){var tips='<p>规则中的特殊字符：<b>^$.*+|?[]{}()</b> 必须加上“\\”才能转义为字符，否则会识别为正则符号</p>';confirmRight({msg:tips,yes:'确定',width:500,textAlign:'left'})},cpDelimiterTips:function(){var tips='<p>如需使用换行符，请注意区别：</p><p>文本换行符：<b>\\r\\n</b>（适用于系统文件中）</p><p>标签换行符：<b>&lt;br /&gt;</b>（适用于网页HTML中）</p>';confirmRight({msg:tips,yes:'确定',width:350,textAlign:'left'})},cpRuleModuleInit:function(boxId,name,namePre){namePre=namePre?namePre:'';var isProcess=(name=='data-process')?true:!1;if(isProcess){$(boxId).on('change','[data-process="'+namePre+'rule_multi"]',function(){var prt=$(this).parents('.process-extract-module').eq(0);if($(this).is(':checked')){prt.find('.process-extract-rule-multi-str').show()}else{prt.find('.process-extract-rule-multi-str').hide()}});globalOp.inputSelectCustom(null,null,{box:boxId,slt:'[data-process="'+namePre+'xpath_attr"]',ipt:'[data-process="'+namePre+'xpath_attr_custom"]'});$(boxId).on('change','[data-process="'+namePre+'xpath_multi"]',function(){var prt=$(this).parents('.process-extract-module').eq(0);if($(this).is(':checked')){prt.find('.process-extract-xpath-multi-str').show()}else{prt.find('.process-extract-xpath-multi-str').hide()}});$(boxId).on('change','select[data-process="'+namePre+'json_arr"]',function(){var prt=$(this).parents('.process-extract-module').eq(0);if($(this).val()=='implode'){prt.find('.process-extract-json-arr-implode').show()}else{prt.find('.process-extract-json-arr-implode').hide()}});$(boxId).off('click','a[data-rule-sign]').on('click','a[data-rule-sign]',function(){var prt=$(this).parents('.process-extract-module').eq(0);var obj=prt.find('[data-process$="rule"]');var ruleSign=$(this).attr('data-rule-sign');if(ruleSign=='sign_wildcard'){ruleInsertSign.wildcard(obj)}else if(ruleSign=='sign_match'){ruleInsertSign.match(obj)}else if(ruleSign=='sign_group'){ruleInsertSign.match(obj,{group:1})}else if(ruleSign=='sign_match_n'){var ruleMerge=prt.find('[data-process$="rule_merge"]');ruleInsertSign.matchN(obj,ruleMerge,{def:1})}})}else{var idPre=' #c_p_'+name+'_'+namePre;idPre=idPre.replace(/[\[\]]/g,'_');$(boxId+' [name="'+name+'['+namePre+'rule_multi]"]').bind('change',function(){if($(this).is(':checked')){$(boxId+idPre+'rule_multi_str').show()}else{$(boxId+idPre+'rule_multi_str').hide()}});$(boxId+' [name="'+name+'['+namePre+'rule_multi_type]"]').bind('change',function(){if($(this).val()=='loop'){$(boxId+idPre+'rule_multi_str').find('.box-rule-multi-str').hide()}else{$(boxId+idPre+'rule_multi_str').find('.box-rule-multi-str').show()}});globalOp.inputSelectCustom(boxId+' select[name="'+name+'['+namePre+'xpath_attr]"]',name+'['+namePre+'xpath_attr_custom]');$(boxId+' [name="'+name+'['+namePre+'xpath_multi]"]').bind('change',function(){if($(this).is(':checked')){$(boxId+idPre+'xpath_multi_str').show()}else{$(boxId+idPre+'xpath_multi_str').hide()}});$(boxId+' [name="'+name+'['+namePre+'xpath_multi_type]"]').bind('change',function(){if($(this).val()=='loop'){$(boxId+idPre+'xpath_multi_str').find('.box-xpath-multi-str').hide()}else{$(boxId+idPre+'xpath_multi_str').find('.box-xpath-multi-str').show()}});$(boxId+' select[name="'+name+'['+namePre+'json_arr]"]').bind('change',function(){if($(this).val()=='implode'){$(boxId+idPre+'json_arr_implode').show()}else{$(boxId+idPre+'json_arr_implode').hide()}})}},cpRuleModuleLoad:function(boxId,name,namePre,config){namePre=namePre?namePre:'';if(isObject(config)){$(boxId+' [name="'+name+'['+namePre+'rule]"]').val(config[namePre+'rule']);$(boxId+' [name="'+name+'['+namePre+'rule_merge]"]').val(config[namePre+'rule_merge']);if(config[namePre+'rule_multi']){$(boxId+' [name="'+name+'['+namePre+'rule_multi]"]').prop('checked',!0).trigger('change')}
$(boxId+' [name="'+name+'['+namePre+'rule_multi_type]"]').val(config[namePre+'rule_multi_type']).trigger('click');$(boxId+' [name="'+name+'['+namePre+'rule_multi_str]"]').val(config[namePre+'rule_multi_str']);$(boxId+' [name="'+name+'['+namePre+'xpath]"]').val(config[namePre+'xpath']);$(boxId+' [name="'+name+'['+namePre+'xpath_attr]"]').val(config[namePre+'xpath_attr']).trigger('change');$(boxId+' [name="'+name+'['+namePre+'xpath_attr_custom]"]').val(config[namePre+'xpath_attr_custom']);if(config[namePre+'xpath_multi']){$(boxId+' [name="'+name+'['+namePre+'xpath_multi]"]').prop('checked',!0).trigger('change')}
$(boxId+' [name="'+name+'['+namePre+'xpath_multi_type]"]').val(config[namePre+'xpath_multi_type']).trigger('click');$(boxId+' [name="'+name+'['+namePre+'xpath_multi_str]"]').val(config[namePre+'xpath_multi_str']);$(boxId+' [name="'+name+'['+namePre+'json]"]').val(config[namePre+'json']);if(config[namePre+'json_loop']){$(boxId+' [name="'+name+'['+namePre+'json_loop]"]').prop('checked',!0)}
if(config[namePre+'json_arr']){$(boxId+' [name="'+name+'['+namePre+'json_arr]"]').val(config[namePre+'json_arr']).trigger('change')}
$(boxId+' [name="'+name+'['+namePre+'json_arr_implode]"]').val(config[namePre+'json_arr_implode'])}}}