@ -8,9 +8,14 @@
| -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
* /
'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 + ' #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?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_&type=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 _encode ) + '"]' ) . 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 ) } }
CollectorPattern . prototype = { constructor : CollectorPattern , 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 ) ) ; settings . data = { '_post_data_' : settings . data } ; 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 ( ) ) { $ ( '#coll_pattern_source_url' ) . css ( 'margin-bottom' , '0px' ) ; $ ( '#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 { $ ( '#coll_pattern_source_url' ) . css ( 'margin-bottom' , '15px' ) ; $ ( '#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?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_&type=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 ) } , 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 _echo _url _msg : function ( dataUrlWeb , dataRenderer ) { this . init _test ( ) ; if ( ! isObject ( dataUrlWeb ) ) { dataUrlWeb = { } }
if ( ! isObject ( dataRenderer ) ) { dataRenderer = { } }
var hasUrlWeb = ! 1 ; for ( var i in dataUrlWeb ) { hasUrlWeb = ! 0 }
var hasRenderer = ! 1 ; for ( var i in dataRenderer ) { hasRenderer = ! 0 }
this . cpUrlWeb . page _load ( 'test' , dataUrlWeb ) ; this . cpRenderer . page _load ( 'test' , dataRenderer ) ; var urlWebForm = $ ( '.c-p-url-web-form' ) . parents ( '.form-group' ) . eq ( 0 ) ; var urlWebBox = urlWebForm . parents ( '.panel[id]' ) . eq ( 0 ) ; if ( hasUrlWeb ) { urlWebBox = urlWebBox . find ( '.panel-body' ) . eq ( 0 ) ; urlWebBox . html ( urlWebForm ) } else { urlWebBox . hide ( ) }
var rendererList = $ ( '.c-p-url-renderer-list' ) . parents ( '.form-group' ) . eq ( 0 ) ; var rendererBox = rendererList . parents ( '.panel[id]' ) . eq ( 0 ) ; if ( hasRenderer ) { rendererBox = rendererBox . find ( '.panel-body' ) . eq ( 0 ) ; rendererBox . html ( rendererList ) } else { rendererBox . hide ( ) } } , 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 _encode ) + '"]' ) . 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 ) }
@ -31,7 +36,8 @@ if(config.request_headers.img>0){showPanelCollapse('#coll_pattern_request_header
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' }
$ ( this . formid + ' [name="effective_edit"]' ) . val ( 1 ) } , get _page _vars : function ( pageType , returnKey , isPagination ) { 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' }
if ( isPagination ) { boxId += '_pagination' ; namePre += '[pagination]' }
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 ] ) }
toastr . success ( pageVars . title + '复制成功:' + data [ pageType ] . name ) } else { toastr . error ( data . msg ) } } } ) } ) } ) ; $ ( $ _o . formid + ' ' + listObj ) . on ( 'click' , '.delete' , function ( ) { var curObj = $ ( this ) ; confirmRight ( '确定删除?' , function ( ) { curObj . parents ( parentObj ) . eq ( 0 ) . remove ( ) } ) } ) ; eleExchange ( $ _o . formid + ' ' + listObj , '.icon-drag-move' , 'tbody tr' ) } , init _page : function ( pageType ) { var $ _o = this ; var pageVars = $ _o . get _page _vars ( pageType ) ; var formId = pageVars . formId ; var boxId = pageVars . boxId ; var namePre = pageVars . namePre ; if ( ! formId || ! boxId || ! namePre ) { return }
@ -47,7 +53,8 @@ $_o.cpUrlWeb.page_load(pageType,config.url_web);$_o.cpRenderer.page_load(pageTyp
$ ( this ) . parents ( 'div[source-param]' ) . find ( 'input[name="source[param]"]' ) . prop ( 'checked' , ! 0 ) } ) ; if ( params . source ) { $ ( formObj + ' .nav-tabs' ) . find ( 'a[source-type="' + params . source . type + '"]' ) . click ( ) ; if ( params . source . type == 'custom' ) { $ ( formObj + ' textarea[name="source[urls]"]' ) . val ( params . source . urls ) } else if ( params . source . type == 'batch' ) { $ ( formObj + ' input[name="source[url]"]' ) . val ( params . source . url ) ; var param _type = params . source . param ; if ( param _type == 'num' ) { $ ( formObj + ' input[name="source[param_num_start]"]' ) . val ( params . source . param _num _start ) ; $ ( formObj + ' input[name="source[param_num_end]"]' ) . val ( params . source . param _num _end ) ; $ ( formObj + ' input[name="source[param_num_inc]"]' ) . val ( params . source . param _num _inc ) ; if ( params . source . param _num _desc ) { $ ( formObj + ' input[name="source[param_num_desc]"]' ) . prop ( 'checked' , ! 0 ) } } else if ( param _type == 'letter' ) { $ ( formObj + ' input[name="source[param_letter_start]"]' ) . val ( params . source . param _letter _start ) ; $ ( formObj + ' input[name="source[param_letter_end]"]' ) . val ( params . source . param _letter _end ) ; if ( params . source . param _letter _desc ) { $ ( formObj + ' input[name="source[param_letter_desc]"]' ) . prop ( 'checked' , ! 0 ) } } else if ( param _type == 'custom' ) { $ ( formObj + ' textarea[name="source[param_custom]"]' ) . val ( params . source . param _custom ) }
$ ( formObj + ' input[name="source[param]"][value="' + param _type + '"]' ) . prop ( 'checked' , ! 0 ) } else if ( params . source . type == 'large' ) { $ ( formObj + ' textarea[name="source[large_urls]"]' ) . val ( params . source . large _urls ) } else if ( params . source . type == 'api' ) { $ ( formObj + ' input[name="source[api]"]' ) . val ( params . source . api ) ; $ ( formObj + ' input[name="source[api_json]"]' ) . val ( params . source . api _json ) } } } else if ( op == 'add' ) { var html = '' ; if ( params . html ) { html = params . html } else { var htmlObj = $ _o . clone _tpl ( '#coll_tpl_source_url' ) ; htmlObj . find ( '[data-id="source_url_"]' ) . attr ( 'id' , 'source_url_' + generateUUID ( ) ) . removeAttr ( 'data-id' ) ; var regLarge = /[\r\n]/ ; if ( regLarge . test ( params . source _url ) ) { htmlObj . find ( 'input[name="config[source_url][]"]' ) . remove ( ) } else { htmlObj . find ( 'textarea[name="config[source_url][]"]' ) . remove ( ) }
html = htmlObj . html ( ) ; html = html ? html : '' ; html = html . replace ( '[_source_url_]' , htmlspecialchars ( params . source _url ) ) }
if ( params . get ) { return html } else { this . source _op ( 'clear_null' ) ; $ ( $ _o . formid + ' #coll_pattern_source_url .c-p-source-urls' ) . append ( html ) } } else if ( op == 'add_sub' ) { ajaxOpen ( { type : 'POST' , dataType : 'json' , url : $ ( formObj ) . attr ( 'action' ) , data : $ ( formObj ) . serialize ( ) , success : function ( data ) { var dataList = data . data ? data . data : { } ; var objid = dataList . objid ? dataList . objid : '' ; var addParams = { } ; if ( data . code == 1 ) { var source _type = $ ( formObj ) . find ( 'input[name="source[type]"]' ) . val ( ) ; if ( source _type == 'custom' ) { $ ( '#myModal' ) . modal ( 'hide' ) ; var urls = dataList . urls ; var ix = 0 ; var url _html _list = '' ; for ( var i in urls ) { addParams . get = 1 ; addParams . source _url = urls [ i ] ; ix ++ ; if ( ix == 1 ) { if ( objid ) { var newSource = $ _o . source _op ( 'add' , addParams ) ; $ ( '#' + objid ) . replaceWith ( newSource ) ; continue } }
if ( params . get ) { return html } else { this . source _op ( 'clear_null' ) ; $ ( $ _o . formid + ' #coll_pattern_source_url .c-p-source-urls' ) . append ( html ) } } else if ( op == 'add_sub' ) { ajaxOpen ( { type : 'POST' , dataType : 'json' , url : $ ( formObj ) . attr ( 'action' ) , data : $ ( formObj ) . serialize ( ) , success : function ( data ) { var dataList = data . data ? data . data : { } ; var objid = dataList . objid ? dataList . objid : '' ; var addParams = { } ; if ( data . code == 1 ) { var source _type = $ ( formObj ) . find ( 'input[name="source[type]"]' ) . val ( ) ; if ( source _type == 'custom' && isObject ( dataList . urls ) && dataList . urls . length > 20 ) { source _type = 'large' }
if ( source _type == 'custom' ) { $ ( '#myModal' ) . modal ( 'hide' ) ; var urls = dataList . urls ; var ix = 0 ; var url _html _list = '' ; for ( var i in urls ) { addParams . get = 1 ; addParams . source _url = urls [ i ] ; ix ++ ; if ( ix == 1 ) { if ( objid ) { var newSource = $ _o . source _op ( 'add' , addParams ) ; $ ( '#' + objid ) . replaceWith ( newSource ) ; continue } }
url _html _list += $ _o . source _op ( 'add' , addParams ) }
if ( url _html _list ) { $ _o . source _op ( 'add' , { html : url _html _list } ) } } else if ( source _type == 'batch' ) { if ( params . preview == 1 ) { var urls = dataList . urls ; var txt = '' ; for ( var i in urls ) { txt += urls [ i ] + "\r\n" }
$ ( formObj ) . find ( '#source_preview' ) . val ( txt ) } else { if ( objid ) { addParams . get = 1 ; addParams . source _url = dataList . url ; var newSource = $ _o . source _op ( 'add' , addParams ) ; $ ( '#' + objid ) . replaceWith ( newSource ) } else { addParams . source _url = dataList . url ; $ _o . source _op ( 'add' , addParams ) }
@ -70,16 +77,18 @@ if(returnMergeSigns){var mergeSigns=[];for(var i in signs.area){var curSign=sign
for ( var i in signs . url ) { var curSign = signs . url [ i ] ; if ( mergeSigns . indexOf ( curSign ) <= - 1 && signs . content . indexOf ( curSign ) <= - 1 ) { mergeSigns . push ( curSign ) } }
for ( var i in signs . content ) { var curSign = signs . content [ i ] ; if ( mergeSigns . indexOf ( curSign ) <= - 1 ) { mergeSigns . push ( curSign ) } }
return mergeSigns } else { return signs } } , parent _page _signs : function ( dropdownBtn ) { var $ _o = this ; var boxObj = $ ( dropdownBtn ) . parents ( '.c-p-url-page-signs' ) . eq ( 0 ) ; if ( ! boxObj || boxObj . length <= 0 ) { return }
var pageType = boxObj . attr ( 'data-page-type' ) ; var inputName = boxObj . attr ( 'data-input-name' ) ; var pageVars = $ _o . get _page _vars ( pageType ) ; var formId = pageVars . formId ; var namePre = pageVars . namePre ; if ( ! pageType || ! inputName || ! formId ) { return }
var pageType = boxObj . attr ( 'data-page-type' ) ; var inputName = boxObj . attr ( 'data-input-name' ) ; var isPagination = boxObj . attr ( 'data-is-pagination' ) ; var pageVars = $ _o . get _page _vars ( pageType ) ; var formId = pageVars . formId ; var namePre = pageVars . namePre ; if ( ! pageType || ! inputName || ! formId ) { return }
var dropdownMenu = boxObj . find ( '.dropdown-menu' ) ; if ( dropdownMenu . length > 0 ) { $ ( dropdownMenu ) . html ( '' ) }
var iptObj = boxObj . find ( '[name="' + inputName + '"]' ) ; if ( ! iptObj || iptObj . length <= 0 ) { iptObj = null }
var frontUrls = new Array ( ) ; $ ( '#c_p_front_urls [id^="front_url_"]' ) . each ( function ( ) { var frontUrl = $ ( this ) . find ( '[name="config[front_urls][]"]' ) . val ( ) ; frontUrls . push ( frontUrl ) } ) ; var levelUrls = new Array ( ) ; $ ( '#c_p_level_urls [id^="level_url_"]' ) . each ( function ( ) { var levelUrl = $ ( this ) . find ( '[name="config[level_urls][]"]' ) . val ( ) ; levelUrls . push ( levelUrl ) } ) ; var relationUrls = new Array ( ) ; $ ( '#c_p_relation_urls [id^="relation_url_"]' ) . each ( function ( ) { var relationUrl = $ ( this ) . find ( '[name="config[relation_urls][]"]' ) . val ( ) ; relationUrls . push ( relationUrl ) } ) ; var sourceConfig = { } ; sourceConfig . area = '' ; sourceConfig . url _rule = '' ; sourceConfig . content _signs = $ _o . get _content _signs ( $ _o . formid + ' [name="config[source_config][content_signs][]"]' ) ; var urlConfig = { } ; urlConfig . area = $ ( $ _o . formid + ' [name="config[area]' ) . val ( ) ; urlConfig . url _rule = $ ( $ _o . formid + ' [name="config[url_rule]"]' ) . val ( ) ; urlConfig . content _signs = $ _o . get _content _signs ( $ _o . formid + ' [name="config[content_signs][]"]' ) ; var pageConfig = { name : '' , area : '' , url _rule : '' , content _signs : '' } ; var mergeType = iptObj . attr ( 'data-merge-type' ) ; mergeType = mergeType ? mergeType : '' ; if ( $ _o . page _is _list ( pageType ) ) { var objid = '' ; if ( mergeType == 'content_sign' ) { var csPageConfig = $ _o . cpContentSign . curPageConfig ; objid = csPageConfig . objid ; if ( pageType == 'relation_url' ) { pageConfig . page = csPageConfig . relation _url . page }
var frontUrls = new Array ( ) ; $ ( '#c_p_front_urls [id^="front_url_"]' ) . each ( function ( ) { var frontUrl = $ ( this ) . find ( '[name="config[front_urls][]"]' ) . val ( ) ; frontUrls . push ( frontUrl ) } ) ; var levelUrls = new Array ( ) ; $ ( '#c_p_level_urls [id^="level_url_"]' ) . each ( function ( ) { var levelUrl = $ ( this ) . find ( '[name="config[level_urls][]"]' ) . val ( ) ; levelUrls . push ( levelUrl ) } ) ; var relationUrls = new Array ( ) ; $ ( '#c_p_relation_urls [id^="relation_url_"]' ) . each ( function ( ) { var relationUrl = $ ( this ) . find ( '[name="config[relation_urls][]"]' ) . val ( ) ; relationUrls . push ( relationUrl ) } ) ; var sourceConfig = { } ; sourceConfig . area = '' ; sourceConfig . url _rule = '' ; sourceConfig . content _signs = $ _o . get _content _signs ( $ _o . formid + ' [name="config[source_config][content_signs][]"]' ) ; if ( isPagination ) { sourceConfig . pagination = { area : $ ( $ _o . formid ) . find ( '[name="config[source_config][pagination][area]"]' ) . val ( ) , url _rule : $ ( $ _o . formid ) . find ( '[name="config[source_config][pagination][url_rule]"]' ) . val ( ) } }
var urlConfig = { } ; urlConfig . area = $ ( $ _o . formid + ' [name="config[area]"]' ) . val ( ) ; urlConfig . url _rule = $ ( $ _o . formid + ' [name="config[url_rule]"]' ) . val ( ) ; urlConfig . content _signs = $ _o . get _content _signs ( $ _o . formid + ' [name="config[content_signs][]"]' ) ; if ( isPagination ) { urlConfig . pagination = { area : $ ( $ _o . formid ) . find ( '[name="config[pagination][area]"]' ) . val ( ) , url _rule : $ ( $ _o . formid ) . find ( '[name="config[pagination][url_rule]"]' ) . val ( ) } }
var pageConfig = { name : '' , area : '' , url _rule : '' , content _signs : '' } ; var mergeType = iptObj . attr ( 'data-merge-type' ) ; mergeType = mergeType ? mergeType : '' ; if ( $ _o . page _is _list ( pageType ) ) { var objid = '' ; if ( mergeType == 'content_sign' ) { var csPageConfig = $ _o . cpContentSign . curPageConfig ; objid = csPageConfig . objid ; if ( pageType == 'relation_url' ) { pageConfig . page = csPageConfig . relation _url . page }
pageConfig . area = csPageConfig [ namePre ] . area ; pageConfig . url _rule = csPageConfig [ namePre ] . url _rule ; pageConfig . content _signs = csPageConfig [ namePre ] . content _signs } else { objid = $ ( formId ) . find ( '[name="objid"]' ) . val ( ) ; if ( pageType == 'relation_url' ) { pageConfig . page = $ ( formId ) . find ( '[name="relation_url[page]"]' ) . val ( ) }
pageConfig . area = $ ( formId ) . find ( '[name="' + namePre + '[area]"]' ) . val ( ) ; pageConfig . url _rule = $ ( formId ) . find ( '[name="' + namePre + '[url_rule]"]' ) . val ( ) ; pageConfig . content _signs = $ _o . get _content _signs ( formId + ' [name="' + namePre + '[content_signs][]"]' ) }
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 : '' }
pageConfig . name = pageConfig . name ? pageConfig . name : '' ; pageConfig . area = pageConfig . area ? pageConfig . area : '' ; pageConfig . url _rule = pageConfig . url _rule ? pageConfig . url _rule : '' ; if ( isPagination ) { pageConfig . pagination = { area : $ ( formId ) . find ( '[name="' + namePre + '[pagination][area]"]' ) . val ( ) , url _rule : $ ( formId ) . find ( '[name="' + namePre + '[pagination][url_rule]"]' ) . val ( ) } } }
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 = ruleInsertSign . matchN ( 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 , is _pagination : isPagination } , 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 . matchN ( 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>' }
@ -111,9 +120,9 @@ objEle.find('.name').attr('data-val',relation_url.name).text(relation_url.name);
if ( checkName ) { var hasName = ! 1 ; $ ( '#c_p_relation_urls [id^="relation_url_"] .name' ) . each ( function ( ) { if ( $ ( $ _o . formObj + ' [name="relation_url[name]"]' ) . val ( ) == $ ( this ) . attr ( 'data-val' ) ) { hasName = ! 0 ; return ! 1 } } ) ; if ( hasName ) { toastr . error ( '该名称已存在!' ) ; return ! 1 } }
ajaxOpen ( { type : 'POST' , dataType : 'json' , url : $ ( $ _o . formObj ) . attr ( 'action' ) , data : $ ( $ _o . formObj ) . serialize ( ) , success : function ( data ) { if ( data . code == 1 ) { $ ( '#myModal' ) . modal ( 'hide' ) ; data = data . data ; if ( data ) { $ _o . add ( data . objid , data . relation _url ) } } else { toastr . error ( data . msg ) } } , error : function ( data ) { toastr . error ( data ) } } ) ; return ! 1 } }
function CpUrlWeb ( cpClass ) { this . $ _cp = cpClass }
CpUrlWeb . prototype = { constructor : CpUrlWeb , page _init : function ( pageType ) { var $ _o = this ; var pageVars = $ _o . $ _cp . get _page _vars ( pageType ) ; var boxId = pageVars . boxId ; var namePre = pageVars . namePre ; if ( ! boxId || ! namePre ) { return }
CpUrlWeb . prototype = { constructor : CpUrlWeb , page _init : function ( pageType , isPagination ) { var $ _o = this ; var pageVars = $ _o . $ _cp . get _page _vars ( pageType , null , isPagination ) ; var boxId = pageVars . boxId ; var namePre = pageVars . namePre ; if ( ! boxId || ! namePre ) { return }
var boxUrlWebId = boxId + '_web' ; $ ( boxUrlWebId + ' [name="' + namePre + '[url_web][open]"]' ) . bind ( 'click' , function ( ) { if ( $ ( this ) . val ( ) == 1 ) { $ ( boxUrlWebId + '_open' ) . show ( ) } else { $ ( boxUrlWebId + '_open' ) . hide ( ) }
$ _o . def _config _use _url _web ( pageType ) } ) ; inputSelectCustom ( boxUrlWebId + ' select[name="' + namePre + '[url_web][charset]"]' , namePre + '[url_web][charset_custom]' ) ; inputSelectCustom ( boxUrlWebId + ' select[name="' + namePre + '[url_web][encode]"]' , namePre + '[url_web][encode_custom]' ) ; $ _o . def _config _charset ( pageType ) ; $ _o . def _config _encode ( pageType ) ; $ ( boxUrlWebId + ' select[name="' + namePre + '[url_web][form_method]"]' ) . bind ( 'change' , function ( ) { var obj = $ ( boxUrlWebId + ' .c-p-url-web-content-type' ) ; if ( $ ( this ) . val ( ) == 'post' ) { obj . show ( ) } else { obj . hide ( ) } } ) ; $ _o . def _config _header _global ( pageType ) ; $ ( boxUrlWebId + ' .add-url-web-form' ) . bind ( 'click' , function ( ) { $ _o . add _page _url _web ( pageType , 'form', '' , '' ) } ) ; $ ( boxUrlWebId + ' .c-p-url-web-form' ) . on ( 'click' , '.delete-url-web-form' , function ( ) { $ ( this ) . parents ( 'tr' ) . eq ( 0 ) . remove ( ) } ) ; $ ( boxUrlWebId + ' .add-url-web-header' ) . bind ( 'click' , function ( ) { $ _o . add _page _url _web ( pageType , 'header', '' , '' ) } ) ; $ ( boxUrlWebId + ' .c-p-url-web-header' ) . on ( 'click' , '.delete-url-web-header' , function ( ) { $ ( this ) . parents ( 'tr' ) . eq ( 0 ) . remove ( ) } ) } , page _load : function ( pageType , urlWebConfig ) { var $ _o = this ; var pageVars = $ _o . $ _cp . get _page _vars ( pageType ) ; var formId = pageVars . formId ; var boxId = pageVars . boxId ; var namePre = pageVars . namePre ; if ( ! formId || ! boxId || ! namePre ) { return }
$ _o . def _config _use _url _web ( pageType ) } ) ; inputSelectCustom ( boxUrlWebId + ' select[name="' + namePre + '[url_web][charset]"]' , namePre + '[url_web][charset_custom]' ) ; inputSelectCustom ( boxUrlWebId + ' select[name="' + namePre + '[url_web][encode]"]' , namePre + '[url_web][encode_custom]' ) ; $ _o . def _config _charset ( pageType ) ; $ _o . def _config _encode ( pageType ) ; $ ( boxUrlWebId + ' select[name="' + namePre + '[url_web][form_method]"]' ) . bind ( 'change' , function ( ) { var obj = $ ( boxUrlWebId + ' .c-p-url-web-content-type' ) ; if ( $ ( this ) . val ( ) == 'post' ) { obj . show ( ) } else { obj . hide ( ) } } ) ; $ _o . def _config _header _global ( pageType ) ; $ ( boxUrlWebId + ' .add-url-web-form' ) . bind ( 'click' , function ( ) { $ _o . add _page _url _web ( pageType , isPagination , 'form', '' , '' ) } ) ; $ ( boxUrlWebId + ' .c-p-url-web-form' ) . on ( 'click' , '.delete-url-web-form' , function ( ) { $ ( this ) . parents ( 'tr' ) . eq ( 0 ) . remove ( ) } ) ; $ ( boxUrlWebId + ' .add-url-web-header' ) . bind ( 'click' , function ( ) { $ _o . add _page _url _web ( pageType , isPagination , 'header', '' , '' ) } ) ; $ ( boxUrlWebId + ' .c-p-url-web-header' ) . on ( 'click' , '.delete-url-web-header' , function ( ) { $ ( this ) . parents ( 'tr' ) . eq ( 0 ) . remove ( ) } ) } , page _load : function ( pageType , urlWebConfig , isPagination ) { var $ _o = this ; var pageVars = $ _o . $ _cp . get _page _vars ( pageType , null , isPagination ) ; var formId = pageVars . formId ; var boxId = pageVars . boxId ; var namePre = pageVars . namePre ; if ( ! formId || ! boxId || ! namePre ) { return }
if ( ! isObject ( urlWebConfig ) ) { urlWebConfig = { } }
var urlWebNamePre = namePre + '[url_web]' ; urlWebConfig . open = toInt ( urlWebConfig . open ) ; $ ( formId + ' [name="' + urlWebNamePre + '[open]"][value="' + urlWebConfig . open + '"]' ) . trigger ( 'click' ) ; if ( urlWebConfig . open > 0 ) { showPanelCollapse ( boxId + '_web' ) }
if ( urlWebConfig . charset ) { $ ( formId + ' select[name="' + urlWebNamePre + '[charset]"]' ) . val ( urlWebConfig . charset ) . trigger ( 'change' ) }
@ -122,10 +131,10 @@ if(urlWebConfig.encode){$(formId+' select[name="'+urlWebNamePre+'[encode]"]').va
if ( urlWebConfig . encode _custom ) { $ ( formId + ' [name="' + urlWebNamePre + '[encode_custom]"]' ) . val ( urlWebConfig . encode _custom ) }
if ( urlWebConfig . form _method ) { $ ( formId + ' [name="' + urlWebNamePre + '[form_method]"]' ) . val ( urlWebConfig . form _method ) . trigger ( 'change' ) }
if ( urlWebConfig . content _type ) { $ ( formId + ' [name="' + urlWebNamePre + '[content_type]"]' ) . val ( urlWebConfig . content _type ) }
if ( urlWebConfig . form _names ) { var urlWebFormVals = urlWebConfig . form _vals ? urlWebConfig . form _vals : { } ; for ( var i in urlWebConfig . form _names ) { $ _o . add _page _url _web ( pageType , 'form', urlWebConfig . form _names [ i ] , urlWebFormVals [ i ] ) } }
if ( urlWebConfig . form _names ) { var urlWebFormVals = urlWebConfig . form _vals ? urlWebConfig . form _vals : { } ; for ( var i in urlWebConfig . form _names ) { $ _o . add _page _url _web ( pageType , isPagination , 'form', urlWebConfig . form _names [ i ] , urlWebFormVals [ i ] ) } }
if ( urlWebConfig . header _global ) { $ ( formId + ' [name="' + urlWebNamePre + '[header_global]"][value="' + urlWebConfig . header _global + '"]' ) . prop ( 'checked' , ! 0 ) }
if ( urlWebConfig . header _names ) { var urlWebHeaderVals = urlWebConfig . header _vals ? urlWebConfig . header _vals : { } ; for ( var i in urlWebConfig . header _names ) { $ _o . add _page _url _web ( pageType , 'header', urlWebConfig . header _names [ i ] , urlWebHeaderVals [ i ] ) } } } , add _page _url _web : function ( pageType , type , name , val ) { var $ _o = this ; var pageVars = $ _o . $ _cp . get _page _vars ( pageType ) ; var boxId = pageVars . boxId ; var namePre = pageVars . namePre ; if ( ! boxId || ! namePre || ! type ) { return }
boxId += '_web' ; name = name ? name : '' ; val = val ? val : '' ; var tr = $ _o . $ _cp . clone _tpl ( '#coll_tpl_url_web_' + type , namePre ) ; tr . find ( '[name="' + namePre + '[url_web][' + type + '_names][]"]' ) . val ( name ) ; tr . find ( '[name="' + namePre + '[url_web][' + type + '_vals][]"]' ) . val ( val ) ; tr . find ( '.c-p-url-page-signs' ) . each ( function ( ) { $ ( this ) . attr ( 'data-page-type' , pageType ) . attr ( 'data-input-name' , namePre + $ ( this ) . attr ( 'data-input-name' ) ) } ) ; $ ( boxId ) . find ( '.c-p-url-web-' + type + ' tbody' ) . append ( tr ) } , def _config _charset : function ( pageType ) { var $ _o = this ; var val = $ ( $ _o . $ _cp . formid + ' [name="config[charset]"]' ) . val ( ) ; var formid = $ _o . $ _cp . formid ; if ( pageType ) { formid = $ _o . $ _cp . get _page _vars ( pageType , 'formId' ) }
if ( urlWebConfig . header _names ) { var urlWebHeaderVals = urlWebConfig . header _vals ? urlWebConfig . header _vals : { } ; for ( var i in urlWebConfig . header _names ) { $ _o . add _page _url _web ( pageType , isPagination , 'header', urlWebConfig . header _names [ i ] , urlWebHeaderVals [ i ] ) } } } , add _page _url _web : function ( pageType , isPagination , type , name , val ) { var $ _o = this ; var pageVars = $ _o . $ _cp . get _page _vars ( pageType , null , isPagination ) ; var boxId = pageVars . boxId ; var namePre = pageVars . namePre ; if ( ! boxId || ! namePre || ! type ) { return }
boxId += '_web' ; name = name ? name : '' ; val = val ? val : '' ; var tr = $ _o . $ _cp . clone _tpl ( '#coll_tpl_url_web_' + type , namePre ) ; tr . find ( '[name="' + namePre + '[url_web][' + type + '_names][]"]' ) . val ( name ) ; tr . find ( '[name="' + namePre + '[url_web][' + type + '_vals][]"]' ) . val ( val ) ; tr . find ( '.c-p-url-page-signs' ) . each ( function ( ) { $ ( this ) . attr ( 'data-page-type' , pageType ) . attr ( 'data-input-name' , namePre + $ ( this ) . attr ( 'data-input-name' ) ) ; if ( isPagination ) { $ ( this ) . attr ( 'data-is-pagination' , 1 ) } } ) ; $ ( boxId ) . find ( '.c-p-url-web-' + type + ' tbody' ) . append ( tr ) } , def _config _charset : function ( pageType ) { var $ _o = this ; var val = $ ( $ _o . $ _cp . formid + ' [name="config[charset]"]' ) . val ( ) ; var formid = $ _o . $ _cp . formid ; if ( pageType ) { formid = $ _o . $ _cp . get _page _vars ( pageType , 'formId' ) }
if ( ! val || val == 'auto' ) { val = '自动检测' } else if ( val == 'custom' ) { if ( $ _o . $ _cp . page _is _list ( pageType ) ) { val = $ ( $ _o . $ _cp . formid + ' [name="config[charset_custom]"]' ) . val ( ) ; val = val ? val : '' } else { val = '' }
val = '自定义' + ( val ? ( '»' + htmlspecialchars ( val ) ) : '' ) }
$ ( formid ) . find ( '.def-config-charset' ) . html ( '默认:' + val ) } , def _config _encode : function ( pageType ) { var $ _o = this ; var val = $ ( $ _o . $ _cp . formid + ' [name="config[encode]"]' ) . val ( ) ; var formid = $ _o . $ _cp . formid ; if ( pageType ) { formid = $ _o . $ _cp . get _page _vars ( pageType , 'formId' ) }
@ -135,22 +144,26 @@ $(formid).find('.def-config-encode').html('默认:'+val)},def_config_header_gl
$ ( formid ) . find ( '.def-config-request-headers-open' ) . html ( val > 0 ? '是' : '否' ) } , def _config _use _url _web : function ( pageType ) { var $ _o = this ; var pageVars = $ _o . $ _cp . get _page _vars ( pageType ) ; var formId = pageVars . formId ; var boxId = pageVars . boxId ; var namePre = pageVars . namePre ; if ( ! formId || ! boxId || ! namePre ) { return }
var urlWebOpen = $ ( formId ) . find ( '[name="' + namePre + '[url_web][open]"]:checked' ) . val ( ) ; urlWebOpen = toInt ( urlWebOpen ) ; $ ( boxId + '_pagination' ) . find ( '.def-config-url-web-open' ) . html ( urlWebOpen > 0 ? '是' : '否' ) } }
function CpRenderer ( cpClass ) { this . $ _cp = cpClass }
CpRenderer . prototype = { constructor : CpRenderer , page _init : function ( pageType ) { var $ _o = this ; var pageVars = $ _o . $ _cp . get _page _vars ( pageType ) ; var boxId = pageVars . boxId ; var namePre = pageVars . namePre ; if ( ! boxId || ! namePre ) { return }
$ _o . def _config _renderer _open ( pageType ) ; var rdBoxId = boxId + '_renderer' ; $ ( rdBoxId + ' .add-url-renderer' ) . bind ( 'click' , function ( ) { $ _o . add ( pageType ) } ) ; $ ( rdBoxId + ' [name="' + namePre + '[renderer][open]"]' ) . bind ( 'click' , function ( ) { $ _o . def _config _use _renderer ( pageType ) } ) ; $ ( rdBoxId + ' .c-p-url-renderer-list' ) . on ( 'change' , 'select[name="' + namePre + '[renderer][types][]"]' , function ( ) { var type = $ ( this ) . val ( ) ; var tr = $ ( this ) . parents ( 'tr' ) . eq ( 0 ) ; var types = { 'wait_time' : { content : 1 , content _tips : '输入数字' } , 'scroll_top' : { content : 1 , content _tips : '输入数字' } , 'click' : { element : 1 } , 'val' : { element : 1 , content : 1 , content _tips : '输入值' } } ; var tdTypeCols = 3 ; tr . find ( '.td-renderer-element,.td-renderer-content' ) . hide ( ) ; tr . find ( 'input[name="' + namePre + '[renderer][contents][]"]' ) . attr ( 'placeholder' , '' ) ; var curType = types [ type ] ; if ( isObject ( curType ) ) { if ( curType . element ) { tr . find ( '.td-renderer-element' ) . show ( ) ; tdTypeCols -= 1 }
CpRenderer . prototype = { constructor : CpRenderer , page _init : function ( pageType , isPagination ) { var $ _o = this ; var pageVars = $ _o . $ _cp . get _page _vars ( pageType , null , isPagination ) ; var boxId = pageVars . boxId ; var namePre = pageVars . namePre ; if ( ! boxId || ! namePre ) { return }
$ _o . def _config _renderer _open ( pageType ) ; var rdBoxId = boxId + '_renderer' ; $ ( rdBoxId + ' .add-url-renderer' ) . bind ( 'click' , function ( ) { $ _o . add ( pageType , isPagination ) } ) ; $ ( rdBoxId + ' [name="' + namePre + '[renderer][open]"]' ) . bind ( 'click' , function ( ) { $ _o . def _config _use _renderer ( pageType ) } ) ; if ( isPagination ) { $ ( rdBoxId + ' [name="' + namePre + '[renderer][open_pn]"]' ) . bind ( 'click' , function ( ) { if ( $ ( this ) . val ( ) == 1 ) { $ ( rdBoxId + '_open_pn' ) . show ( ) } else { $ ( rdBoxId + '_open_pn' ) . hide ( ) } } ) }
$ ( rdBoxId + ' .c-p-url-renderer-list' ) . on ( 'change' , 'select[name="' + namePre + '[renderer][types][]"]' , function ( ) { var type = $ ( this ) . val ( ) ; var tr = $ ( this ) . parents ( 'tr' ) . eq ( 0 ) ; var types = { 'wait_time' : { content : 1 , content _tips : '输入数字' } , 'scroll_top' : { content : 1 , content _tips : '输入数字' } , 'click' : { element : 1 } , 'val' : { element : 1 , content : 1 , content _tips : '输入值' } } ; var tdTypeCols = 3 ; tr . find ( '.td-renderer-element,.td-renderer-content' ) . hide ( ) ; tr . find ( 'input[name="' + namePre + '[renderer][contents][]"]' ) . attr ( 'placeholder' , '' ) ; var curType = types [ type ] ; if ( isObject ( curType ) ) { if ( curType . element ) { tr . find ( '.td-renderer-element' ) . show ( ) ; tdTypeCols -= 1 }
if ( curType . content ) { tr . find ( '.td-renderer-content' ) . show ( ) ; tdTypeCols -= 1 ; if ( curType . content _tips ) { tr . find ( 'input[name="' + namePre + '[renderer][contents][]"]' ) . attr ( 'placeholder' , curType . content _tips ) } } }
tr . find ( '.td-renderer-type' ) . attr ( 'colspan' , tdTypeCols ) } ) ; $ ( rdBoxId + ' .c-p-url-renderer-list' ) . on ( 'click' , '.delete-url-renderer' , function ( ) { $ ( this ) . parents ( 'tr' ) . eq ( 0 ) . remove ( ) } ) ; eleExchange ( rdBoxId + ' .c-p-url-renderer-list' , '.icon-drag-move' , 'tr' ) } , page _load : function ( pageType , rdConfig ) { var $ _o = this ; var pageVars = $ _o . $ _cp . get _page _vars ( pageType ) ; var boxId = pageVars . boxId ; var namePre = pageVars . namePre ; if ( ! boxId || ! namePre ) { return }
var rdBoxId = boxId + '_renderer' ; if ( isObject ( rdConfig ) ) { $ ( rdBoxId ) . find ( '[name="' + namePre + '[renderer][open]"][value="' + rdConfig . open + '"]' ) . prop ( 'checked' , ! 0 ) . trigger ( 'click' ) ; var rdTypes = isObject ( rdConfig . types ) ? rdConfig . types : [ ] ; var rdElements = isObject ( rdConfig . elements ) ? rdConfig . elements : [ ] ; var rdContents = isObject ( rdConfig . contents ) ? rdConfig . contents : [ ] ; var showPanel = ! 1 ; var openVal = rdConfig . open == 'y' ? true : ! 1 ; var openDef = $ ( $ _o . $ _cp . formid + ' [name="config[page_render]"]:checked' ) . val ( ) ; openDef = toInt ( openDef ) ; openDef = openDef > 0 ? true : ! 1 ; if ( rdTypes && rdTypes . length > 0 ) { for ( var i in rdTypes ) { $ _o . add ( pageType , rdTypes [ i ] , rdElements [ i ] , rdContents [ i ] ) }
tr . find ( '.td-renderer-type' ) . attr ( 'colspan' , tdTypeCols ) } ) ; $ ( rdBoxId + ' .c-p-url-renderer-list' ) . on ( 'click' , '.delete-url-renderer' , function ( ) { $ ( this ) . parents ( 'tr' ) . eq ( 0 ) . remove ( ) } ) ; eleExchange ( rdBoxId + ' .c-p-url-renderer-list' , '.icon-drag-move' , 'tr' ) } , page _load : function ( pageType , rdConfig , isPagination ) { var $ _o = this ; var pageVars = $ _o . $ _cp . get _page _vars ( pageType , null , isPagination ) ; var boxId = pageVars . boxId ; var namePre = pageVars . namePre ; if ( ! boxId || ! namePre ) { return }
var rdBoxId = boxId + '_renderer' ; if ( isObject ( rdConfig ) ) { $ ( rdBoxId ) . find ( '[name="' + namePre + '[renderer][open]"][value="' + rdConfig . open + '"]' ) . prop ( 'checked' , ! 0 ) . trigger ( 'click' ) ; var rdTypes = isObject ( rdConfig . types ) ? rdConfig . types : [ ] ; var rdElements = isObject ( rdConfig . elements ) ? rdConfig . elements : [ ] ; var rdContents = isObject ( rdConfig . contents ) ? rdConfig . contents : [ ] ; var showPanel = ! 1 ; var openVal = rdConfig . open == 'y' ? true : ! 1 ; var openDef = $ ( $ _o . $ _cp . formid + ' [name="config[page_render]"]:checked' ) . val ( ) ; openDef = toInt ( openDef ) ; openDef = openDef > 0 ? true : ! 1 ; if ( rdTypes && rdTypes . length > 0 ) { for ( var i in rdTypes ) { $ _o . add ( pageType , isPagination , rdTypes [ i ] , rdElements [ i ] , rdContents [ i ] ) }
if ( ( ! rdConfig . open && openDef ) || openVal ) { showPanel = ! 0 } } else { if ( rdConfig . open ) { if ( openVal != openDef ) { showPanel = ! 0 } } }
if ( showPanel ) { showPanelCollapse ( rdBoxId ) } } } , add : function ( pageType , rdType , rdElement , rdContent ) { var $ _o = this ; var pageVars = $ _o . $ _cp . get _page _vars ( pageType ) ; var boxId = pageVars . boxId ; var namePre = pageVars . namePre ; if ( ! boxId || ! namePre ) { return }
if ( isPagination ) { $ ( rdBoxId + ' [name="' + namePre + '[renderer][open_pn]"][value="' + rdConfig . open _pn + '"]' ) . prop ( 'checked' , ! 0 ) . trigger ( 'click' ) ; if ( rdConfig . open _pn ) { showPanel = ! 0 } else { showPanel = ! 1 } }
if ( showPanel ) { showPanelCollapse ( rdBoxId ) } } } , add : function ( pageType , isPagination , rdType , rdElement , rdContent ) { var $ _o = this ; var pageVars = $ _o . $ _cp . get _page _vars ( pageType , null , isPagination ) ; var boxId = pageVars . boxId ; var namePre = pageVars . namePre ; if ( ! boxId || ! namePre ) { return }
var rdBoxId = boxId + '_renderer' ; var tr = $ _o . $ _cp . clone _tpl ( '#coll_tpl_url_renderer' , namePre ) ; if ( rdType ) { tr . find ( '[name*="[renderer][types]"]' ) . val ( rdType ) ; tr . find ( '[name*="[renderer][elements]"]' ) . val ( rdElement ) ; tr . find ( '[name*="[renderer][contents]"]' ) . val ( rdContent ) }
tr . find ( '.c-p-url-page-signs' ) . each ( function ( ) { $ ( this ) . attr ( 'data-page-type' , pageType ) . attr ( 'data-input-name' , namePre + $ ( this ) . attr ( 'data-input-name' ) ) } ) ; $ ( rdBoxId + ' .c-p-url-renderer-list table' ) . append ( tr ) ; if ( rdType ) { $ ( rdBoxId + ' .c-p-url-renderer-list' ) . find ( '[name*="[renderer][types]"]:last-child' ) . trigger ( 'change' ) } } , def _config _renderer _open : function ( pageType ) { var $ _o = this ; var val = $ ( $ _o . $ _cp . formid + ' [name="config[page_render]"]:checked' ) . val ( ) ; val = toInt ( val ) ; var formid = $ _o . $ _cp . formid ; if ( pageType ) { formid = $ _o . $ _cp . get _page _vars ( pageType , 'formId' ) }
tr . find ( '.c-p-url-page-signs' ) . each ( function ( ) { $ ( this ) . attr ( 'data-page-type' , pageType ) . attr ( 'data-input-name' , namePre + $ ( this ) . attr ( 'data-input-name' ) ) ; if ( isPagination ) { $ ( this ) . attr ( 'data-is-pagination' , 1 ) } } ) ; $ ( rdBoxId + ' .c-p-url-renderer-list table' ) . append ( tr ) ; if ( rdType ) { $ ( rdBoxId + ' .c-p-url-renderer-list' ) . find ( '[name*="[renderer][types]"]:last-child' ) . trigger ( 'change' ) } } , def _config _renderer _open : function ( pageType ) { var $ _o = this ; var val = $ ( $ _o . $ _cp . formid + ' [name="config[page_render]"]:checked' ) . val ( ) ; val = toInt ( val ) ; var formid = $ _o . $ _cp . formid ; if ( pageType ) { formid = $ _o . $ _cp . get _page _vars ( pageType , 'formId' ) }
$ ( formid ) . find ( '.def-config-page-render' ) . html ( val > 0 ? '是' : '否' ) } , def _config _use _renderer : function ( pageType ) { var $ _o = this ; var pageVars = $ _o . $ _cp . get _page _vars ( pageType ) ; var formId = pageVars . formId ; var boxId = pageVars . boxId ; var namePre = pageVars . namePre ; if ( ! formId || ! boxId || ! namePre ) { return }
var defConfigObj = $ ( boxId + '_pagination' ) . find ( '.def-config-renderer-open' ) ; var rendererOpen = $ ( formId ) . find ( '[name="' + namePre + '[renderer][open]"]:checked' ) . val ( ) ; if ( rendererOpen ) { defConfigObj . html ( rendererOpen == 'y' ? '是' : '否' ) . show ( ) ; defConfigObj . parent ( ) . find ( '.def-config-page-render' ) . hide ( ) } else { defConfigObj . parent ( ) . find ( '.def-config-page-render' ) . show ( ) ; defConfigObj . hide ( ) } } , }
var defConfigObj = $ ( boxId + '_pagination' ) . find ( '.def-config-renderer-open' ) ; var rendererOpen = $ ( formId ) . find ( '[name="' + namePre + '[renderer][open]"]:checked' ) . val ( ) ; if ( rendererOpen ) { defConfigObj . html ( rendererOpen == 'y' ? '是' : '否' ) . show ( ) ; defConfigObj . parent ( ) . find ( '.def-config-page-render' ) . hide ( ) } else { defConfigObj . parent ( ) . find ( '.def-config-page-render' ) . show ( ) ; defConfigObj . hide ( ) } } }
function CpPagination ( cpClass ) { this . $ _cp = cpClass }
CpPagination . prototype = { constructor : CpPagination , page _init : function ( pageType ) { var $ _o = this ; if ( pageType == 'source_url' || pageType == 'level_url' || pageType == 'url' ) { var pageVars = $ _o . $ _cp . get _page _vars ( pageType ) ; var formId = pageVars . formId ; var boxId = pageVars . boxId ; var namePre = pageVars . namePre ; if ( ! formId || ! boxId || ! namePre ) { return }
var pnBoxId = boxId + '_pagination' ; var pnNamePre = namePre + '[pagination]' ; $ ( formId + ' select[name="' + pnNamePre + '[area_module]"],select[name="' + pnNamePre + '[url_rule_module]"]' ) . bind ( 'click' , function ( ) { $ _o . $ _cp . rule _module _slt ( this ) } ) ; $ ( pnBoxId + ' [name="' + pnNamePre + '[open]"]' ) . bind ( 'click' , function ( ) { if ( $ ( this ) . val ( ) == 1 ) { $ ( pnBoxId + '_open' ) . show ( ) } else { $ ( pnBoxId + '_open' ) . hide ( ) } } ) ; if ( pageType == 'url' ) { $ ( pnBoxId ) . on ( 'click' , '.add-url-pagination-field' , function ( ) { var url = ulink ( "cpattern/pagination_field?is_loop=_is_loop_" , { '_is_loop_' : $ _o . $ _cp . field _is _loop ( ) } ) ; windowModal ( '分页字段' , url ) } ) ; $ ( pnBoxId + ' .c-p-url-pagination-fields' ) . on ( 'click' , '.field' , function ( ) { var parent = $ ( this ) . parents ( '[id^="pagination_field_"]' ) . eq ( 0 ) ; var objid = parent . attr ( 'id' ) ; var pnField = parent . find ( '[name="' + pnNamePre + '[fields][]"]' ) . val ( ) ; var url = ulink ( "cpattern/pagination_field?objid=_objid_&pagination_field=_pnfield_&is_loop=_is_loop_" , { '_objid_' : objid , '_pnfield_' : pnField , '_is_loop_' : $ _o . $ _cp . field _is _loop ( ) } ) ; windowModal ( '分页字段' , url ) } ) ; $ ( pnBoxId + ' .c-p-url-pagination-fields' ) . on ( 'click' , '.delete' , function ( ) { var parent = $ ( this ) . parents ( '[id^="pagination_field_"]' ) . eq ( 0 ) ; confirmRight ( '确定删除?' , function ( ) { parent . remove ( ) } ) } ) } } } , page _load : function ( pageType , pnConfig ) { var $ _o = this ; if ( pageType == 'source_url' || pageType == 'level_url' || pageType == 'url' ) { var pageVars = $ _o . $ _cp . get _page _vars ( pageType ) ; if ( ! pageVars . boxId || ! pageVars . namePre ) { return }
CpPagination . prototype = { constructor : CpPagination , page _has _pn : function ( pageType ) { if ( pageType == 'source_url' || pageType == 'level_url' || pageType == 'url' ) { return ! 0 } else { return ! 1 } } , page _init : function ( pageType ) { var $ _o = this ; if ( $ _o . page _has _pn ( pageType ) ) { var pageVars = $ _o . $ _cp . get _page _vars ( pageType ) ; var formId = pageVars . formId ; var boxId = pageVars . boxId ; var namePre = pageVars . namePre ; if ( ! formId || ! boxId || ! namePre ) { return }
var pnBoxId = boxId + '_pagination' ; var pnNamePre = namePre + '[pagination]' ; $ ( formId + ' select[name="' + pnNamePre + '[area_module]"],select[name="' + pnNamePre + '[url_rule_module]"]' ) . bind ( 'click' , function ( ) { $ _o . $ _cp . rule _module _slt ( this ) } ) ; $ ( pnBoxId + ' [name="' + pnNamePre + '[open]"]' ) . bind ( 'click' , function ( ) { if ( $ ( this ) . val ( ) == 1 ) { $ ( pnBoxId + '_open' ) . show ( ) } else { $ ( pnBoxId + '_open' ) . hide ( ) } } ) ; if ( pageType == 'url' ) { $ ( pnBoxId ) . on ( 'click' , '.add-url-pagination-field' , function ( ) { var url = ulink ( "cpattern/pagination_field?is_loop=_is_loop_" , { '_is_loop_' : $ _o . $ _cp . field _is _loop ( ) } ) ; windowModal ( '分页字段' , url ) } ) ; $ ( pnBoxId + ' .c-p-url-pagination-fields' ) . on ( 'click' , '.field' , function ( ) { var parent = $ ( this ) . parents ( '[id^="pagination_field_"]' ) . eq ( 0 ) ; var objid = parent . attr ( 'id' ) ; var pnField = parent . find ( '[name="' + pnNamePre + '[fields][]"]' ) . val ( ) ; var url = ulink ( "cpattern/pagination_field?objid=_objid_&pagination_field=_pnfield_&is_loop=_is_loop_" , { '_objid_' : objid , '_pnfield_' : pnField , '_is_loop_' : $ _o . $ _cp . field _is _loop ( ) } ) ; windowModal ( '分页字段' , url ) } ) ; $ ( pnBoxId + ' .c-p-url-pagination-fields' ) . on ( 'click' , '.delete' , function ( ) { var parent = $ ( this ) . parents ( '[id^="pagination_field_"]' ) . eq ( 0 ) ; confirmRight ( '确定删除?' , function ( ) { parent . remove ( ) } ) } ) }
$ _o . $ _cp . cpUrlWeb . page _init ( pageType , ! 0 ) ; $ _o . $ _cp . cpRenderer . page _init ( pageType , ! 0 ) } } , page _load : function ( pageType , pnConfig ) { var $ _o = this ; if ( $ _o . page _has _pn ( pageType ) ) { var pageVars = $ _o . $ _cp . get _page _vars ( pageType ) ; if ( ! pageVars . boxId || ! pageVars . namePre ) { return }
var pnBoxId = pageVars . boxId + '_pagination' ; var pnNamePre = pageVars . namePre + '[pagination]' ; if ( isObject ( pnConfig ) ) { $ _o . $ _cp . load _page _rule ( pageType , pnConfig , ! 0 ) ; $ ( pnBoxId + ' [name="' + pnNamePre + '[max]"]' ) . val ( toInt ( pnConfig . max ) ) ; $ ( pnBoxId + ' [name="' + pnNamePre + '[use_url_web]"][value="' + pnConfig . use _url _web + '"]' ) . prop ( 'checked' , ! 0 ) ; $ ( pnBoxId + ' [name="' + pnNamePre + '[use_renderer]"][value="' + pnConfig . use _renderer + '"]' ) . prop ( 'checked' , ! 0 ) ; pnConfig . open = toInt ( pnConfig . open ) ; if ( pnConfig . open ) { $ ( pnBoxId + ' [name="' + pnNamePre + '[open]"][value="' + pnConfig . open + '"]' ) . trigger ( 'click' ) ; if ( pnConfig . open > 0 ) { showPanelCollapse ( pnBoxId ) } }
if ( pageType == 'url' ) { if ( pnConfig . fields ) { for ( var i in pnConfig . fields ) { $ _o . field _op ( pageType , 'add' , { pagination _field : pnConfig . fields [ i ] } ) } } } } } } , field _op : function ( pageType , op , params ) { var $ _o = this ; if ( pageType != 'url' ) { return }
if ( pageType == 'url' ) { if ( pnConfig . fields ) { for ( var i in pnConfig . fields ) { $ _o . field _op ( pageType , 'add' , { pagination _field : pnConfig . fields [ i ] } ) } } }
$ _o . $ _cp . cpUrlWeb . page _load ( pageType , pnConfig . url _web , ! 0 ) ; $ _o . $ _cp . cpRenderer . page _load ( pageType , pnConfig . renderer , ! 0 ) } } } , field _op : function ( pageType , op , params ) { var $ _o = this ; if ( pageType != 'url' ) { return }
params = params ? params : { } ; var formObj = params . formObj ? params . formObj : '#form_pagination_field' ; var pageVars = $ _o . $ _cp . get _page _vars ( pageType ) ; if ( ! pageVars . boxId || ! pageVars . namePre ) { return }
var pnBoxId = pageVars . boxId + '_pagination' ; var pnNamePre = pageVars . namePre + '[pagination]' ; if ( op == 'init' ) { var fieldNames = $ _o . $ _cp . get _field _names ( ) ; var fieldOptions = '<option value="">--请选择--</option><option value="::all">-全部字段-</option>' ; for ( var i in fieldNames ) { fieldOptions += '<option value="' + fieldNames [ i ] + '">' + fieldNames [ i ] + '</option>' }
$ ( formObj + ' select[name="pagination_field[field]"]' ) . html ( fieldOptions ) ; $ ( formObj ) . bind ( 'submit' , function ( ) { $ _o . field _op ( pageType , 'add_sub' ) ; return ! 1 } ) ; if ( isObject ( params . pagination _field ) ) { $ ( formObj + ' select[name="pagination_field[field]"]' ) . val ( params . pagination _field . field ) ; $ ( formObj + ' [name="pagination_field[delimiter]"]' ) . val ( params . pagination _field . delimiter ) } } else if ( op == 'add' ) { params . pagination _field = isObject ( params . pagination _field ) ? params . pagination _field : { } ; var tpl = '<a href="javascript:;" class="field" data-field="__field__">__field_name__</a><em class="glyphicon glyphicon-remove-circle delete"></em><input type="hidden" name="' + pnNamePre + '[fields][]" value="__pn_field__" />' ; var fieldName = params . pagination _field . field == '::all' ? '-全部字段-' : params . pagination _field . field ; tpl = tpl . replace ( /__field__/ig , params . pagination _field . field ) . replace ( /__field_name__/ig , htmlspecialchars ( fieldName ) ) . replace ( /__pn_field__/ig , encode _json2urlbase ( params . pagination _field ) ) ; var objid = params . objid ; if ( ! objid ) { objid = 'pagination_field_' + pageType + '_' + generateUUID ( ) ; $ ( pnBoxId + ' .c-p-url-pagination-fields' ) . append ( '<div class="param-label" id="' + objid + '"></div>' ) }
@ -168,9 +181,10 @@ signHtml+='</div>';$(signListId).append(signHtml)}}
$ ( signListId ) . off ( 'click' , 'a[data-val]' ) . on ( 'click' , 'a[data-val]' , function ( ) { insertAtCaret ( $ ( $ _o . formObj + ' [name="field[sign]"]' ) , $ ( this ) . attr ( 'data-val' ) ) } ) } ) ; $ ( $ _o . formObj + ' select[name="field[module]"]' ) . bind ( 'change' , function ( ) { $ ( $ _o . formObj + ' .c-p-field-module' ) . hide ( ) ; $ ( $ _o . formObj + ' .c-p-field-module[module="' + $ ( this ) . val ( ) + '"]' ) . show ( ) ; var source _module = new Array ( 'rule' , 'xpath' , 'json' , 'auto' , 'sign' ) ; var in _module = ! 1 ; for ( var i in source _module ) { if ( $ ( this ) . val ( ) == source _module [ i ] ) { in _module = ! 0 ; break } }
if ( in _module ) { $ ( $ _o . formObj + ' .c-p-field-source' ) . show ( ) } else { $ ( $ _o . formObj + ' select[name="field[source]"]' ) . val ( '' ) ; $ ( $ _o . formObj + ' .c-p-field-source' ) . hide ( ) } } ) ; $ ( $ _o . formObj + ' select[name="field[extract_module]"]' ) . bind ( 'change' , function ( ) { $ ( '.c-p-field-extract-module' ) . hide ( ) ; $ ( '.c-p-field-extract-module[extract-module="' + $ ( this ) . val ( ) + '"]' ) . show ( ) } ) ; var fieldNames = $ _o . $ _cp . get _field _names ( ) ; for ( var i in fieldNames ) { if ( fieldData && fieldData . name == fieldNames [ i ] ) { continue }
$ ( $ _o . formObj + ' #c_p_field_merge_list' ) . append ( '<a href="javascript:;" style="margin-right:10px;" data-val="[字段:' + fieldNames [ i ] + ']">[字段:' + fieldNames [ i ] + ']</a>' ) ; $ ( $ _o . formObj + ' [name="field[extract]"]' ) . append ( '<option value="' + fieldNames [ i ] + '">' + fieldNames [ i ] + '</option>' ) }
$ ( $ _o . formObj + ' #c_p_field_time_format_list' ) . on ( 'click' , 'a[data-val]' , function ( ) { insertAtCaret ( $ ( $ _o . formObj + ' [name="field[time_format]"]' ) , $ ( this ) . attr ( 'data-val' ) ) } ) ; $ ( $ _o . formObj + ' #c_p_field_merge_list' ) . on ( 'click' , 'a[data-val]' , function ( ) { insertAtCaret ( $ ( $ _o . formObj + ' [name="field[merge]"]' ) , $ ( this ) . attr ( 'data-val' ) ) } ) ; $ . datetimepicker . setLocale ( 'zh' ) ; $ ( $ _o . formObj + ' input[name="field[time_start]"],#form_field input[name="field[time_end]"]' ) . datetimepicker ( ) ; $ ( $ _o . formObj ) . bind ( 'submit' , function ( ) { $ _o . add _sub ( ) ; return ! 1 } ) ; cpRuleModuleInit ( $ _o . formObj , 'field' , '' ) ; cpRuleModuleInit ( $ _o . formObj , 'field' , 'extract_' ) ; if ( fieldData ) { for ( var i in fieldData ) { var fieldEle = $ ( $ _o . formObj + ' [name="field[' + i + ']"]' ) ; if ( fieldEle . is ( 'input:text' ) ) { fieldEle . val ( fieldData [ i ] ) } else if ( fieldEle . is ( 'select' ) ) { fieldEle . val ( fieldData [ i ] ) . trigger ( "change" ) } }
$ ( $ _o . formObj + ' #c_p_field_time_format_list' ) . on ( 'click' , 'a[data-val]' , function ( ) { insertAtCaret ( $ ( $ _o . formObj + ' [name="field[time_format]"]' ) , $ ( this ) . attr ( 'data-val' ) ) } ) ; $ ( $ _o . formObj + ' #c_p_field_merge_list' ) . on ( 'click' , 'a[data-val]' , function ( ) { insertAtCaret ( $ ( $ _o . formObj + ' [name="field[merge]"]' ) , $ ( this ) . attr ( 'data-val' ) ) } ) ; $ . datetimepicker . setLocale ( 'zh' ) ; $ ( $ _o . formObj + ' input[name="field[time_start]"],#form_field input[name="field[time_end]"]' ) . datetimepicker ( ) ; $ ( $ _o . formObj ) . bind ( 'submit' , function ( ) { $ _o . add _sub ( ) ; return ! 1 } ) ; cpRuleModuleInit ( $ _o . formObj , 'field' , '' ) ; cpRuleModuleInit ( $ _o . formObj , 'field' , 'extract_' ) ; if ( fieldData ) { for ( var i in fieldData ) { var fieldEle = $ ( $ _o . formObj + ' [name="field[' + i + ']"]' ) ; if ( fieldEle . is ( 'input:text' ) || fieldEle . is ( 'textarea' ) ) { fieldEle . val ( fieldData [ i ] ) } else if ( fieldEle . is ( 'select' ) ) { fieldEle . val ( fieldData [ i ] ) . trigger ( "change" ) } }
if ( ! fieldData . hasOwnProperty ( 'source' ) ) { $ ( $ _o . formObj + ' [name="field[source]"]' ) . trigger ( "change" ) }
$ ( $ _o . formObj + ' [name="field[auto]"][value="' + fieldData . auto + '"]' ) . prop ( 'checked' , ! 0 ) ; cpRuleModuleLoad ( $ _o . formObj , 'field' , '' , fieldData ) ; cpRuleModuleLoad ( $ _o . formObj , 'field' , 'extract_' , fieldData ) } } , add : function ( objid , fieldData , processData ) { var $ _o = this ; var fieldSource = '内容页' ; if ( fieldData . source ) { var fsource = fieldData . source . split ( ':' ) ; fieldSource = $ _o . $ _cp . get _page _vars ( fsource [ 0 ] , 'title' ) ; if ( fsource [ 1 ] ) { fieldSource += ':' + fsource [ 1 ] } }
$ ( $ _o . formObj + ' [name="field[num_start]"]' ) . val ( toInt ( fieldData . num _start ) ) ; $ ( $ _o . formObj + ' [name="field[num_end]"]' ) . val ( toInt ( fieldData . num _end ) ) ; $ ( $ _o . formObj + ' [name="field[auto]"][value="' + fieldData . auto + '"]' ) . prop ( 'checked' , ! 0 ) ; if ( fieldData . time _stamp ) { $ ( $ _o . formObj + ' [name="field[time_stamp]"]' ) . prop ( 'checked' , ! 0 ) }
cpRuleModuleLoad ( $ _o . formObj , 'field' , '' , fieldData ) ; cpRuleModuleLoad ( $ _o . formObj , 'field' , 'extract_' , fieldData ) } } , add : function ( objid , fieldData , processData ) { var $ _o = this ; var fieldSource = '内容页' ; if ( fieldData . source ) { var fsource = fieldData . source . split ( ':' ) ; fieldSource = $ _o . $ _cp . get _page _vars ( fsource [ 0 ] , 'title' ) ; if ( fsource [ 1 ] ) { fieldSource += ':' + fsource [ 1 ] } }
var isLoop = '' ; if ( fieldData . module == 'rule' ) { if ( fieldData . rule _multi && fieldData . rule _multi _type == 'loop' ) { isLoop = ' - 循环入库' } } else if ( fieldData . module == 'xpath' ) { if ( fieldData . xpath _multi && fieldData . xpath _multi _type == 'loop' ) { isLoop = ' - 循环入库' } } else if ( fieldData . module == 'json' ) { if ( fieldData . json _loop ) { isLoop = ' - 循环入库' } } else if ( fieldData . module == 'extract' || fieldData . module == 'merge' ) { $ ( $ _o . $ _cp . formid + ' #coll_pattern_field' ) . find ( '.sort-field' ) . show ( ) }
if ( isLoop ) { $ ( '#c_p_field_loop_tips' ) . show ( ) }
if ( objid ) { var eleObj = $ ( $ _o . $ _cp . formid + ' #' + objid ) ; eleObj . find ( '.field-name' ) . attr ( 'data-val' , fieldData . name ) . text ( fieldData . name ) ; eleObj . find ( '.field-source' ) . attr ( 'data-val' , fieldData . source ) . text ( fieldSource ) ; eleObj . find ( '.field-module' ) . attr ( 'data-val' , fieldData . module ) . text ( window . tpl _lang [ 'field_module_' + fieldData . module ] + isLoop ) ; if ( isLoop ) { eleObj . find ( '.field-module' ) . attr ( 'data-is-loop' , 1 ) } else { eleObj . find ( '.field-module' ) . removeAttr ( 'data-is-loop' ) }
@ -188,20 +202,20 @@ CpProcess.prototype={constructor:CpProcess,init:function(processData,isCommon,is
if ( $ ( $ _o . processForm ) . is ( 'form' ) ) { $ ( $ _o . processForm ) . bind ( 'submit' , function ( ) { $ _o . add _sub ( ) ; return ! 1 } ) }
$ ( $ _o . processBox + ' .process-add' ) . bind ( 'click' , function ( ) { var module = $ ( $ _o . processBox + ' select[name="process[module]"]' ) . val ( ) ; $ _o . add ( { 'add_new' : 1 , 'module' : module } ) } ) ; if ( $ ( $ _o . processForm ) . prop ( 'inited' ) == 1 ) { return ! 0 }
$ ( $ _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 ( ) { ti psP luginFunc( '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 }
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 ( ) { pluginFuncOp . tips ( '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 . txt _insert _field ( $ _o . processForm , '.p-m-api-url-field select' , function ( sltObj ) { return $ ( sltObj ) . parents ( 'section' ) . eq ( 0 ) . find ( '[data-process="api:api_url"]' ) } ) ; $ ( $ _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_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 }
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 ; pluginFuncOp . load ( { 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 }
params . module = htmlspecialchars ( params . module ) ; params . title = params . title ? htmlspecialchars ( params . title ) : '' ; var parentid = $ ( $ _o . processForm + ' .c-p-process-accordion' ) . attr ( 'id' ) ; if ( ! parentid ) { parentid = 'p_accordion_' + generateUUID ( ) ; $ ( $ _o . processForm + ' .c-p-process-accordion' ) . attr ( 'id' , parentid ) }
var dataParent = parentid ? ( 'data-parent="#' + parentid + '"' ) : '' ; var moduleHtml = $ ( $ _o . processBox + ' .c-p-process-module[module="' + params . module + '"]' ) . html ( ) ; if ( params . module == 'html' ) { moduleHtml = moduleHtml . replace ( /p_m_html_allow/ig , 'p_m_html_allow_' + generateUUID ( ) ) ; moduleHtml = moduleHtml . replace ( /p_m_html_filter/ig , 'p_m_html_filter_' + generateUUID ( ) ) }
var processName = 'process[i_' + generateUUID ( ) + ']' ; moduleHtml = '<input type="hidden" name="' + processName + '[module]" value="' + params . module + '" />' + moduleHtml ; var collapseId = 'p_collapse_' + generateUUID ( ) ; var html = $ _o . $ _cp . clone _tpl ( '#coll_tpl_process' ) ; html . attr ( 'data-name' , processName ) ; html . find ( 'a[data-toggle="collapse"]' ) . attr ( 'data-parent' , '#' + parentid ) . attr ( 'href' , '#' + collapseId ) ; if ( params . title ) { html . find ( '.panel-title > a[data-toggle="collapse"]' ) . text ( window . tpl _lang [ 'process_module_' + params . module ] + ':' ) ; html . find ( '.panel-title-title > a[data-toggle="collapse"]' ) . text ( params . title ) . show ( ) } else { html . find ( '.panel-title > a[data-toggle="collapse"]' ) . text ( window . tpl _lang [ 'process_module_' + params . module ] ) ; html . find ( '.panel-title-title > a[data-toggle="collapse"]' ) . hide ( ) }
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 == '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 ) }
$ ( 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 : '' ) ; $ ( curCollapse ) . find ( '[data-process="batch:batch_sign"]' ) . val ( params . batch _sign ? params . batch _sign : '' ) } 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 : '' ) ; pluginFuncOp . load ( { 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 ( ) ; 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 ] : '' ) } }
@ -228,10 +242,8 @@ $('#'+eleId).html(tpl);if(objid&&objid!=eleId){if(document.getElementById(objid)
$ ( $ _o . formObj ) . bind ( 'submit' , function ( ) { $ _o . add _sub ( ) ; return ! 1 } ) ; if ( ! isObject ( pageConfig ) ) { pageConfig = { } }
if ( ! isObject ( pageConfig [ namePre ] ) ) { pageConfig [ namePre ] = { } }
$ _o . curPageType = pageType ; $ _o . curPageConfig = pageConfig ; if ( $ _o . $ _cp . page _is _list ( $ _o . curPageType ) ) { $ ( '#myModal' ) . on ( 'hidden.bs.modal' , function ( e ) { if ( $ _o . $ _cp . page _is _list ( $ _o . curPageType ) ) { var curPageVars = $ _o . $ _cp . get _page _vars ( $ _o . curPageType ) ; var namePre = curPageVars . namePre ; var options = { 'ajax_scroll_top' : window . modal _scroll _top , lg : 1 , ajax : { type : 'post' , data : { } } } ; options . ajax . data . objid = $ _o . curPageConfig . objid ; options . ajax . data [ namePre ] = encode _json2urlbase ( $ _o . curPageConfig [ namePre ] ) ; windowModal ( '编辑' + curPageVars . title + '规则' , ulink ( 'cpattern/' + $ _o . curPageType ) , options ) } } ) }
$ ( $ _o . formObj + ' select[name="content_sign[module]"]' ) . bind ( 'change' , function ( ) { $ ( $ _o . formObj + ' .c-p-content-sign-module' ) . hide ( ) ; $ ( $ _o . formObj + ' .c-p-content-sign-module[data-module="' + $ ( this ) . val ( ) + '"]' ) . show ( ) } ) ; cpRuleModuleInit ( $ _o . formObj , 'content_sign' , '' ) ; var contentSignFunc = '' ; if ( contentSign ) { $ ( $ _o . formObj + ' [name="objid"]' ) . attr ( 'data-identity' , contentSign . identity ) ; for ( var i in contentSign ) { var csEle = $ ( $ _o . formObj + ' [name="content_sign[' + i + ']"]' ) ; if ( csEle . is ( 'input:text' ) ) { csEle . val ( contentSign [ i ] ) } else if ( csEle . is ( 'select' ) ) { csEle . val ( contentSign [ i ] ) . trigger ( "change" ) } }
cpRuleModuleLoad ( $ _o . formObj , 'content_sign' , '' , contentSign ) ; contentSignFunc = contentSign . func ; if ( contentSign . func _param ) { $ ( $ _o . formObj + ' [name="content_sign[func_param]"]' ) . val ( contentSign . func _param ) } }
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 = [ ] }
$ ( $ _o . formObj + ' select[name="content_sign[module]"]' ) . bind ( 'change' , function ( ) { $ ( $ _o . formObj + ' .c-p-content-sign-module' ) . hide ( ) ; $ ( $ _o . formObj + ' .c-p-content-sign-module[data-module="' + $ ( this ) . val ( ) + '"]' ) . show ( ) } ) ; $ ( $ _o . formObj + ' #c_p_content_sign_add_func' ) . bind ( 'click' , function ( ) { $ _o . add _func ( null ) } ) ; pluginFuncOp . initHtml ( $ _o . formObj + ' #c_p_content_sign_funcs' ) ; cpRuleModuleInit ( $ _o . formObj , 'content_sign' , '' ) ; if ( contentSign ) { $ ( $ _o . formObj + ' [name="objid"]' ) . attr ( 'data-identity' , contentSign . identity ) ; for ( var i in contentSign ) { var csEle = $ ( $ _o . formObj + ' [name="content_sign[' + i + ']"]' ) ; if ( csEle . is ( 'input:text' ) ) { csEle . val ( contentSign [ i ] ) } else if ( csEle . is ( 'select' ) ) { csEle . val ( contentSign [ i ] ) . trigger ( "change" ) } }
cpRuleModuleLoad ( $ _o . formObj , 'content_sign' , '' , contentSign ) ; if ( isObject ( contentSign . funcs ) ) { for ( var i in contentSign . funcs ) { $ _o . add _func ( contentSign . funcs [ i ] ) } } } } , add _func : function ( contentSignFunc ) { var $ _o = this ; pluginFuncOp . addHtml ( { funcData : contentSignFunc , funcName : 'content_sign[funcs][{id}][func]' , funcParamName : 'content_sign[funcs][{id}][func_param]' , tplId : 'c_p_content_sign_tpl_func' , listId : 'c_p_content_sign_funcs' , funcId : 'c_p_content_sign_func_{id}' } , { module : 'contentSign' , boxObj : $ _o . formObj } ) } , 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 : '' ; 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 ( ) } } ) } }