@ -8,9 +8,9 @@
| -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
* /
'use strict' ; function CollectorPattern ( ) { this . formid = '#form_coll' ; this . cpFrontUrl = null ; this . cpLevelUrl = null ; this . cpRelationUrl = null ; this . cpUrlWeb = null ; this . cpRenderer = null ; this . cpContentSign = null ; this . cpPagination = null ; this . cpField = null ; this . cpProcess = null }
CollectorPattern . prototype = { constructor : CollectorPattern , init _test : function ( ) { var $ _o = this ; $ _o . formid = '#win_form_cache' ; $ _o . cpUrlWeb = new CpUrlWeb ( $ _o ) ; $ _o . cpRenderer = new CpRenderer ( $ _o ) ; $ _o . cpUrlWeb . page _init ( 'test' ) ; $ _o . cpRenderer . page _init ( 'test' ) } , init : function ( ) { var $ _o = this ; $ ( $ _o . formid ) . bind ( 'submit' , function ( ) { $ ( '#coll_tab_content' ) . find ( '.tab-pane[id^="coll_pattern_"]' ) . each ( function ( ) { if ( $ ( this ) . hasClass ( 'active' ) ) { $ ( $ _o . formid + ' [name="tab_link"]' ) . val ( $ ( this ) . attr ( 'id' ) ) ; return } } ) ; var settings = getFormAjaxSettings ( $ ( this ) ) ; ajaxOpen ( settings ) ; return ! 1 } ) ; $ _o . cpFrontUrl = new CpFrontUrl ( $ _o ) ; $ _o . cpLevelUrl = new CpLevelUrl ( $ _o ) ; $ _o . cpRelationUrl = new CpRelationUrl ( $ _o ) ; $ _o . cpUrlWeb = new CpUrlWeb ( $ _o ) ; $ _o . cpRenderer = new CpRenderer ( $ _o ) ; $ _o . cpContentSign = new CpContentSign ( $ _o ) ; $ _o . cpPagination = new CpPagination ( $ _o ) ; $ _o . cpField = new CpField ( $ _o ) ; $ _o . cpProcess = new CpProcess ( $ _o ) ; inputSelectCustom ( $ _o . formid + ' select[name="config[charset]"]' , 'config[charset_custom]' , null , null , function ( ) { $ _o . cpUrlWeb . def _config _charset ( '' ) } ) ; inputSelectCustom ( $ _o . formid + ' select[name="config[encode]"]' , 'config[encode_custom]' , null , null , function ( ) { $ _o . cpUrlWeb . def _config _encode ( '' ) } ) ; $ ( $ _o . formid + ' [name="config[page_render]"]' ) . bind ( 'click' , function ( ) { $ _o . cpRenderer . def _config _renderer _open ( '' ) } ) ; $ ( $ _o . formid + ' [name="config[request_headers][open]"]' ) . bind ( 'click' , function ( ) { $ _o . cpUrlWeb . def _config _header _global ( '' ) } ) ; $ ( $ _o . formid + ' #coll_pattern_request_headers .dm-useragent li a' ) . bind ( 'click' , function ( ) { $ ( $ _o . formid + ' [name="config[request_headers][useragent]"]' ) . val ( $ ( this ) . attr ( 'data-useragent' ) ) } ) ; $ ( $ _o . formid + ' #coll_pattern_request_headers .add-request-header' ) . bind ( 'click' , function ( ) { $ _o . add _request _header ( '' , '' ) } ) ; $ ( $ _o . formid + ' #coll_pattern_request_headers .add-request-header-img' ) . bind ( 'click' , function ( ) { $ _o . add _request _header _img ( '' , '' ) } ) ; $ ( $ _o . formid + ' .c-p-request-headers' ) . on ( 'click' , '.delete-request-header' , function ( ) { $ ( this ) . parents ( 'tr' ) . eq ( 0 ) . remove ( ) } ) ; $ ( $ _o . formid + ' .c-p-request-headers-img' ) . on ( 'click' , '.delete-request-header-img' , function ( ) { $ ( this ) . parents ( 'tr' ) . eq ( 0 ) . remove ( ) } ) ; $ _o . init _page _list _op ( 'front_url' ) ; $ ( this . formid + ' #coll_pattern_source_url .add-source-url' ) . bind ( 'click' , function ( ) { windowModal ( '添加起始网址' , ulink ( "cpattern/source" ) , { lg : 1 } ) } ) ; $ ( this . formid + ' #coll_pattern_source_url .clear-source-url' ) . bind ( 'click' , function ( ) { $ _o . source _op ( 'clear_all' ) } ) ; $ ( this . formid + ' #coll_pattern_source_url' ) . on ( 'click' , '.edit-source-url' , function ( ) { var parent = $ ( this ) . parents ( '[id^="source_url_"]' ) . eq ( 0 ) ; var objid = parent . attr ( 'id' ) ; var sourceUrl = parent . find ( '[name="config[source_url][]"]' ) . val ( ) ; sourceUrl = sourceUrl ? sourceUrl : '' ; var url = ulink ( "cpattern/source" ) ; var options = { lg : 1 } ; if ( objid || sourceUrl ) { options . ajax = { type : 'post' , data : { 'source_url' : sourceUrl , 'objid' : objid } } }
CollectorPattern . prototype = { constructor : CollectorPattern , init _test : function ( ) { var $ _o = this ; $ _o . formid = '#win_form_cache' ; $ _o . cpUrlWeb = new CpUrlWeb ( $ _o ) ; $ _o . cpRenderer = new CpRenderer ( $ _o ) ; $ _o . cpUrlWeb . page _init ( 'test' ) ; $ _o . cpRenderer . page _init ( 'test' ) } , init : function ( ) { var $ _o = this ; $ ( $ _o . formid ) . bind ( 'submit' , function ( ) { $ ( '#coll_tab_content' ) . find ( '.tab-pane[id^="coll_pattern_"]' ) . each ( function ( ) { if ( $ ( this ) . hasClass ( 'active' ) ) { $ ( $ _o . formid + ' [name="tab_link"]' ) . val ( $ ( this ) . attr ( 'id' ) ) ; return } } ) ; var settings = getFormAjaxSettings ( $ ( this ) ) ; ajaxOpen ( settings ) ; return ! 1 } ) ; $ _o . cpFrontUrl = new CpFrontUrl ( $ _o ) ; $ _o . cpLevelUrl = new CpLevelUrl ( $ _o ) ; $ _o . cpRelationUrl = new CpRelationUrl ( $ _o ) ; $ _o . cpUrlWeb = new CpUrlWeb ( $ _o ) ; $ _o . cpRenderer = new CpRenderer ( $ _o ) ; $ _o . cpContentSign = new CpContentSign ( $ _o ) ; $ _o . cpPagination = new CpPagination ( $ _o ) ; $ _o . cpField = new CpField ( $ _o ) ; $ _o . cpProcess = new CpProcess ( $ _o ) ; inputSelectCustom ( $ _o . formid + ' select[name="config[charset]"]' , 'config[charset_custom]' , null , null , function ( ) { $ _o . cpUrlWeb . def _config _charset ( '' ) } ) ; inputSelectCustom ( $ _o . formid + ' select[name="config[encode]"]' , 'config[encode_custom]' , null , null , function ( ) { $ _o . cpUrlWeb . def _config _encode ( '' ) } ) ; $ ( $ _o . formid + ' [name="config[page_render]"]' ) . bind ( 'click' , function ( ) { $ _o . cpRenderer . def _config _renderer _open ( '' ) } ) ; $ ( $ _o . formid + ' [name="config[request_headers][open]"]' ) . bind ( 'click' , function ( ) { $ _o . cpUrlWeb . def _config _header _global ( '' ) } ) ; $ ( $ _o . formid + ' #coll_pattern_request_headers .dm-useragent li a' ) . bind ( 'click' , function ( ) { $ ( $ _o . formid + ' [name="config[request_headers][useragent]"]' ) . val ( $ ( this ) . attr ( 'data-useragent' ) ) } ) ; $ ( $ _o . formid + ' #coll_pattern_request_headers .add-request-header' ) . bind ( 'click' , function ( ) { $ _o . add _request _header ( '' , '' ) } ) ; $ ( $ _o . formid + ' #coll_pattern_request_headers .add-request-header-img' ) . bind ( 'click' , function ( ) { $ _o . add _request _header _img ( '' , '' ) } ) ; $ ( $ _o . formid + ' #coll_pattern_request_headers .add-request-header-file' ) . bind ( 'click' , function ( ) { $ _o . add _request _header _file ( '' , '' ) } ) ; $ ( $ _o . formid + ' .c-p-request-headers' ) . on ( 'click' , '.delete-request-header' , function ( ) { $ ( this ) . parents ( 'tr' ) . eq ( 0 ) . remove ( ) } ) ; $ ( $ _o . formid + ' .c-p-request-headers-img' ) . on ( 'click' , '.delete-request-header-img' , function ( ) { $ ( this ) . parents ( 'tr' ) . eq ( 0 ) . remove ( ) } ) ; $ ( $ _o . formid + ' .c-p-request-headers-file' ) . on ( 'click' , '.delete-request-header-file ' , function ( ) { $ ( this ) . parents ( 'tr' ) . eq ( 0 ) . remove ( ) } ) ; $ _o . init _page _list _op ( 'front_url' ) ; $ ( this . formid + ' #coll_pattern_source_url .add-source-url' ) . bind ( 'click' , function ( ) { windowModal ( '添加起始网址' , ulink ( "cpattern/source" ) , { lg : 1 } ) } ) ; $ ( this . formid + ' #coll_pattern_source_url .clear-source-url' ) . bind ( 'click' , function ( ) { $ _o . source _op ( 'clear_all' ) } ) ; $ ( this . formid + ' #coll_pattern_source_url' ) . on ( 'click' , '.edit-source-url' , function ( ) { var parent = $ ( this ) . parents ( '[id^="source_url_"]' ) . eq ( 0 ) ; var objid = parent . attr ( 'id' ) ; var sourceUrl = parent . find ( '[name="config[source_url][]"]' ) . val ( ) ; sourceUrl = sourceUrl ? sourceUrl : '' ; var url = ulink ( "cpattern/source" ) ; var options = { lg : 1 } ; if ( objid || sourceUrl ) { options . ajax = { type : 'post' , data : { 'source_url' : sourceUrl , 'objid' : objid } } }
windowModal ( '添加起始网址' , url , options ) } ) ; $ ( this . formid + ' #coll_pattern_source_url' ) . on ( 'click' , '.delete-source-url' , function ( ) { var obj = $ ( this ) ; confirmRight ( window . tpl _lang . confirm _delete , function ( ) { obj . parents ( '[id^="source_url_"]' ) . eq ( 0 ) . remove ( ) } ) } ) ; eleExchange ( this . formid + ' #coll_pattern_source_url' , '.icon-drag-move' , '[id^="source_url_"]' ) ; $ ( this . formid + ' [name="config[source_is_url]"]' ) . bind ( 'click' , function ( ) { if ( $ _o . source _is _url ( ) ) { $ ( '#alert_coll_pattern_link' ) . show ( ) ; $ ( '#panel_coll_pattern_source_url_web' ) . hide ( ) ; $ ( '#panel_coll_pattern_source_url_renderer' ) . hide ( ) ; $ ( '#panel_coll_pattern_source_url_content_sign' ) . hide ( ) ; $ ( '#panel_coll_pattern_source_url_pagination' ) . hide ( ) ; $ ( '#panel_coll_pattern_level_url' ) . hide ( ) ; $ ( '#panel_coll_pattern_url_content_sign' ) . siblings ( '.panel' ) . hide ( ) ; $ ( '#panel_coll_pattern_url_web' ) . show ( ) ; $ ( '#panel_coll_pattern_url_renderer' ) . show ( ) } else { $ ( '#alert_coll_pattern_link' ) . hide ( ) ; $ ( '#panel_coll_pattern_source_url_web' ) . show ( ) ; $ ( '#panel_coll_pattern_source_url_renderer' ) . show ( ) ; $ ( '#panel_coll_pattern_source_url_content_sign' ) . show ( ) ; $ ( '#panel_coll_pattern_source_url_pagination' ) . show ( ) ; $ ( '#panel_coll_pattern_level_url' ) . show ( ) ; $ ( '#panel_coll_pattern_url_content_sign' ) . siblings ( '.panel' ) . show ( ) } } ) ; $ _o . init _page ( 'source_url' ) ; $ _o . init _page ( 'url' ) ; $ ( $ _o . formid ) . on ( 'click' , '.c-p-url-page-signs .btn-page-signs' , function ( ) { $ _o . parent _page _signs ( this ) } ) ; $ _o . init _page _list _op ( 'level_url' ) ; $ _o . init _page _list _op ( 'relation_url' ) ; $ ( this . formid + ' #coll_pattern_field' ) . on ( 'click' , '.add-field' , function ( ) { $ _o . field _editor ( null , null ) } ) ; $ ( this . formid + ' #coll_pattern_field' ) . on ( 'click' , '.field-name' , function ( ) { $ _o . field _editor ( $ ( this ) , null ) } ) ; $ ( this . formid + ' #coll_pattern_field' ) . on ( 'click' , '.add-field-default' , function ( ) { $ _o . cpField . add _default ( ) } ) ; $ ( this . formid + ' #coll_pattern_field' ) . on ( 'click' , '.sort-field' , function ( ) { var fieldNames = $ _o . get _field _names ( ! 0 ) ; for ( var i in fieldNames ) { var fieldTr = $ ( $ _o . formid + ' #coll_pattern_field' ) . find ( '.field-name[data-val="' + fieldNames [ i ] + '"]' ) . parents ( 'tr[id^="field_"]' ) . eq ( 0 ) ; if ( fieldTr . length > 0 ) { $ ( $ _o . formid + ' #coll_pattern_field .c-p-field-list tbody' ) . append ( fieldTr ) } }
toastr . success ( '调整完成' ) } ) ; $ ( this . formid + ' #coll_pattern_field' ) . on ( 'click' , '.field-del' , function ( ) { var obj = $ ( this ) ; confirmRight ( window . tpl _lang . confirm _delete , function ( ) { $ _o . field _delete _tr ( obj ) } ) } ) ; $ ( this . formid + ' #coll_pattern_field' ) . on ( 'click' , '.field-clone' , function ( ) { var tr = $ ( this ) . parents ( 'tr[id^="field_"]' ) . eq ( 0 ) ; var field = tr . find ( '[name="config[field_list][]"]' ) . val ( ) ; var process = tr . find ( '[name="config[field_process][]"]' ) . val ( ) ; confirmRight ( '确定复制字段?' , function ( ) { ajaxOpen ( { type : 'POST' , dataType : 'json' , url : ulink ( "cpattern/clone_field" ) , data : { field : field , process : process } , success : function ( data ) { if ( data . code == 1 ) { data = data . data ; var hasField = ! 1 ; do { data . field . name += '_1' ; hasField = $ ( '#coll_pattern_field .c-p-field-list' ) . find ( '.field-name[data-val="' + data . field . name + '"]' ) ; if ( hasField && hasField . length > 0 ) { hasField = ! 0 } else { hasField = ! 1 } } while ( hasField ) ; $ _o . cpField . add ( null , data . field , data . process ) ; toastr . success ( '字段复制成功:' + data . field . name ) } else { toastr . error ( data . msg ) } } } ) } ) } ) ; $ ( this . formid + ' #coll_pattern_field' ) . on ( 'click' , '.field-process' , function ( ) { var process = $ ( this ) . parent ( ) . find ( 'input[name="config[field_process][]"]' ) . val ( ) ; var prt = $ ( this ) . parents ( 'tr[id^="field_"]' ) . eq ( 0 ) ; var objid = prt . attr ( 'id' ) ; var field = prt . find ( '.field-name' ) . attr ( 'data-val' ) ; var url = ulink ( "cpattern/process?field=_field_" , { '_field_' : field } ) ; windowModal ( '数据处理:' + field + '<small><a href="javascript:;" id="window_process_paste" title="粘贴" class="glyphicon glyphicon-paste" style="margin-left:7px;color:#888;"></a></small>' , url , { lg : 1 , ajax : { type : 'post' , data : { objid : objid , process : process } } } ) ; $ _o . process _paste ( ) } ) ; $ ( this . formid + ' #coll_pattern_process' ) . on ( 'click' , '.add-process' , function ( ) { var url = ulink ( "cpattern/process?type=common" ) ; windowModal ( '数据处理(通用)<small><a href="javascript:;" id="window_process_paste" title="粘贴" class="glyphicon glyphicon-paste" style="color:#888;"></a></small>' , url , { lg : 1 } ) ; $ _o . process _paste ( ) } ) ; eleExchange ( this . formid + ' #coll_pattern_field' , '.icon-drag-move' , 'tr[id^="field_"]' ) ; $ ( this . formid + ' [name="effective"]' ) . val ( 1 ) } , load : function ( config ) { var $ _o = this ; if ( config ) { $ ( this . formid + ' [name="config[charset_custom]"]' ) . val ( config . charset _custom ) ; $ ( this . formid + ' [name="config[charset]"]' ) . val ( config . charset ) . trigger ( 'change' ) ; $ ( this . formid + ' [name="config[encode_custom]"]' ) . val ( config . encode _custom ) ; $ ( this . formid + ' [name="config[encode]"]' ) . val ( config . encode ) . trigger ( 'change' ) ; $ ( this . formid + ' [name="config[url_complete]"][value="' + toInt ( config . url _complete ) + '"]' ) . prop ( 'checked' , ! 0 ) ; $ ( this . formid + ' [name="config[url_reverse]"][value="' + toInt ( config . url _reverse ) + '"]' ) . prop ( 'checked' , ! 0 ) ; $ ( this . formid + ' [name="config[page_render]"][value="' + toInt ( config . page _render ) + '"]' ) . prop ( 'checked' , ! 0 ) . trigger ( 'click' ) ; $ ( this . formid + ' [name="config[url_repeat]"][value="' + toInt ( config . url _repeat ) + '"]' ) . prop ( 'checked' , ! 0 ) ; $ ( this . formid + ' [name="config[url_no_name]"][value="' + toInt ( config . url _no _name ) + '"]' ) . prop ( 'checked' , ! 0 ) ; if ( config . regexp _flags ) { for ( var i in config . regexp _flags ) { $ ( this . formid ) . find ( '[name="config[regexp_flags][]"][value="' + config . regexp _flags [ i ] + '"]' ) . prop ( 'checked' , ! 0 ) } }
toastr . success ( '调整完成' ) } ) ; $ ( this . formid + ' #coll_pattern_field' ) . on ( 'click' , '.field-del' , function ( ) { var obj = $ ( this ) ; confirmRight ( window . tpl _lang . confirm _delete , function ( ) { $ _o . field _delete _tr ( obj ) } ) } ) ; $ ( this . formid + ' #coll_pattern_field' ) . on ( 'click' , '.field-clone' , function ( ) { var tr = $ ( this ) . parents ( 'tr[id^="field_"]' ) . eq ( 0 ) ; var field = tr . find ( '[name="config[field_list][]"]' ) . val ( ) ; var process = tr . find ( '[name="config[field_process][]"]' ) . val ( ) ; confirmRight ( '确定复制字段?' , function ( ) { ajaxOpen ( { type : 'POST' , dataType : 'json' , url : ulink ( "cpattern/clone_field" ) , data : { field : field , process : process } , success : function ( data ) { if ( data . code == 1 ) { data = data . data ; var hasField = ! 1 ; do { data . field . name += '_1' ; hasField = $ ( '#coll_pattern_field .c-p-field-list' ) . find ( '.field-name[data-val="' + data . field . name + '"]' ) ; if ( hasField && hasField . length > 0 ) { hasField = ! 0 } else { hasField = ! 1 } } while ( hasField ) ; $ _o . cpField . add ( null , data . field , data . process ) ; toastr . success ( '字段复制成功:' + data . field . name ) } else { toastr . error ( data . msg ) } } } ) } ) } ) ; $ ( this . formid + ' #coll_pattern_field' ) . on ( 'click' , '.field-process' , function ( ) { var process = $ ( this ) . parent ( ) . find ( 'input[name="config[field_process][]"]' ) . val ( ) ; var prt = $ ( this ) . parents ( 'tr[id^="field_"]' ) . eq ( 0 ) ; var objid = prt . attr ( 'id' ) ; var field = prt . find ( '.field-name' ) . attr ( 'data-val' ) ; var url = ulink ( "cpattern/process?task_id=_tid_& field=_field_" , { '_tid_' : $ _o . get _task _id ( ) , '_field_' : field } ) ; windowModal ( '数据处理:' + field + '<small><a href="javascript:;" id="window_process_paste" title="粘贴" class="glyphicon glyphicon-paste" style="margin-left:7px;color:#888;"></a></small>' , url , { lg : 1 , ajax : { type : 'post' , data : { objid : objid , process : process } } } ) ; $ _o . process _paste ( ) } ) ; $ ( this . formid + ' #coll_pattern_process' ) . on ( 'click' , '.add-process' , function ( ) { var url = ulink ( "cpattern/process?task_id=_tid_&t ype=common" , { '_tid_' : $ _o . get _task _id ( ) } ) ; windowModal ( '数据处理(通用)<small><a href="javascript:;" id="window_process_paste" title="粘贴" class="glyphicon glyphicon-paste" style="color:#888;"></a></small>' , url , { lg : 1 } ) ; $ _o . process _paste ( ) } ) ; eleExchange ( this . formid + ' #coll_pattern_field' , '.icon-drag-move' , 'tr[id^="field_"]' ) ; $ ( this . formid + ' [name="effective"]' ) . val ( 1 ) } , load : function ( config ) { var $ _o = this ; if ( config ) { $ ( this . formid + ' [name="config[charset_custom]"]' ) . val ( config . charset _custom ) ; $ ( this . formid + ' [name="config[charset]"]' ) . val ( config . charset ) . trigger ( 'change' ) ; $ ( this . formid + ' [name="config[encode_custom]"]' ) . val ( config . encode _custom ) ; $ ( this . formid + ' [name="config[encode]"]' ) . val ( config . encode ) . trigger ( 'change' ) ; $ ( this . formid + ' [name="config[url_complete]"][value="' + toInt ( config . url _complete ) + '"]' ) . prop ( 'checked' , ! 0 ) ; $ ( this . formid + ' [name="config[url_reverse]"][value="' + toInt ( config . url _reverse ) + '"]' ) . prop ( 'checked' , ! 0 ) ; $ ( this . formid + ' [name="config[page_render]"][value="' + toInt ( config . page _render ) + '"]' ) . prop ( 'checked' , ! 0 ) . trigger ( 'click' ) ; $ ( this . formid + ' [name="config[url_repeat]"][value="' + toInt ( config . url _repeat ) + '"]' ) . prop ( 'checked' , ! 0 ) ; $ ( this . formid + ' [name="config[url_no_name]"][value="' + toInt ( config . url _no _name ) + '"]' ) . prop ( 'checked' , ! 0 ) ; $ ( this . formid + ' [name="config[url_encode]"][value="' + toInt ( config . url _encod e ) + '"]' ) . prop ( 'checked' , ! 0 ) ; if ( config . regexp _flags ) { for ( var i in config . regexp _flags ) { $ ( this . formid ) . find ( '[name="config[regexp_flags][]"][value="' + config . regexp _flags [ i ] + '"]' ) . prop ( 'checked' , ! 0 ) } }
if ( isObject ( config . front _urls ) ) { for ( var i in config . front _urls ) { $ _o . cpFrontUrl . add ( null , config . front _urls [ i ] ) }
showPanelCollapse ( '#coll_pattern_front_url' ) }
if ( config . source _url ) { var source _url _html _list = '' ; var sourceParams = { get : 1 } ; for ( var i in config . source _url ) { sourceParams . source _url = config . source _url [ i ] ; source _url _html _list += this . source _op ( 'add' , sourceParams ) }
@ -24,11 +24,13 @@ showPanelCollapse('#coll_pattern_relation_url')}
if ( config . field _list && config . field _list . length > 0 ) { this . cpField . clearall ( ) ; for ( var i in config . field _list ) { var fieldProcess = null ; if ( config . field _process ) { fieldProcess = config . field _process [ i ] }
this . cpField . add ( null , config . field _list [ i ] , fieldProcess ) } }
if ( config . field _title ) { $ ( this . formid + ' [name="config[field_title]"]' ) . each ( function ( ) { if ( $ ( this ) . val ( ) == config . field _title ) { $ ( this ) . prop ( 'checked' , ! 0 ) } } ) }
if ( config . common _process && config . common _process . length > 0 ) { showPanelCollapse ( '#coll_pattern_process' ) ; ajaxOpen ( { type : 'post' , url : ulink ( "cpattern/process?type=common&op=load" ) , data : { process : config . common _process } , dataType : 'html' , beforeSend : function ( ) { $ ( $ _o . cpProcess . processForm + ' .c-p-process-accordion' ) . append ( '<div class="loading" style="margin:5px 0 0 -5px;"></div>' ) } , success : function ( data ) { $ ( 'body' ) . append ( data ) } , complete : function ( ) { $ ( $ _o . cpProcess . processForm + ' .c-p-process-accordion' ) . find ( '.loading' ) . remove ( ) } } ) }
if ( config . common _process && config . common _process . length > 0 ) { showPanelCollapse ( '#coll_pattern_process' ) ; ajaxOpen ( { type : 'post' , url : ulink ( "cpattern/process?task_id=_tid_&t ype=common&op=load" , { '_tid_' : $ _o . get _task _id ( ) } ) , data : { process : config . common _process } , dataType : 'html' , beforeSend : function ( ) { $ ( $ _o . cpProcess . processForm + ' .c-p-process-accordion' ) . append ( '<div class="loading" style="margin:5px 0 0 -5px;"></div>' ) } , success : function ( data ) { $ ( 'body' ) . append ( data ) } , complete : function ( ) { $ ( $ _o . cpProcess . processForm + ' .c-p-process-accordion' ) . find ( '.loading' ) . remove ( ) } } ) }
if ( config . request _headers ) { $ ( this . formid + ' [name="config[request_headers][useragent]"]' ) . val ( config . request _headers . useragent ) ; $ ( this . formid + ' [name="config[request_headers][cookie]"]' ) . val ( config . request _headers . cookie ) ; $ ( this . formid + ' [name="config[request_headers][referer]"]' ) . val ( config . request _headers . referer ) ; if ( config . request _headers . custom _names ) { var r _h _vals = config . request _headers . custom _vals ? config . request _headers . custom _vals : { } ; for ( var i in config . request _headers . custom _names ) { $ _o . add _request _header ( config . request _headers . custom _names [ i ] , r _h _vals [ i ] ) } }
config . request _headers . open = toInt ( config . request _headers . open ) ; config . request _headers . img = toInt ( config . request _headers . img ) ; $ ( this . formid + ' [name="config[request_headers][open]"][value="' + config . request _headers . open + '"]' ) . prop ( 'checked' , ! 0 ) . trigger ( 'click' ) ; $ ( this . formid + ' [name="config[request_headers][img]"][value="' + config . request _headers . img + '"]' ) . prop ( 'checked' , ! 0 ) ; $ ( this . formid + ' [name="config[request_headers][img_use_page]"][value="' + config . request _headers . img _use _page + '"]' ) . prop ( 'checked' , ! 0 ) ; if ( config . request _headers . open > 0 ) { showPanelCollapse ( '#coll_pattern_request_headers' ) ; showPanelCollapse ( '#c_p_request_headers_open' ) }
config . request _headers . open = toInt ( config . request _headers . open ) ; config . request _headers . img = toInt ( config . request _headers . img ) ; config . request _headers . file = toInt ( config . request _headers . file ) ; $ ( this . formid + ' [name="config[request_headers][open]"][value="' + config . request _headers . open + '"]' ) . prop ( 'checked' , ! 0 ) . trigger ( 'click' ) ; $ ( this . formid + ' [name="config[request_headers][img]"][value="' + config . request _headers . img + '"]' ) . prop ( 'checked' , ! 0 ) ; $ ( this . formid + ' [name="config[request_headers][img_use_page]"][value="' + config . request _headers . img _use _page + '"]' ) . prop ( 'checked' , ! 0 ) ; $ ( this . formid + ' [name="config[request_headers][file]"][value="' + config . request _headers . file + '"]' ) . prop ( 'checked' , ! 0 ) ; $ ( this . formid + ' [name="config[request_headers][file_use_page]"][value="' + config . request _headers . file _use _page + '"]' ) . prop ( 'checked' , ! 0 ) ; if ( config . request _headers . open > 0 ) { showPanelCollapse ( '#coll_pattern_request_headers' ) ; showPanelCollapse ( '#c_p_request_headers_open' ) }
if ( config . request _headers . img > 0 ) { showPanelCollapse ( '#coll_pattern_request_headers' ) ; showPanelCollapse ( '#c_p_request_headers_img' ) }
if ( config . request _headers . img _names ) { var r _h _img _vals = config . request _headers . img _vals ? config . request _headers . img _vals : { } ; for ( var i in config . request _headers . img _names ) { $ _o . add _request _header _img ( config . request _headers . img _names [ i ] , r _h _img _vals [ i ] ) } } } }
if ( config . request _headers . img _names ) { var r _h _img _vals = config . request _headers . img _vals ? config . request _headers . img _vals : { } ; for ( var i in config . request _headers . img _names ) { $ _o . add _request _header _img ( config . request _headers . img _names [ i ] , r _h _img _vals [ i ] ) } }
if ( config . request _headers . file > 0 ) { showPanelCollapse ( '#coll_pattern_request_headers' ) ; showPanelCollapse ( '#c_p_request_headers_file' ) }
if ( config . request _headers . file _names ) { var r _h _file _vals = config . request _headers . file _vals ? config . request _headers . file _vals : { } ; for ( var i in config . request _headers . file _names ) { $ _o . add _request _header _file ( config . request _headers . file _names [ i ] , r _h _file _vals [ i ] ) } } } }
$ ( this . formid + ' [name="effective_edit"]' ) . val ( 1 ) } , get _page _vars : function ( pageType , returnKey ) { var title = '' ; var boxId = '' ; var namePre = '' ; var formId = '' ; if ( 'front_url' == pageType ) { title = '前置页' ; boxId = '#c_p_front_url' ; namePre = 'front_url' ; formId = this . cpFrontUrl . formObj } else if ( 'source_url' == pageType ) { title = '起始页' ; boxId = '#coll_pattern_source_url' ; namePre = 'config[source_config]' ; formId = this . formid } else if ( 'level_url' == pageType ) { title = '多级页' ; boxId = '#c_p_level_url' ; namePre = 'level_url' ; formId = this . cpLevelUrl . formObj } else if ( 'relation_url' == pageType ) { title = '关联页' ; boxId = '#c_p_relation_url' ; namePre = 'relation_url' ; formId = this . cpRelationUrl . formObj } else if ( 'url' == pageType ) { title = '内容页' ; boxId = '#coll_pattern_url' ; namePre = 'config' ; formId = this . formid } else if ( 'test' == pageType ) { title = '' ; boxId = '#win_coll_pattern_test' ; namePre = 'config' ; formId = '#win_form_test' }
var data = { title : title , boxId : boxId , namePre : namePre , formId : formId } ; if ( returnKey ) { return data [ returnKey ] } else { return data } } , page _is _list : function ( pageType ) { if ( pageType == 'front_url' || pageType == 'level_url' || pageType == 'relation_url' ) { return ! 0 } else { return ! 1 } } , init _page _list _op : function ( pageType ) { var $ _o = this ; if ( ! $ _o . page _is _list ( pageType ) ) { return }
var pageVars = $ _o . get _page _vars ( pageType ) ; var listObj = '#c_p_' + pageType + 's' ; var parentObj = '[id^="' + pageType + '_"]' ; $ ( $ _o . formid + ' #coll_pattern_' + pageType + ' .add-' + pageType . replace ( '_' , '-' ) ) . bind ( 'click' , function ( ) { var url = ulink ( 'cpattern/' + pageType ) ; windowModal ( '添加' + pageVars . title + '规则' , url , { lg : 1 } ) } ) ; $ ( $ _o . formid + ' ' + listObj ) . on ( 'click' , '.name' , function ( ) { var parent = $ ( this ) . parents ( parentObj ) . eq ( 0 ) ; var options = { lg : 1 , ajax : { type : 'post' , data : { } } } ; options . ajax . data . objid = parent . attr ( 'id' ) ; options . ajax . data [ pageType ] = parent . find ( '[name="config[' + pageType + 's][]"]' ) . val ( ) ; windowModal ( '编辑' + pageVars . title + '规则' , ulink ( 'cpattern/' + pageType ) , options ) } ) ; $ ( $ _o . formid + ' ' + listObj ) . on ( 'click' , '.clone' , function ( ) { var parent = $ ( this ) . parents ( parentObj ) . eq ( 0 ) ; var pageConfig = parent . find ( '[name="config[' + pageType + 's][]"]' ) . val ( ) ; var postData = { } ; postData [ pageType ] = pageConfig ; confirmRight ( '确定复制' + pageVars . title + '?' , function ( ) { ajaxOpen ( { type : 'POST' , dataType : 'json' , url : ulink ( 'cpattern/clone_' + pageType ) , data : postData , success : function ( data ) { if ( data . code == 1 ) { data = data . data ; var hasName = ! 1 ; do { data [ pageType ] . name += '_1' ; hasName = $ ( $ _o . formid + ' ' + listObj ) . find ( '.name[data-val="' + data [ pageType ] . name + '"]' ) ; if ( hasName && hasName . length > 0 ) { hasName = ! 0 } else { hasName = ! 1 } } while ( hasName ) ; if ( pageType == 'front_url' ) { $ _o . cpFrontUrl . add ( null , data [ pageType ] ) } else if ( pageType == 'level_url' ) { $ _o . cpLevelUrl . add ( null , data [ pageType ] ) } else if ( pageType == 'relation_url' ) { $ _o . cpRelationUrl . add ( null , data [ pageType ] ) }
@ -55,14 +57,14 @@ $('#myModal').modal('hide')}}else{toastr.error(data.msg)}},error:function(data){
if ( ! $ _o . source _is _url ( ) ) { options += '<option value="source_url">起始页</option>' ; var level _urls = new Array ( ) ; $ ( '#c_p_level_urls [id^="level_url_"]' ) . each ( function ( ) { var levelName = $ ( this ) . find ( '.name' ) . attr ( 'data-val' ) ; level _urls . push ( '<option value="level_url:' + levelName + '">多级页:' + levelName + '</option>' ) } ) ; if ( level _urls . length > 0 ) { options += level _urls . join ( '' ) } }
options += '<option value="' + ( setOptUrlVal ? 'url' : '' ) + '" selected="selected">内容页</option>' ; var relation _urls = new Array ( ) ; $ ( '#c_p_relation_urls [id^="relation_url_"]' ) . each ( function ( ) { var relationName = $ ( this ) . find ( '.name' ) . attr ( 'data-val' ) ; relation _urls . push ( '<option value="relation_url:' + relationName + '">关联页:' + relationName + '</option>' ) } ) ; if ( relation _urls . length > 0 ) { options += relation _urls . join ( '' ) }
return options } , field _delete _tr : function ( subEle ) { $ ( subEle ) . parents ( 'tr[id^="field_"]' ) . eq ( 0 ) . remove ( ) } , field _editor : function ( subEle , hiddenFunc ) { var field = null ; var objid = null ; var title = '添加字段' ; if ( subEle ) { objid = $ ( subEle ) . parents ( 'tr[id^="field_"]' ) . eq ( 0 ) . attr ( 'id' ) ; if ( objid ) { field = $ ( '#' + objid ) . find ( 'input[name="config[field_list][]"]' ) . val ( ) ; title = '编辑字段' } }
var options = { hidden _func : hiddenFunc } ; options . ajax = { type : 'post' , data : { objid : objid , field : field } } ; windowModal ( title , ulink ( 'cpattern/field' ) , options ) } , process _paste : function ( ) { var $ _o = this ; $ ( 'body' ) . off ( 'click' , '#window_process_paste' ) . on ( 'click' , '#window_process_paste' , function ( ) { ajaxOpen ( { type : 'get' , dataType : 'json' , url : ulink ( 'cpattern/clone_process?op=paste' ) , success : function ( data ) { if ( data . code == 1 ) { $ _o . cpProcess . add ( data . data ) ; toastr . success ( data . msg ) } else { toastr . error ( data . msg ) } } } ) } ) } , add _request _header : function ( name , val ) { var $ _o = this ; name = name ? name : '' ; val = val ? val : '' ; var tr = $ _o . clone _tpl ( '#coll_tpl_request_headers' ) ; tr . find ( '[name="config[request_headers][custom_names][]"]' ) . val ( name ) ; tr . find ( '[name="config[request_headers][custom_vals][]"]' ) . val ( val ) ; $ ( $ _o . formid + ' #coll_pattern_request_headers .c-p-request-headers tbody' ) . append ( tr ) } , add _request _header _img : function ( name , val ) { var $ _o = this ; name = name ? name : '' ; val = val ? val : '' ; var tr = $ _o . clone _tpl ( '#coll_tpl_request_headers_img' ) ; tr . find ( '[name="config[request_headers][img_names][]"]' ) . val ( name ) ; tr . find ( '[name="config[request_headers][img_vals][]"]' ) . val ( val ) ; $ ( $ _o . formid + ' #coll_pattern_request_headers .c-p-request-headers-img tbody' ) . append ( tr ) } , get _field _names : function ( sortField ) { var fields = new Array ( ) ; var trs = $ ( this . formid + ' #coll_pattern_field .c-p-field-list' ) . find ( 'tr[id^="field_"]' ) ; if ( sortField ) { var fieldsNormal = new Array ( ) ; var fieldsExtract = new Array ( ) ; var fieldsMerge = new Array ( ) ; trs . each ( function ( ) { var fmodule = $ ( this ) . find ( '.field-module' ) . attr ( 'data-val' ) ; var fname = $ ( this ) . find ( '.field-name' ) . attr ( 'data-val' ) ; if ( fname ) { if ( fmodule == 'extract' ) { fieldsExtract . push ( fname ) } else if ( fmodule == 'merge' ) { fieldsMerge . push ( fname ) } else { fieldsNormal . push ( fname ) } } } ) ; for ( var i in fieldsNormal ) { fields . push ( fieldsNormal [ i ] ) }
var options = { hidden _func : hiddenFunc } ; options . ajax = { type : 'post' , data : { objid : objid , field : field } } ; windowModal ( title , ulink ( 'cpattern/field' ) , options ) } , process _paste : function ( ) { var $ _o = this ; $ ( 'body' ) . off ( 'click' , '#window_process_paste' ) . on ( 'click' , '#window_process_paste' , function ( ) { ajaxOpen ( { type : 'get' , dataType : 'json' , url : ulink ( 'cpattern/clone_process?op=paste' ) , success : function ( data ) { if ( data . code == 1 ) { $ _o . cpProcess . add ( data . data ) ; toastr . success ( data . msg ) } else { toastr . error ( data . msg ) } } } ) } ) } , add _request _header : function ( name , val ) { var $ _o = this ; name = name ? name : '' ; val = val ? val : '' ; var tr = $ _o . clone _tpl ( '#coll_tpl_request_headers' ) ; tr . find ( '[name="config[request_headers][custom_names][]"]' ) . val ( name ) ; tr . find ( '[name="config[request_headers][custom_vals][]"]' ) . val ( val ) ; $ ( $ _o . formid + ' #coll_pattern_request_headers .c-p-request-headers tbody' ) . append ( tr ) } , add _request _header _img : function ( name , val ) { var $ _o = this ; name = name ? name : '' ; val = val ? val : '' ; var tr = $ _o . clone _tpl ( '#coll_tpl_request_headers_img' ) ; tr . find ( '[name="config[request_headers][img_names][]"]' ) . val ( name ) ; tr . find ( '[name="config[request_headers][img_vals][]"]' ) . val ( val ) ; $ ( $ _o . formid + ' #coll_pattern_request_headers .c-p-request-headers-img tbody' ) . append ( tr ) } , add _request _header _file : function ( name , val ) { var $ _o = this ; name = name ? name : '' ; val = val ? val : '' ; var tr = $ _o . clone _tpl ( '#coll_tpl_request_headers_file' ) ; tr . find ( '[name="config[request_headers][file_names][]"]' ) . val ( name ) ; tr . find ( '[name="config[request_headers][file_vals][]"]' ) . val ( val ) ; $ ( $ _o . formid + ' #coll_pattern_request_headers .c-p-request-headers-file tbody' ) . append ( tr ) } , get _field _names : function ( sortField ) { var fields = new Array ( ) ; var trs = $ ( this . formid + ' #coll_pattern_field .c-p-field-list' ) . find ( 'tr[id^="field_"]' ) ; if ( sortField ) { var fieldsNormal = new Array ( ) ; var fieldsExtract = new Array ( ) ; var fieldsMerge = new Array ( ) ; trs . each ( function ( ) { var fmodule = $ ( this ) . find ( '.field-module' ) . attr ( 'data-val' ) ; var fname = $ ( this ) . find ( '.field-name' ) . attr ( 'data-val' ) ; if ( fname ) { if ( fmodule == 'extract' ) { fieldsExtract . push ( fname ) } else if ( fmodule == 'merge' ) { fieldsMerge . push ( fname ) } else { fieldsNormal . push ( fname ) } } } ) ; for ( var i in fieldsNormal ) { fields . push ( fieldsNormal [ i ] ) }
for ( var i in fieldsExtract ) { fields . push ( fieldsExtract [ i ] ) }
for ( var i in fieldsMerge ) { fields . push ( fieldsMerge [ i ] ) } } else { trs . each ( function ( ) { var fname = $ ( this ) . find ( '.field-name' ) . attr ( 'data-val' ) ; if ( fname ) { fields . push ( fname ) } } ) }
return fields } , rule _module _slt : function ( curObj ) { curObj = $ ( curObj ) ; var module = curObj . val ( ) ; if ( curObj . attr ( 'data-module-input' ) ) { var ipt = $ ( '[name="' + curObj . attr ( 'data-module-input' ) + '"]' ) ; ipt . attr ( 'data-val-' + module , ipt . val ( ) ) }
curObj . off ( 'change' ) . on ( 'change' , function ( ) { var obj = $ ( this ) ; var name = obj . attr ( 'name' ) ; var changeModule = obj . val ( ) ; $ ( '[data-module-select="' + name + '"]' ) . find ( '[data-module]' ) . hide ( ) ; $ ( '[data-module-select="' + name + '"]' ) . find ( '[data-module="' + changeModule + '"]' ) . show ( ) ; if ( obj . attr ( 'data-module-input' ) ) { var ipt = $ ( '[name="' + obj . attr ( 'data-module-input' ) + '"]' ) ; if ( ! ipt . attr ( 'data-placeholder-' ) ) { ipt . attr ( 'data-placeholder-' , ipt . prop ( 'placeholder' ) + ' ' ) }
if ( ipt . attr ( 'data-placeholder-' + changeModule ) ) { ipt . prop ( 'placeholder' , ipt . attr ( 'data-placeholder-' + changeModule ) ) } else { ipt . prop ( 'placeholder' , '' ) }
if ( ipt . attr ( 'data-val-' + changeModule ) ) { ipt . val ( ipt . attr ( 'data-val-' + changeModule ) ) } else { ipt . val ( '' ) } } } ) } , clone _tpl : function ( tplId , namePre ) { namePre = namePre ? namePre : '' ; var tpl = $ ( tplId ) . clone ( ) ; tpl . removeAttr ( 'id' ) ; tpl . find ( '[data-name]' ) . each ( function ( ) { $ ( this ) . attr ( 'name' , namePre + $ ( this ) . attr ( 'data-name' ) ) ; $ ( this ) . removeAttr ( 'data-name' ) } ) ; return tpl } , get _content _signs : function ( contentSignEle ) { var contentSigns = [ ] ; $ ( contentSignEle ) . each ( function ( ) { var csVal = $ ( this ) . val ( ) ; csVal = decode _urlbase2json ( csVal ) ; contentSigns . push ( csVal ) } ) ; return contentSigns } , page _signs : function ( pageConfig , returnMergeSigns , noDefSign ) { var signs = { area : [ ] , url : [ ] , content : [ ] } ; if ( ! isObject ( pageConfig ) ) { pageConfig = { } }
var areaRule = pageConfig . area ? pageConfig . area : '' ; var urlRule = pageConfig . url _rule ? pageConfig . url _rule : '' ; var contentSigns = pageConfig . content _signs ; var allowDefSign = noDefSign ? 0 : ! 0 ; signs . area = cpM atchN( null , null , { rule : areaRule , def : allowDefSign } ) ; signs . url = cpM atchN( null , null , { rule : urlRule , def : allowDefSign } ) ; var signMatch = window . tpl _lang . sign _match ; if ( isObject ( contentSigns ) ) { for ( var i in contentSigns ) { if ( isObject ( contentSigns [ i ] ) ) { if ( contentSigns [ i ] . identity ) { signs . content . push ( signMatch . replace ( '{:id}' , contentSigns [ i ] . identity ) ) } } } }
var areaRule = pageConfig . area ? pageConfig . area : '' ; var urlRule = pageConfig . url _rule ? pageConfig . url _rule : '' ; var contentSigns = pageConfig . content _signs ; var allowDefSign = noDefSign ? 0 : ! 0 ; signs . area = ruleInsertSign . m atchN( null , null , { rule : areaRule , def : allowDefSign } ) ; signs . url = ruleInsertSign . m atchN( null , null , { rule : urlRule , def : allowDefSign } ) ; var signMatch = window . tpl _lang . sign _match ; if ( isObject ( contentSigns ) ) { for ( var i in contentSigns ) { if ( isObject ( contentSigns [ i ] ) ) { if ( contentSigns [ i ] . identity ) { signs . content . push ( signMatch . replace ( '{:id}' , contentSigns [ i ] . identity ) ) } } } }
for ( var i in signs ) { if ( ! isObject ( signs [ i ] ) ) { signs [ i ] = [ ] } }
if ( returnMergeSigns ) { var mergeSigns = [ ] ; for ( var i in signs . area ) { var curSign = signs . area [ i ] ; if ( mergeSigns . indexOf ( curSign ) <= - 1 && signs . url . indexOf ( curSign ) <= - 1 && signs . content . indexOf ( curSign ) <= - 1 ) { mergeSigns . push ( curSign ) } }
for ( var i in signs . url ) { var curSign = signs . url [ i ] ; if ( mergeSigns . indexOf ( curSign ) <= - 1 && signs . content . indexOf ( curSign ) <= - 1 ) { mergeSigns . push ( curSign ) } }
@ -77,18 +79,19 @@ pageConfig.area=$(formId).find('[name="'+namePre+'[area]"]').val();pageConfig.ur
if ( objid ) { pageConfig . name = $ ( '#' + objid ) . find ( '.name' ) . attr ( 'data-val' ) }
pageConfig . name = pageConfig . name ? pageConfig . name : '' ; pageConfig . area = pageConfig . area ? pageConfig . area : '' ; pageConfig . url _rule = pageConfig . url _rule ? pageConfig . url _rule : '' }
if ( mergeType == 'content_sign' ) { mergeType += ':' + $ ( $ _o . cpContentSign . formObj + ' [name="objid"]' ) . attr ( 'data-identity' ) }
var sourceIsUrl = $ _o . source _is _url ( ) ; ajaxOpen ( { type : 'POST' , dataType : 'json' , url : ulink ( "cpattern/page_signs" ) , data : { front _urls : frontUrls , source _config : sourceConfig , level _urls : levelUrls , relation _urls : relationUrls , url _config : urlConfig , page _config : pageConfig , page _type : pageType , merge _type : mergeType , source _is _url : sourceIsUrl } , success : function ( data ) { if ( data . code == 1 ) { data = data . data ; var pageSort = data . sort ; var allSigns = data . signs ; var html = '' ; var valSigns = null ; if ( iptObj ) { valSigns = cpM atchN( null , null , { rule : iptObj . val ( ) } ) }
var sourceIsUrl = $ _o . source _is _url ( ) ; ajaxOpen ( { type : 'POST' , dataType : 'json' , url : ulink ( "cpattern/page_signs" ) , data : { front _urls : frontUrls , source _config : sourceConfig , level _urls : levelUrls , relation _urls : relationUrls , url _config : urlConfig , page _config : pageConfig , page _type : pageType , merge _type : mergeType , source _is _url : sourceIsUrl } , success : function ( data ) { if ( data . code == 1 ) { data = data . data ; var pageSort = data . sort ; var allSigns = data . signs ; var html = '' ; var valSigns = null ; if ( iptObj ) { valSigns = ruleInsertSign . m atchN( null , null , { rule : iptObj . val ( ) } ) }
if ( ! valSigns || typeof ( valSigns ) != 'object' ) { valSigns = new Array ( ) }
var nullTips = '' ; if ( sourceIsUrl ) { nullTips = '起始页已设为内容页' }
for ( var asi in allSigns ) { var pageSigns = allSigns [ asi ] ? allSigns [ asi ] : { } ; var pageName = pageSigns . name ; var signs = pageSigns . signs ; signs = signs ? signs : { } ; html += '<tr><td>' + pageName + '</td>' ; var signKeys = [ 'area' , 'url' , 'content' ] ; for ( var ski in signKeys ) { html += '<td>' ; var signKey = signKeys [ ski ] ; var keySigns = signs [ signKey ] ; if ( keySigns && keySigns . length > 0 ) { var keyGlobalSigns = signs [ signKey + '_global' ] ; for ( var ksi in keySigns ) { var sign = keySigns [ ksi ] ; var signHtml = htmlspecialchars ( sign ) ; if ( keyGlobalSigns && keyGlobalSigns . indexOf ( sign ) > - 1 ) { var color = valSigns . indexOf ( sign ) > - 1 ? 'color:green;' : '' ; html += '<a href="javascript:;" data-val="' + signHtml + '" style="' + color + '">' + signHtml + '</a>' } else { html += '<span style="color:#999;" title="被覆盖">' + signHtml + '</span>' } } } else { html += '<span style="color:#999;" title="' + nullTips + '">无</span>' }
html += '</td>' }
html += '</tr>' }
if ( dropdownMenu . length > 0 ) { var signsObj = $ _o . clone _tpl ( '#coll_tpl_page_signs' ) ; $ ( dropdownMenu ) . append ( signsObj ) ; $ ( dropdownMenu ) . find ( 'table tbody' ) . html ( html ) ; $ ( dropdownMenu ) . find ( 'a[data-val]' ) . bind ( 'click' , function ( ) { if ( iptObj ) { insertAtCaret ( iptObj , $ ( this ) . attr ( 'data-val' ) ) } } ) ; var sortObj = $ ( dropdownMenu ) . find ( 'th.sorting' ) ; sortObj . removeClass ( 'sorting' ) ; sortObj . addClass ( pageSort == 'asc' ? 'sorting_asc' : 'sorting_desc' ) ; sortObj . attr ( 'title' , '页面' + ( pageSort == 'asc' ? '升序' : '降序' ) + '排列' ) ; sortObj . bind ( 'click' , function ( ) { ajaxOpen ( { type : 'get' , dataType : 'json' , url : ulink ( "cpattern/page_signs_sort" ) , success : function ( data ) { toastr . success ( data . msg ) } } ) } ) } } } } ) } , field _is _loop : function ( ) { var hasLoop = $ ( this . formid + ' #coll_pattern_field .c-p-field-list' ) . find ( '.field-module[data-is-loop]' ) ; if ( hasLoop && hasLoop . length > 0 ) { hasLoop = 1 } else { hasLoop = '' }
return hasLoop } }
return hasLoop } , get _task _id : function ( ) { var taskId = $ ( this . formid + ' [name="task_id"]' ) . val ( ) ; taskId = taskId ? taskId : '' ; return taskId } }
function CpFrontUrl ( cpClass ) { this . $ _cp = cpClass ; this . formObj = '#form_front_url' }
CpFrontUrl . prototype = { constructor : CpFrontUrl , init : function ( front _url ) { var $ _o = this ; $ ( $ _o . formObj ) . bind ( 'submit' , function ( ) { $ _o . add _sub ( ) ; return ! 1 } ) ; $ _o . $ _cp . init _page ( 'front_url' ) ; $ ( $ _o . formObj ) . on ( 'click' , '.c-p-url-page-signs .btn-page-signs' , function ( ) { $ _o . $ _cp . parent _page _signs ( this ) } ) ; if ( front _url ) { var loadParams = [ 'name' , 'url' ] ; for ( var i in loadParams ) { if ( front _url [ loadParams [ i ] ] ) { $ ( $ _o . formObj + ' [name="front_url[' + loadParams [ i ] + ']"]' ) . val ( front _url [ loadParams [ i ] ] ) } }
if ( front _url . use _cookie ) { $ ( $ _o . formObj + ' [name="front_url[use_cookie]"][value="' + toInt ( front _url . use _cookie ) + '"]' ) . prop ( 'checked' , ! 0 ) }
if ( front _url . use _cookie _img ) { $ ( $ _o . formObj + ' [name="front_url[use_cookie_img]"][value="' + toInt ( front _url . use _cookie _img ) + '"]' ) . prop ( 'checked' , ! 0 ) }
if ( front _url . use _cookie _file ) { $ ( $ _o . formObj + ' [name="front_url[use_cookie_file]"][value="' + toInt ( front _url . use _cookie _file ) + '"]' ) . prop ( 'checked' , ! 0 ) }
$ _o . $ _cp . load _page ( 'front_url' , front _url ) } } , add : function ( objid , front _url ) { var $ _o = this ; var pageSigns = $ _o . $ _cp . page _signs ( front _url , ! 0 , ! 0 ) ; var objEle = null ; if ( objid ) { objEle = $ ( $ _o . $ _cp . formid + ' #' + objid ) } else { objEle = $ _o . $ _cp . clone _tpl ( '#coll_tpl_front_url' ) ; objEle . attr ( 'id' , 'front_url_' + generateUUID ( ) ) ; $ ( $ _o . $ _cp . formid + ' #c_p_front_urls' ) . append ( objEle ) }
objEle . find ( '.name' ) . attr ( 'data-val' , front _url . name ) . text ( front _url . name ) ; objEle . find ( '[name="config[front_urls][]"]' ) . val ( encode _json2urlbase ( front _url ) ) ; pageSigns = pageSigns . join ( ' ' ) ; pageSigns = pageSigns ? pageSigns : '无' ; objEle . find ( '.signs' ) . val ( pageSigns ) } , add _sub : function ( ) { var $ _o = this ; var objid = $ ( $ _o . formObj + ' input[name="objid"]' ) . val ( ) ; var checkName = ! 0 ; if ( objid ) { var name = $ ( $ _o . $ _cp . formid + ' #' + objid ) . find ( '.name' ) . attr ( 'data-val' ) ; if ( name == $ ( $ _o . formObj + ' [name="front_url[name]"]' ) . val ( ) ) { checkName = ! 1 } }
if ( checkName ) { var hasName = ! 1 ; $ ( '#c_p_front_urls [id^="front_url_"] .name' ) . each ( function ( ) { if ( $ ( $ _o . formObj + ' [name="front_url[name]"]' ) . val ( ) == $ ( this ) . attr ( 'data-val' ) ) { hasName = ! 0 ; return ! 1 } } ) ; if ( hasName ) { toastr . error ( '该名称已存在!' ) ; return ! 1 } }
@ -187,7 +190,8 @@ $($_o.processBox+' .process-add').bind('click',function(){var module=$($_o.proce
$ ( $ _o . processForm ) . on ( 'click' , '.p-m-html-tags a[data-val]' , function ( ) { var tag = $ ( this ) . attr ( 'data-val' ) ; var moduleHtml = $ ( this ) . parents ( '.p-m-html-tags' ) . eq ( 0 ) . attr ( 'module-html' ) ; var tagsObj = $ ( this ) . parents ( 'section' ) . eq ( 0 ) . find ( 'input[data-process="html:' + moduleHtml + '"]' ) ; var tags = tagsObj . val ( ) + ',' + tag ; tags = tags . replace ( /(^,+)|(,+$)/ , '' ) ; tagsObj . val ( tags ) } ) ; $ ( $ _o . processForm ) . on ( 'change' , '[data-process="insert:insert_loc"]' , function ( ) { var helpEle = $ ( this ) . siblings ( '.help-block' ) ; if ( $ ( this ) . val ( ) == 'rand' ) { helpEle . show ( ) } else { helpEle . hide ( ) } } ) ; inputSelectCustom ( null , null , { box : $ _o . processForm , slt : '[data-process="translate:translate_from"]' , ipt : '[data-process="translate:translate_from_custom"]' } ) ; inputSelectCustom ( null , null , { box : $ _o . processForm , slt : '[data-process="translate:translate_to"]' , ipt : '[data-process="translate:translate_to_custom"]' } ) ; $ _o . txt _insert _field ( $ _o . processForm , '.p-m-func-field' , function ( sltObj ) { return $ ( sltObj ) . parents ( 'section' ) . eq ( 0 ) . find ( '[data-process="func:func_param"]' ) } ) ; $ ( $ _o . processForm ) . on ( 'click' , '.p-m-if-add' , function ( ) { var ifTable = $ ( this ) . parents ( 'section' ) . eq ( 0 ) . find ( '.p-m-if-table' ) ; ifTable . append ( '<tr>' + ifTable . attr ( 'data-tpl' ) + '</tr>' ) } ) ; $ ( $ _o . processForm ) . on ( 'click' , '.p-m-if-del' , function ( ) { var tr = $ ( this ) . parents ( 'tr' ) . eq ( 0 ) ; confirmRight ( '确定删除?' , function ( ) { tr . remove ( ) } ) } ) ; $ ( $ _o . processForm ) . on ( 'change' , '[data-process="if:if_cond:"]' , function ( ) { var ifCond = $ ( this ) . val ( ) ; var ifTr = $ ( this ) . parents ( 'tr' ) . eq ( 0 ) ; var ifTd = ifTr . find ( '.p-m-if-val' ) . eq ( 0 ) ; var ifVal = ifTd . find ( '[data-process="if:if_val:"]' ) . eq ( 0 ) ; var ifValInfo = { name : ifVal . attr ( 'name' ) , val : ifVal . val ( ) , process : ifVal . attr ( 'data-process' ) } ; var ifValType = 'def' ; if ( ifCond == 'func' ) { ifValType = 'func' } else if ( ifCond . indexOf ( 'time_' ) > - 1 ) { ifValType = 'time' }
ifTd . find ( '.p-m-if-val-def,.p-m-if-val-time,.p-m-if-val-func' ) . hide ( ) ; ifTd . find ( '[data-process="if:if_val:"]' ) . removeAttr ( 'name' ) . removeAttr ( 'data-process' ) ; var ifValBox = ifTd . find ( '.p-m-if-val-' + ifValType ) ; var ifValEle = ifValBox . find ( '.p-m-if-val-ele' ) ; ifValEle . attr ( 'name' , ifValInfo . name ) . attr ( 'data-process' , ifValInfo . process ) . val ( ifValInfo . val ) ; ifValBox . show ( ) ; if ( ifValType == 'func' ) { $ _o . load _if _func ( ifTd , null ) } } ) ; $ ( $ _o . processForm ) . on ( 'change' , '.p-m-if-val-time-date select' , function ( ) { $ ( this ) . parents ( 'tr' ) . eq ( 0 ) . find ( '[data-process="if:if_val:"]' ) . val ( $ ( this ) . val ( ) ) } ) ; $ ( $ _o . processForm ) . on ( 'click' , '.p-m-if-val-func-info' , function ( ) { tipsPluginFunc ( 'processIf' ) } ) ; $ _o . txt _insert _field ( $ _o . processForm , '.p-m-if-val-func-field select' , function ( sltObj ) { return $ ( sltObj ) . parents ( 'td' ) . eq ( 0 ) . find ( '[data-process="if:if_val:"]' ) } ) ; $ ( $ _o . processForm ) . on ( 'click' , '.p-m-if-info' , function ( ) { var tips = '<p>执行顺序:从上至下判断,逻辑符“并且”的优先级高于“或者”</p>' + '<p>例如(字母表示条件):</p>' + '<p>a && b || c && d && e || f || g && h && i && j 等同于</p>' + '<p>(a && b) || (c && d && e) || f || (g && h && i && j)</p>' + '<p>括号中的条件都为真时才是真否则为假,整条语句中任意一个括号的结果为真最终结果为真,都为假最终结果为假</p>' ; confirmRight ( { msg : tips , yes : '确定' , width : 500 , textAlign : 'left' } ) } ) ; $ ( $ _o . processForm ) . on ( 'click' , '.p-m-api-add' , function ( ) { var apiTable = $ ( this ) . parents ( 'section' ) . eq ( 0 ) . find ( '.p-m-api-table table' ) ; apiTable . find ( 'tbody' ) . append ( '<tr>' + apiTable . attr ( 'data-tpl' ) + '</tr>' ) } ) ; $ ( $ _o . processForm ) . on ( 'click' , '.p-m-api-del' , function ( ) { var tr = $ ( this ) . parents ( 'tr' ) . eq ( 0 ) ; tr . remove ( ) } ) ; inputSelectCustom ( null , null , { box : $ _o . processForm , slt : '[data-process="api:api_charset"]' , ipt : '[data-process="api:api_charset_custom"]' } ) ; inputSelectCustom ( null , null , { box : $ _o . processForm , slt : '[data-process="api:api_encode"]' , ipt : '[data-process="api:api_encode_custom"]' } ) ; $ ( $ _o . processForm ) . on ( 'change' , '[data-process="api:api_params:val:"],[data-process="api:api_headers:val:"]' , function ( ) { var isHeader = ! 1 ; if ( $ ( this ) . attr ( 'data-process' ) == 'api:api_headers:val:' ) { isHeader = ! 0 }
var val = $ ( this ) . val ( ) ; var tdObj = $ ( this ) . parents ( 'td' ) . eq ( 0 ) ; var iptObj = tdObj . find ( '[data-process="api:' + ( isHeader ? 'api_headers' : 'api_params' ) + ':addon:"]' ) ; var sltObj = tdObj . find ( '.p-m-api-' + ( isHeader ? 'header' : 'val' ) + '-field' ) ; iptObj . hide ( ) ; sltObj . hide ( ) ; if ( val == 'time' || val == 'custom' ) { if ( val == 'time' ) { iptObj . attr ( 'placeholder' , '默认格式:Y-m-d H:i:s' ) } else if ( val == 'custom' ) { iptObj . attr ( 'placeholder' , '输入任何内容' ) ; sltObj . css ( 'display' , 'table-cell' ) }
iptObj . show ( ) } } ) ; $ _o . txt _insert _field ( $ _o . processForm , '.p-m-api-val-field select' , function ( sltObj ) { return $ ( sltObj ) . parents ( 'td' ) . eq ( 0 ) . find ( '[data-process="api:api_params:addon:"]' ) } ) ; $ _o . txt _insert _field ( $ _o . processForm , '.p-m-api-header-field select' , function ( sltObj ) { return $ ( sltObj ) . parents ( 'td' ) . eq ( 0 ) . find ( '[data-process="api:api_headers:addon:"]' ) } ) ; $ ( $ _o . processForm ) . on ( 'click' , '.p-m-api-header-add' , function ( ) { var apiHdTable = $ ( this ) . parents ( 'section' ) . eq ( 0 ) . find ( '.p-m-api-header-table table' ) ; apiHdTable . find ( 'tbody' ) . append ( '<tr>' + apiHdTable . attr ( 'data-tpl' ) + '</tr>' ) } ) ; $ ( $ _o . processForm ) . on ( 'click' , '.p-m-api-header-del' , function ( ) { var tr = $ ( this ) . parents ( 'tr' ) . eq ( 0 ) ; tr . remove ( ) } ) ; $ ( $ _o . processForm ) . on ( 'change' , '[data-process="api:api_type"]' , function ( ) { var obj = $ ( this ) . parents ( 'section' ) . eq ( 0 ) . find ( '.p-m-api-content-type' ) ; if ( $ ( this ) . val ( ) == 'post' ) { obj . show ( ) } else { obj . hide ( ) } } ) ; $ ( $ _o . processForm ) . on ( 'change' , '[data-process="api:api_json_arr"]' , function ( ) { var ipt = $ ( this ) . parent ( ) . find ( '.p-m-api-json-implode' ) ; if ( $ ( this ) . val ( ) == 'implode' ) { ipt . show ( ) } else { ipt . hide ( ) } } ) ; $ ( $ _o . processForm ) . on ( 'click' , '.sign-wildcard' , function ( ) { var toObj = $ ( this ) . parent ( ) . siblings ( '[data-process="replace:replace_from"]' ) ; cpWildcard ( toObj ) } ) ; $ ( $ _o . processForm ) . on ( 'click' , '.c-p-process-title' , function ( ) { var panelTitle = $ ( this ) . parents ( '.panel' ) . eq ( 0 ) . find ( '.panel-title-title' ) ; if ( panelTitle . find ( 'input' ) . is ( ':visible' ) ) { panelTitle . find ( '*' ) . show ( ) ; panelTitle . find ( 'input' ) . hide ( ) } else { panelTitle . find ( '*' ) . hide ( ) ; panelTitle . find ( 'input' ) . show ( ) } } ) ; ( function ( processForm , processBox ) { $ ( processForm ) . on ( 'click' , '.c-p-process-clone' , function ( ) { var panelObj = $ ( this ) . parents ( '.panel[data-name^="process"]' ) . eq ( 0 ) ; var formEle = document . createElement ( 'form' ) ; $ ( formEle ) . append ( panelObj . clone ( ) ) ; $ ( panelObj ) . find ( '[name^="process"]' ) . each ( function ( index ) { var processEle = $ ( formEle ) . find ( '[name^="process"]' ) . eq ( index ) ; if ( $ ( this ) . is ( 'input:radio' ) || $ ( this ) . is ( 'input:checkbox' ) ) { processEle . prop ( 'checked' , $ ( this ) . is ( ':checked' ) ) } else { processEle . val ( $ ( this ) . val ( ) ) } } ) ; confirmRight ( { msg : '拷贝或复制数据处理' , yes : '复制' , no : '拷贝' , close : ! 0 } , function ( ) { ajaxOpen ( { type : 'POST' , dataType : 'json' , url : ulink ( 'cpattern/clone_process' ) , data : $ ( formEle ) . serialize ( ) , success : function ( data ) { if ( data . code == 1 ) { $ _o . processForm = processForm ; $ _o . processBox = processBox ; $ _o . add ( data . data ) ; toastr . success ( data . msg ) } } } ) } , function ( ) { ajaxOpen ( { type : 'POST' , dataType : 'json' , url : ulink ( 'cpattern/clone_process?op=copy' ) , data : $ ( formEle ) . serialize ( ) , success : function ( data ) { if ( data . code == 1 ) { toastr . success ( data . msg ) } } } ) } ) } ) } ) ( $ _o . processForm , $ _o . processBox ) ; $ ( $ _o . processForm ) . on ( 'click' , '.c-p-process-del' , function ( ) { $ _o . del ( this ) } ) ; eleExchange ( $ _o . processForm + ' .c-p-process-accordion' , '.panel-title-ops .icon-drag-move' , '.panel' ) ; if ( processData ) { for ( var i in processData ) { if ( processData [ i ] ) { $ _o . add ( processData [ i ] ) } } }
iptObj . show ( ) } } ) ; $ _o . txt _insert _field ( $ _o . processForm , '.p-m-api-val-field select' , function ( sltObj ) { return $ ( sltObj ) . parents ( 'td' ) . eq ( 0 ) . find ( '[data-process="api:api_params:addon:"]' ) } ) ; $ _o . txt _insert _field ( $ _o . processForm , '.p-m-api-header-field select' , function ( sltObj ) { return $ ( sltObj ) . parents ( 'td' ) . eq ( 0 ) . find ( '[data-process="api:api_headers:addon:"]' ) } ) ; $ ( $ _o . processForm ) . on ( 'click' , '.p-m-api-header-add' , function ( ) { var apiHdTable = $ ( this ) . parents ( 'section' ) . eq ( 0 ) . find ( '.p-m-api-header-table table' ) ; apiHdTable . find ( 'tbody' ) . append ( '<tr>' + apiHdTable . attr ( 'data-tpl' ) + '</tr>' ) } ) ; $ ( $ _o . processForm ) . on ( 'click' , '.p-m-api-header-del' , function ( ) { var tr = $ ( this ) . parents ( 'tr' ) . eq ( 0 ) ; tr . remove ( ) } ) ; $ ( $ _o . processForm ) . on ( 'change' , '[data-process="api:api_type"]' , function ( ) { var obj = $ ( this ) . parents ( 'section' ) . eq ( 0 ) . find ( '.p-m-api-content-type' ) ; if ( $ ( this ) . val ( ) == 'post' ) { obj . show ( ) } else { obj . hide ( ) } } ) ; $ ( $ _o . processForm ) . on ( 'change' , '[data-process="api:api_rule_module"]' , function ( ) { var ruleModule = $ ( this ) . val ( ) ; ruleModule = ruleModule ? ruleModule : '' ; var obj = $ ( this ) . parents ( 'section' ) . eq ( 0 ) ; obj . find ( '.p-m-api-rule-module' ) . hide ( ) ; obj . find ( '.p-m-api-rule-module[data-rule-module="' + ruleModule + '"]' ) . show ( ) } ) ; cpRuleModuleInit ( $ _o . processForm , 'data-process' , 'api:api_' ) ; $ ( $ _o . processForm ) . on ( 'change' , '[data-process="download:download_op"]' , function ( ) { var obj = $ ( this ) . parents ( 'section' ) . eq ( 0 ) ; var val = $ ( this ) . val ( ) ; obj . find ( '.p-m-download-op' ) . hide ( ) ; obj . find ( '.p-m-download-op[data-op="' + val + '"]' ) . show ( ) } ) ; $ ( $ _o . processForm ) . on ( 'click' , '.p-m-download-file-tag .dropdown-menu a[data-val]' , function ( ) { var prt = $ ( this ) . parents ( '.p-m-download-file-tag' ) . eq ( 0 ) ; var obj = prt . find ( '[data-process="download:download_file_tag"]' ) ; var val = obj . val ( ) ; if ( val ) { val = val . split ( ',' ) } else { val = new Array ( ) }
val . push ( $ ( this ) . attr ( 'data-val' ) ) ; val = val . join ( ',' ) ; obj . val ( val ) } ) ; $ ( $ _o . processForm ) . on ( 'click' , '.c-p-process-sign-wildcard' , function ( ) { var toObj = $ ( this ) . parent ( ) . siblings ( '[data-process]' ) ; ruleInsertSign . wildcard ( toObj ) } ) ; $ ( $ _o . processForm ) . on ( 'click' , '.c-p-process-title' , function ( ) { var panelTitle = $ ( this ) . parents ( '.panel' ) . eq ( 0 ) . find ( '.panel-title-title' ) ; if ( panelTitle . find ( 'input' ) . is ( ':visible' ) ) { panelTitle . find ( '*' ) . show ( ) ; panelTitle . find ( 'input' ) . hide ( ) } else { panelTitle . find ( '*' ) . hide ( ) ; panelTitle . find ( 'input' ) . show ( ) } } ) ; ( function ( processForm , processBox ) { $ ( processForm ) . on ( 'click' , '.c-p-process-clone' , function ( ) { var panelObj = $ ( this ) . parents ( '.panel[data-name^="process"]' ) . eq ( 0 ) ; var formEle = document . createElement ( 'form' ) ; $ ( formEle ) . append ( panelObj . clone ( ) ) ; $ ( panelObj ) . find ( '[name^="process"]' ) . each ( function ( index ) { var processEle = $ ( formEle ) . find ( '[name^="process"]' ) . eq ( index ) ; if ( $ ( this ) . is ( 'input:radio' ) || $ ( this ) . is ( 'input:checkbox' ) ) { processEle . prop ( 'checked' , $ ( this ) . is ( ':checked' ) ) } else { processEle . val ( $ ( this ) . val ( ) ) } } ) ; confirmRight ( { msg : '拷贝或复制数据处理' , yes : '复制' , no : '拷贝' , close : ! 0 } , function ( ) { ajaxOpen ( { type : 'POST' , dataType : 'json' , url : ulink ( 'cpattern/clone_process' ) , data : $ ( formEle ) . serialize ( ) , success : function ( data ) { if ( data . code == 1 ) { $ _o . processForm = processForm ; $ _o . processBox = processBox ; $ _o . add ( data . data ) ; toastr . success ( data . msg ) } } } ) } , function ( ) { ajaxOpen ( { type : 'POST' , dataType : 'json' , url : ulink ( 'cpattern/clone_process?op=copy' ) , data : $ ( formEle ) . serialize ( ) , success : function ( data ) { if ( data . code == 1 ) { toastr . success ( data . msg ) } } } ) } ) } ) } ) ( $ _o . processForm , $ _o . processBox ) ; $ ( $ _o . processForm ) . on ( 'click' , '.c-p-process-del' , function ( ) { $ _o . del ( this ) } ) ; eleExchange ( $ _o . processForm + ' .c-p-process-accordion' , '.panel-title-ops .icon-drag-move' , '.panel' ) ; if ( processData ) { for ( var i in processData ) { if ( processData [ i ] ) { $ _o . add ( processData [ i ] ) } } }
$ ( $ _o . processForm ) . prop ( 'inited' , 1 ) } , add _sub : function ( ) { var $ _o = this ; ajaxOpen ( { type : 'POST' , dataType : 'json' , url : $ ( $ _o . processForm ) . attr ( 'action' ) , data : $ ( $ _o . processForm ) . serialize ( ) , success : function ( data ) { if ( data . code == 1 ) { $ ( '#myModal' ) . modal ( 'hide' ) ; if ( data . data && data . data . objid ) { $ ( $ _o . $ _cp . formid + ' #' + data . data . objid ) . find ( 'input[name="config[field_process][]"]' ) . val ( data . data . process _json ? url _base64encode ( data . data . process _json ) : '' ) ; var ptitle = '' ; var processData = data . data . process ; if ( processData ) { ptitle = [ ] ; for ( var i in processData ) { ptitle . push ( window . tpl _lang [ 'process_module_' + processData [ i ] . module ] + ( processData [ i ] . title ? ( ':' + processData [ i ] . title ) : '' ) ) }
ptitle = ptitle . join ( ' / ' ) }
if ( processData && ptitle ) { $ ( $ _o . $ _cp . formid + ' #' + data . data . objid ) . find ( '.field-process' ) . addClass ( 'exist-process' ) . attr ( 'title' , ptitle ) } else { $ ( $ _o . $ _cp . formid + ' #' + data . data . objid ) . find ( '.field-process' ) . removeClass ( 'exist-process' ) . attr ( 'title' , '' ) } } } else { toastr . error ( data . msg ) } } , error : function ( data ) { toastr . error ( data ) } } ) ; return ! 1 } , del : function ( obj ) { var $ _o = this ; confirmRight ( '是否删除?' , function ( ) { $ ( obj ) . parents ( '.panel' ) . eq ( 0 ) . remove ( ) } ) } , load _if _func : function ( box , setVal ) { var $ _o = this ; loadPluginFunc ( { module : 'processIf' , boxObj : box , funcObj : '[data-process="if:if_addon:func:"]' , paramObj : '[data-process="if:if_val:"]' , funcVal : setVal , cache : ! 0 } ) } , add : function ( params ) { var $ _o = this ; params = params ? params : { } ; if ( ! params . module ) { toastr . error ( '请选择处理方式' ) ; return ! 1 }
@ -197,12 +201,14 @@ var processName='process[i_'+generateUUID()+']';moduleHtml='<input type="hidden"
html . find ( '.panel-title-title > input:text' ) . attr ( 'name' , processName + '[title]' ) . val ( params . title ? params . title : '' ) ; html . find ( '.panel-collapse' ) . attr ( 'id' , collapseId ) ; if ( params . add _new ) { html . find ( '.panel-collapse' ) . addClass ( 'in' ) }
html . find ( '.panel-body' ) . html ( moduleHtml ) ; $ ( $ _o . processForm + ' .c-p-process-accordion' ) . append ( html ) ; $ ( $ _o . processForm ) . show ( ) ; var curCollapse = $ _o . processForm + ' #' + collapseId ; $ ( curCollapse ) . find ( '[data-process]' ) . each ( function ( ) { var eleName = $ ( this ) . attr ( 'data-process' ) . split ( ':' ) ; eleName [ 1 ] = processName + '[' + eleName [ 1 ] + ']' ; if ( eleName . length >= 3 ) { eleName [ 1 ] += eleName [ 2 ] ? ( '[' + eleName [ 2 ] + ']' ) : '[]' }
if ( eleName . length >= 4 ) { eleName [ 1 ] += eleName [ 3 ] ? ( '[' + eleName [ 3 ] + ']' ) : '[]' }
$ ( this ) . attr ( 'name' , eleName [ 1 ] ) } ) ; if ( params . module == 'html' ) { $ ( curCollapse ) . find ( '[data-process="html:html_allow"]' ) . val ( params . html _allow ? params . html _allow : '' ) ; $ ( curCollapse ) . find ( '[data-process="html:html_filter"]' ) . val ( params . html _filter ? params . html _filter : '' ) ; if ( params . html _filter ) { $ ( curCollapse ) . find ( 'a[href^="#p_m_html_filter"]' ) . tab ( 'show' ) } } else if ( params . module == 'insert' ) { $ ( curCollapse ) . find ( '[data-process="insert:insert_loc"]' ) . val ( params . insert _loc ? params . insert _loc : '' ) . trigger ( 'change' ) ; $ ( curCollapse ) . find ( '[data-process="insert:insert_txt"]' ) . val ( params . insert _txt ? params . insert _txt : '' ) } else if ( params . module == 'replace' ) { $ ( curCollapse ) . find ( '[data-process="replace:replace_from"]' ) . val ( params . replace _from ? params . replace _from : '' ) ; $ ( curCollapse ) . find ( '[data-process="replace:replace_to"]' ) . val ( params . replace _to ? params . replace _to : '' ) } else if ( params . module == 'filter' ) { $ ( curCollapse ) . find ( '[data-process="filter:filter_list"]' ) . val ( params . filter _list ? params . filter _list : '' ) ; $ ( curCollapse ) . find ( '[data-process="filter:filter_replace"]' ) . val ( params . filter _replace ? params . filter _replace : '' ) ; $ ( curCollapse ) . find ( '[data-process="filter:filter_pass"][value="' + params . filter _pass + '"]' ) . prop ( 'checked' , ! 0 ) } else if ( params . module == 'tool' ) { $ ( curCollapse ) . find ( '[data-process="tool:tool_list"]' ) . attr ( 'name' , processName + '[tool_list][]' ) ; if ( params . tool _list ) { for ( var ti in params . tool _list ) { $ ( curCollapse ) . find ( '[data-process="tool:tool_list"][value="' + params . tool _list [ ti ] + '"]' ) . prop ( 'checked' , ! 0 ) } } } else if ( params . module == 'translate' ) { $ ( curCollapse ) . find ( '[data-process="translate:translate_from"]' ) . val ( params . translate _from ? params . translate _from : '' ) . trigger ( 'change' ) ; $ ( curCollapse ) . find ( '[data-process="translate:translate_to"]' ) . val ( params . translate _to ? params . translate _to : '' ) . trigger ( 'change' ) ; $ ( curCollapse ) . find ( '[data-process="translate:translate_from_custom"]' ) . val ( params . translate _from _custom ? params . translate _from _custom : '' ) ; $ ( curCollapse ) . find ( '[data-process="translate:translate_to_custom"]' ) . val ( params . translate _to _custom ? params . translate _to _custom : '' ) } else if ( params . module == 'batch' ) { $ ( curCollapse ) . find ( '[data-process="batch:batch_list"]' ) . val ( params . batch _list ? params . batch _list : '' ) } else if ( params . module == 'substr' ) { $ ( curCollapse ) . find ( '[data-process="substr:substr_len"]' ) . val ( params . substr _len ? params . substr _len : '' ) ; $ ( curCollapse ) . find ( '[data-process="substr:substr_end"]' ) . val ( params . substr _end ? params . substr _end : '' ) } else if ( params . module == 'func' ) { $ ( curCollapse ) . find ( '[data-process="func:func_param"]' ) . val ( params . func _param ? params . func _param : '' ) ; loadPluginFunc ( { module : 'process' , boxObj : $ ( curCollapse ) , funcObj : '[data-process="func:func_name"]' , paramObj : '[data-process="func:func_param"]' , funcVal : params . func _name , cache : ! 0 } ) } else if ( params . module == 'if' ) { var ifTrTpl = $ ( curCollapse ) . find ( '.p-m-if-table-tpl' ) ; var ifTable = $ ( curCollapse ) . find ( '.p-m-if-table' ) ; ifTable . attr ( 'data-tpl' , ifTrTpl . html ( ) ) ; ifTrTpl . remove ( ) ; if ( params . if _type ) { $ ( curCollapse ) . find ( '[data-process="if:if_type"]' ) . val ( params . if _type ) }
$ ( this ) . attr ( 'name' , eleName [ 1 ] ) } ) ; if ( params . module == 'html' ) { $ ( curCollapse ) . find ( '[data-process="html:html_allow"]' ) . val ( params . html _allow ? params . html _allow : '' ) ; $ ( curCollapse ) . find ( '[data-process="html:html_filter"]' ) . val ( params . html _filter ? params . html _filter : '' ) ; if ( params . html _filter ) { $ ( curCollapse ) . find ( 'a[href^="#p_m_html_filter"]' ) . tab ( 'show' ) } } else if ( params . module == 'insert' ) { $ ( curCollapse ) . find ( '[data-process="insert:insert_loc"]' ) . val ( params . insert _loc ? params . insert _loc : '' ) . trigger ( 'change' ) ; $ ( curCollapse ) . find ( '[data-process="insert:insert_txt"]' ) . val ( params . insert _txt ? params . insert _txt : '' ) } else if ( params . module == 'replace' ) { $ ( curCollapse ) . find ( '[data-process="replace:replace_from"]' ) . val ( params . replace _from ? params . replace _from : '' ) ; $ ( curCollapse ) . find ( '[data-process="replace:replace_to"]' ) . val ( params . replace _to ? params . replace _to : '' ) } else if ( params . module == 'filter' ) { $ ( curCollapse ) . find ( '[data-process="filter:filter_list"]' ) . val ( params . filter _list ? params . filter _list : '' ) ; $ ( curCollapse ) . find ( '[data-process="filter:filter_replace"]' ) . val ( params . filter _replace ? params . filter _replace : '' ) ; $ ( curCollapse ) . find ( '[data-process="filter:filter_pass"][value="' + params . filter _pass + '"]' ) . prop ( 'checked' , ! 0 ) } else if ( params . module == 'tool' ) { $ ( curCollapse ) . find ( '[data-process="tool:tool_list"]' ) . attr ( 'name' , processName + '[tool_list][]' ) ; if ( params . tool _list ) { for ( var ti in params . tool _list ) { $ ( curCollapse ) . find ( '[data-process="tool:tool_list"][value="' + params . tool _list [ ti ] + '"]' ) . prop ( 'checked' , ! 0 ) } } } else if ( params . module == 'download' ) { $ ( curCollapse ) . find ( '[data-process="download:download_op"]' ) . val ( params . download _op ? params . download _op : '' ) . trigger ( 'change' ) ; $ ( curCollapse ) . find ( '[data-process="download:download_file_tag"]' ) . val ( params . download _file _tag ? params . download _file _tag : '' ) ; $ ( curCollapse ) . find ( '[data-process="download:download_file_must"]' ) . val ( params . download _file _must ? params . download _file _must : '' ) ; $ ( curCollapse ) . find ( '[data-process="download:download_file_ban"]' ) . val ( params . download _file _ban ? params . download _file _ban : '' ) } else if ( params . module == ' translate' ) { $ ( curCollapse ) . find ( '[data-process="translate:translate_from"]' ) . val ( params . translate _from ? params . translate _from : '' ) . trigger ( 'change' ) ; $ ( curCollapse ) . find ( '[data-process="translate:translate_to"]' ) . val ( params . translate _to ? params . translate _to : '' ) . trigger ( 'change' ) ; $ ( curCollapse ) . find ( '[data-process="translate:translate_from_custom"]' ) . val ( params . translate _from _custom ? params . translate _from _custom : '' ) ; $ ( curCollapse ) . find ( '[data-process="translate:translate_to_custom"]' ) . val ( params . translate _to _custom ? params . translate _to _custom : '' ) } else if ( params . module == 'batch' ) { $ ( curCollapse ) . find ( '[data-process="batch:batch_list"]' ) . val ( params . batch _list ? params . batch _list : '' ) } else if ( params . module == 'substr' ) { $ ( curCollapse ) . find ( '[data-process="substr:substr_len"]' ) . val ( params . substr _len ? params . substr _len : '' ) ; $ ( curCollapse ) . find ( '[data-process="substr:substr_end"]' ) . val ( params . substr _end ? params . substr _end : '' ) } else if ( params . module == 'func' ) { $ ( curCollapse ) . find ( '[data-process="func:func_param"]' ) . val ( params . func _param ? params . func _param : '' ) ; loadPluginFunc ( { module : 'process' , boxObj : $ ( curCollapse ) , funcObj : '[data-process="func:func_name"]' , paramObj : '[data-process="func:func_param"]' , funcVal : params . func _name , cache : ! 0 } ) } else if ( params . module == 'if' ) { var ifTrTpl = $ ( curCollapse ) . find ( '.p-m-if-table-tpl' ) ; var ifTable = $ ( curCollapse ) . find ( '.p-m-if-table' ) ; ifTable . attr ( 'data-tpl' , ifTrTpl . html ( ) ) ; ifTrTpl . remove ( ) ; if ( params . if _type ) { $ ( curCollapse ) . find ( '[data-process="if:if_type"]' ) . val ( params . if _type ) }
if ( params . if _logic && params . if _cond && params . if _val ) { params . if _addon = params . if _addon ? params . if _addon : { } ; for ( var i in params . if _logic ) { ifTable . find ( 'tbody' ) . append ( '<tr data-if-id="' + i + '">' + ifTable . attr ( 'data-tpl' ) + '</tr>' ) ; var curIfTr = ifTable . find ( 'tr[data-if-id="' + i + '"]' ) ; curIfTr . find ( '[data-process="if:if_logic:"]' ) . val ( params . if _logic [ i ] ) ; curIfTr . find ( '[data-process="if:if_cond:"]' ) . val ( params . if _cond [ i ] ) . trigger ( 'change' ) ; curIfTr . find ( '[data-process="if:if_val:"]' ) . val ( params . if _val [ i ] ) ; if ( params . if _cond [ i ] == 'func' ) { var ifFuncVal = '' ; if ( params . if _addon . func ) { ifFuncVal = params . if _addon . func [ i ] }
$ _o . load _if _func ( curIfTr , ifFuncVal ) ; if ( params . if _addon . turn ) { curIfTr . find ( '[data-process="if:if_addon:turn:"]' ) . val ( params . if _addon . turn [ i ] ) } } } }
eleExchange ( curCollapse + ' .p-m-if-table' , '.icon-drag-move' , 'tbody tr' ) } else if ( params . module == 'api' ) { var apiTrTpl = $ ( curCollapse ) . find ( '.p-m-api-table-tpl' ) ; var apiTable = $ ( curCollapse ) . find ( '.p-m-api-table table' ) ; apiTable . attr ( 'data-tpl' , apiTrTpl . html ( ) ) ; apiTrTpl . remove ( ) ; var apiHdTrTpl = $ ( curCollapse ) . find ( '.p-m-api-header-table-tpl' ) ; var apiHdTable = $ ( curCollapse ) . find ( '.p-m-api-header-table table' ) ; apiHdTable . attr ( 'data-tpl' , apiHdTrTpl . html ( ) ) ; apiHdTrTpl . remove ( ) ; $ ( curCollapse ) . find ( '[data-process="api:api_url"]' ) . val ( params . api _url ? params . api _url : '' ) ; $ ( curCollapse ) . find ( '[data-process="api:api_type"]' ) . val ( params . api _type ? params . api _type : '' ) . trigger ( 'change' ) ; $ ( curCollapse ) . find ( '[data-process="api:api_content_type"]' ) . val ( params . api _content _type ? params . api _content _type : '' ) ; $ ( curCollapse ) . find ( '[data-process="api:api_charset"]' ) . val ( params . api _charset ? params . api _charset : '' ) . trigger ( 'change' ) ; $ ( curCollapse ) . find ( '[data-process="api:api_charset_custom"]' ) . val ( params . api _charset _custom ? params . api _charset _custom : '' ) ; $ ( curCollapse ) . find ( '[data-process="api:api_encode"]' ) . val ( params . api _encode ? params . api _encode : '' ) . trigger ( 'change' ) ; $ ( curCollapse ) . find ( '[data-process="api:api_encode_custom"]' ) . val ( params . api _encode _custom ? params . api _encode _custom : '' ) ; if ( params . api _params ) { params . api _params . name = params . api _params . name ? params . api _params . name : { } ; params . api _params . val = params . api _params . val ? params . api _params . val : { } ; params . api _params . addon = params . api _params . addon ? params . api _params . addon : { } ; for ( var i in params . api _params . name ) { var trId = 'p-m-api-param_' + generateUUID ( ) ; var trTpl = '<tr id="' + trId + '">' + apiTable . attr ( 'data-tpl' ) + '</tr>' ; apiTable . find ( 'tbody' ) . append ( trTpl ) ; apiTable . find ( '#' + trId + ' [data-process="api:api_params:name:"]' ) . val ( params . api _params . name [ i ] ) ; apiTable . find ( '#' + trId + ' [data-process="api:api_params:val:"]' ) . val ( params . api _params . val [ i ] ? params . api _params . val [ i ] : '' ) . trigger ( 'change' ) ; apiTable . find ( '#' + trId + ' [data-process="api:api_params:addon:"]' ) . val ( params . api _params . addon [ i ] ? params . api _params . addon [ i ] : '' ) } }
eleExchange ( curCollapse + ' .p-m-if-table' , '.icon-drag-move' , 'tbody tr' ) } else if ( params . module == 'api' ) { var apiTrTpl = $ ( curCollapse ) . find ( '.p-m-api-table-tpl' ) ; var apiTable = $ ( curCollapse ) . find ( '.p-m-api-table table' ) ; apiTable . attr ( 'data-tpl' , apiTrTpl . html ( ) ) ; apiTrTpl . remove ( ) ; var apiHdTrTpl = $ ( curCollapse ) . find ( '.p-m-api-header-table-tpl' ) ; var apiHdTable = $ ( curCollapse ) . find ( '.p-m-api-header-table table' ) ; apiHdTable . attr ( 'data-tpl' , apiHdTrTpl . html ( ) ) ; apiHdTrTpl . remove ( ) ; if ( params . api _params ) { params . api _params . name = params . api _params . name ? params . api _params . name : { } ; params . api _params . val = params . api _params . val ? params . api _params . val : { } ; params . api _params . addon = params . api _params . addon ? params . api _params . addon : { } ; for ( var i in params . api _params . name ) { var trId = 'p-m-api-param_' + generateUUID ( ) ; var trTpl = '<tr id="' + trId + '">' + apiTable . attr ( 'data-tpl' ) + '</tr>' ; apiTable . find ( 'tbody' ) . append ( trTpl ) ; apiTable . find ( '#' + trId + ' [data-process="api:api_params:name:"]' ) . val ( params . api _params . name [ i ] ) ; apiTable . find ( '#' + trId + ' [data-process="api:api_params:val:"]' ) . val ( params . api _params . val [ i ] ? params . api _params . val [ i ] : '' ) . trigger ( 'change' ) ; apiTable . find ( '#' + trId + ' [data-process="api:api_params:addon:"]' ) . val ( params . api _params . addon [ i ] ? params . api _params . addon [ i ] : '' ) } }
if ( params . api _headers ) { params . api _headers . name = params . api _headers . name ? params . api _headers . name : { } ; params . api _headers . val = params . api _headers . val ? params . api _headers . val : { } ; params . api _headers . addon = params . api _headers . addon ? params . api _headers . addon : { } ; for ( var i in params . api _headers . name ) { var trId = 'p-m-api-header_' + generateUUID ( ) ; var trTpl = '<tr id="' + trId + '">' + apiHdTable . attr ( 'data-tpl' ) + '</tr>' ; apiHdTable . find ( 'tbody' ) . append ( trTpl ) ; apiHdTable . find ( '#' + trId + ' [data-process="api:api_headers:name:"]' ) . val ( params . api _headers . name [ i ] ) ; apiHdTable . find ( '#' + trId + ' [data-process="api:api_headers:val:"]' ) . val ( params . api _headers . val [ i ] ? params . api _headers . val [ i ] : '' ) . trigger ( 'change' ) ; apiHdTable . find ( '#' + trId + ' [data-process="api:api_headers:addon:"]' ) . val ( params . api _headers . addon [ i ] ? params . api _headers . addon [ i ] : '' ) } }
$ ( curCollapse ) . find ( '[data-process="api:api_json"]' ) . val ( params . api _json ? params . api _json : '' ) ; $ ( curCollapse ) . find ( '[data-process="api:api_json_arr"]' ) . val ( params . api _json _arr ? params . api _json _arr : 'implode' ) . trigger ( 'change' ) ; $ ( curCollapse ) . find ( '[data-process="api:api_json_implode"]' ) . val ( params . api _json _implode ? params . api _json _implode : '' ) ; $ ( curCollapse ) . find ( '[data-process="api:api_interval"]' ) . val ( params . api _interval ? params . api _interval : '' ) ; $ ( curCollapse ) . find ( '[data-process="api:api_wait"]' ) . val ( params . api _wait ? params . api _wait : '' ) ; $ ( curCollapse ) . find ( '[data-process="api:api_retry"]' ) . val ( params . api _retry ? params . api _retry : '' ) }
params . api _json _arr = params . api _json _arr ? params . api _json _arr : 'implode' ; for ( var i in params ) { if ( isObject ( params [ i ] ) ) { continue }
$ ( curCollapse ) . find ( '[data-process="api:' + i + '"]' ) . val ( params [ i ] ? params [ i ] : '' ) }
$ ( curCollapse ) . find ( '[data-process="api:api_type"]' ) . trigger ( 'change' ) ; $ ( curCollapse ) . find ( '[data-process="api:api_charset"]' ) . trigger ( 'change' ) ; $ ( curCollapse ) . find ( '[data-process="api:api_encode"]' ) . trigger ( 'change' ) ; $ ( curCollapse ) . find ( '[data-process="api:api_rule_module"]' ) . trigger ( 'change' ) ; cpRuleModuleLoad ( curCollapse , processName , 'api_' , params ) }
if ( $ _o . processForm != $ _o . processFormField ) { $ ( '#myModal' ) . modal ( 'hide' ) } } , txt _insert _field : function ( boxEle , sltEle , txtObjFunc ) { var $ _o = this ; $ ( boxEle ) . on ( 'mouseover' , sltEle , function ( ) { if ( ! $ ( this ) . attr ( 'data-loaded' ) ) { var fieldNames = $ _o . $ _cp . get _field _names ( ! 0 ) ; var html = '<option value="">插入字段</option><option value="###">###表示当前字段</option>' ; if ( fieldNames ) { var formField = $ ( this ) . parents ( $ _o . processFormField ) . eq ( 0 ) . find ( '[name="field"]' ) . val ( ) ; if ( formField ) { for ( var i = 0 ; i < fieldNames . length ; i ++ ) { var curField = fieldNames [ i ] ; if ( formField && formField == curField ) { if ( i < fieldNames . length - 1 ) { html += '<optgroup label="不能调用当前字段顺序后面的字段,可移动字段位置使之生效"></optgroup>' }
break }
html += '<option value="[字段:' + curField + ']">字段:' + curField + '</option>' } } else { html += '<optgroup label="通用数据处理仅支持调用当前字段"></optgroup>' } }
@ -228,28 +234,10 @@ if(contentSignFunc){showPanelCollapse('#panel_content_sign_func')}
loadPluginFunc ( { module : 'contentSign' , boxObj : $ _o . formObj , funcObj : '[name="content_sign[func]"]' , funcVal : contentSignFunc , paramObj : '[name="content_sign[func_param]"]' } ) ; $ ( $ _o . formObj + ' .c-p-content-sign-add-cur' ) . bind ( 'click' , function ( ) { insertAtCaret ( $ ( $ _o . formObj ) . find ( '[name="content_sign[func_param]"]' ) , '###' ) } ) ; $ ( $ _o . formObj ) . on ( 'click' , '.c-p-url-page-signs .btn-page-signs' , function ( ) { $ _o . $ _cp . parent _page _signs ( this ) } ) } , add _sub : function ( ) { var $ _o = this ; ajaxOpen ( { type : 'POST' , dataType : 'json' , url : $ ( $ _o . formObj ) . attr ( 'action' ) , data : $ ( $ _o . formObj ) . serialize ( ) , success : function ( data ) { if ( data . code == 1 ) { data = data . data ; if ( data && data . content _sign ) { var contentSign = data . content _sign ; if ( $ _o . $ _cp . page _is _list ( $ _o . curPageType ) ) { var namePre = $ _o . $ _cp . get _page _vars ( $ _o . curPageType , 'namePre' ) ; var pageTypeConfig = $ _o . curPageConfig [ namePre ] ; if ( ! isObject ( pageTypeConfig . content _signs ) ) { pageTypeConfig . content _signs = [ ] }
contentSign . _objid = data . objid ; pageTypeConfig . content _signs . push ( contentSign ) ; $ _o . curPageConfig [ namePre ] = pageTypeConfig } else { $ _o . page _add ( $ _o . curPageType , data . objid , contentSign ) } }
$ ( '#myModal' ) . modal ( 'hide' ) } else { toastr . error ( data . msg ) } } , error : function ( data ) { toastr . error ( data ) } } ) ; return ! 1 } }
function cpRuleModuleInit ( boxId , name , namePre ) { namePre = namePre ? namePre : '' ; $ ( boxId + ' [name="' + name + '[' + namePre + 'rule_multi]"]' ) . bind ( 'change' , function ( ) { if ( $ ( this ) . is ( ':checked' ) ) { $ ( boxId + ' #c_p_' + name + '_' + namePre + 'rule_multi_str' ) . show ( ) } else { $ ( boxId + ' #c_p_' + name + '_' + namePre + 'rule_multi_str' ) . hide ( ) } } ) ; 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 + ' #c_p_' + name + '_' + namePre + 'xpath_multi_str' ) . show ( ) } else { $ ( boxId + ' #c_p_' + name + '_' + namePre + 'xpath_multi_str' ) . hide ( ) } } ) ; $ ( boxId + ' select[name="' + name + '[' + namePre + 'json_arr]"]' ) . bind ( 'change' , function ( ) { if ( $ ( this ) . val ( ) == 'implode' ) { $ ( boxId + ' #c_p_' + name + '_' + namePre + 'json_arr_implode' ) . show ( ) } else { $ ( boxId + ' #c_p_' + name + '_' + namePre + 'json_arr_implode' ) . hide ( ) } } ) }
function cpRuleModuleInit ( 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 ( '.p-m-api-rule-module' ) . eq ( 0 ) ; if ( $ ( this ) . is ( ':checked' ) ) { prt . find ( '.p-m-api-rule-multi-str' ) . show ( ) } else { prt . find ( '.p-m-api-rule-multi-str' ) . hide ( ) } } ) ; 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 ( '.p-m-api-rule-module' ) . eq ( 0 ) ; if ( $ ( this ) . is ( ':checked' ) ) { prt . find ( '.p-m-api-xpath-multi-str' ) . show ( ) } else { prt . find ( '.p-m-api-xpath-multi-str' ) . hide ( ) } } ) ; $ ( boxId ) . on ( 'change' , 'select[data-process="' + namePre + 'json_arr"]' , function ( ) { var prt = $ ( this ) . parents ( '.p-m-api-rule-module' ) . eq ( 0 ) ; if ( $ ( this ) . val ( ) == 'implode' ) { prt . find ( '.p-m-api-json-arr-implode' ) . show ( ) } else { prt . find ( '.p-m-api-json-arr-implode' ) . hide ( ) } } ) ; $ ( boxId ) . on ( 'click' , 'a[data-rule-sign]' , function ( ) { var prt = $ ( this ) . parents ( '.p-m-api-rule-module' ) . eq ( 0 ) ; var obj = prt . find ( '[data-process="' + namePre + '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="' + namePre + 'rule_merge"]' ) ; ruleInsertSign . matchN ( obj , ruleMerge , { def : 1 } ) } } ) } else { $ ( boxId + ' [name="' + name + '[' + namePre + 'rule_multi]"]' ) . bind ( 'change' , function ( ) { if ( $ ( this ) . is ( ':checked' ) ) { $ ( boxId + ' #c_p_' + name + '_' + namePre + 'rule_multi_str' ) . show ( ) } else { $ ( boxId + ' #c_p_' + name + '_' + namePre + 'rule_multi_str' ) . hide ( ) } } ) ; 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 + ' #c_p_' + name + '_' + namePre + 'xpath_multi_str' ) . show ( ) } else { $ ( boxId + ' #c_p_' + name + '_' + namePre + 'xpath_multi_str' ) . hide ( ) } } ) ; $ ( boxId + ' select[name="' + name + '[' + namePre + 'json_arr]"]' ) . bind ( 'change' , function ( ) { if ( $ ( this ) . val ( ) == 'implode' ) { $ ( boxId + ' #c_p_' + name + '_' + namePre + 'json_arr_implode' ) . show ( ) } else { $ ( boxId + ' #c_p_' + name + '_' + namePre + 'json_arr_implode' ) . hide ( ) } } ) } }
function cpRuleModuleLoad ( boxId , name , namePre , config ) { namePre = namePre ? namePre : '' ; if ( 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]"][value="' + ( config [ namePre + 'rule_multi_type' ] ? config [ namePre + 'rule_multi_type' ] : '' ) + '"]' ) . prop ( 'checked' , ! 0 ) ; $ ( boxId + ' [name="' + name + '[' + namePre + 'xpath]"]' ) . val ( config [ namePre + 'xpath' ] ) ; if ( config [ namePre + 'xpath_multi' ] ) { $ ( boxId + ' [name="' + name + '[' + namePre + 'xpath_multi]"]' ) . prop ( 'checked' , ! 0 ) . trigger ( 'change' ) }
$ ( boxId + ' [name="' + name + '[' + namePre + 'xpath_multi_type]"][value="' + ( config [ namePre + 'xpath_multi_type' ] ? config [ namePre + 'xpath_multi_type' ] : '' ) + '"]' ) . prop ( 'checked' , ! 0 ) ; 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' ] ) } }
function cpRuleTips ( isPage ) { var tips = '<p>1、规则中的特殊字符:<b>^$.*+|?[]{}()</b> 必须加上“\\”才能转义为字符,否则会识别为正则符号</p><p>2、[内容]标签的标识可由数字、字母及下划线组成</p>' ; if ( isPage ) { tips += '<p>3、页面级别:多级页 > 多级页子页 > 内容页 > 关联页 > 关联页子页</p>' ; tips += '<p>4、[内容]标签可全局调用,但只能调用比自己级别高的页面中的标签,即内容页可调用多级页中的标签而不能调用关联页中的标签</p>' ; tips += '<p>5、同一页面中有相同标识的[内容]标签时,后面的标签会覆盖前面的同名标签。不同页面中有相同标识的[内容]标签时,低级别页面会覆盖高级别页面中的同名标签</p>' }
confirmRight ( { msg : tips , yes : '确定' , width : 500 , textAlign : 'left' } ) }
function cpDelimiterTips ( ) { var tips = '<p>如需使用换行符,请注意区别:</p><p>文本换行符:<b>\\r\\n</b>(适用于系统文件中)</p><p>标签换行符:<b><br /></b>(适用于网页HTML中)</p>' ; confirmRight ( { msg : tips , yes : '确定' , width : 350 , textAlign : 'left' } ) }
function cpMatch ( 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}' , '' ) }
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 ) ; insertAtCaret ( $ ( toObj ) , sign ) } }
function cpMatchN ( 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 ) { 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 ) { insertAtCaret ( $ ( toObj ) , sign ) } } } }
if ( ! toObj ) { return returnList } }
function cpWildcard ( toObj , options ) { if ( ! options ) { options = { } }
var wildcard = window . tpl _lang . sign _wildcard ; if ( options . only ) { if ( $ ( toObj ) . val ( ) . indexOf ( wildcard ) < 0 ) { insertAtCaret ( $ ( toObj ) , wildcard ) } } else { insertAtCaret ( $ ( toObj ) , wildcard ) } }
function cpDelimiterTips ( ) { var tips = '<p>如需使用换行符,请注意区别:</p><p>文本换行符:<b>\\r\\n</b>(适用于系统文件中)</p><p>标签换行符:<b><br /></b>(适用于网页HTML中)</p>' ; confirmRight ( { msg : tips , yes : '确定' , width : 350 , textAlign : 'left' } ) }