/*
|--------------------------------------------------------------------------
| SkyCaiji (蓝天采集器)
|--------------------------------------------------------------------------
| Copyright (c) 2018 https://www.skycaiji.com All rights reserved.
|--------------------------------------------------------------------------
| 使用协议 https://www.skycaiji.com/licenses
|--------------------------------------------------------------------------
*/
'use strict';function prompt_success(msg){toastr.success(msg?msg:'')}
function prompt_error(msg){toastr.error(msg?msg:'')}
function ajax_check_userpwd(ajaxSet){var oldSuccess=ajaxSet.success;ajaxSet.success=function(data){if(data.data&&data.data._check_pwd_){if(data.msg){toastr.error(data.msg)}
var msg='
该操作需要验证您的登录密码
'+'
'+'
小时内不再验证
';confirmRight({closeAfterFunc:!0,yes:'确定',no:'取消',msg:msg},function(){var ajaxSetData=isNull(ajaxSet.data)?{}:ajaxSet.data;var checkPwd=$('#confirm_ipt_check_pwd').val();var checkSkip=$('#confirm_ipt_check_skip').val();if(typeof(ajaxSetData)=='object'){ajaxSetData._check_pwd_=checkPwd;ajaxSetData._check_skip_=checkSkip}else{ajaxSetData=ajaxSetData?(ajaxSetData+'&'):'';ajaxSetData+='_check_pwd_='+encodeURIComponent(checkPwd);ajaxSetData+='&_check_skip_='+encodeURIComponent(checkSkip)}
ajaxSet.data=ajaxSetData;ajaxSet.success=oldSuccess;ajax_check_userpwd(ajaxSet)});$('#confirm_ipt_check_skip').val(toInt(admincpOp.getConfig('check_skip')));$('#confirm_ipt_check_skip').bind('change',function(){admincpOp.config('check_skip',$(this).val())});$('#confirm_ipt_check_pwd').bind('keyup',function(event){if(event.keyCode=="13"){$('#confirm_right .cr-btn-yes').trigger("click")}})}else{if(oldSuccess&&typeof(oldSuccess)=='function'){oldSuccess(data)}}};ajaxOpen(ajaxSet)}
var admincpOp={getConfig:function(key){var cpConfig=window.site_config.admincp;cpConfig=cpConfig?cpConfig:{};return key?cpConfig[key]:cpConfig},init:function(){$('[data-toggle="push-menu"]').pushMenu(menuOpts);var $pushMenu=$('[data-toggle="push-menu"]').data('lte.pushmenu');$pushMenu.expandOnHover=function(){};var bodyWidth=$(document.body).width();var cpConfig=admincpOp.getConfig(null);if(cpConfig.skin){$('body').removeClass('skin-blue').addClass(cpConfig.skin)}
if(cpConfig.fixed==1){$('body').addClass('fixed')}
var menuOpts={};if(bodyWidth>767){if(cpConfig.mini==1){$('body').addClass('sidebar-collapse').addClass('sidebar-mini')}
if(cpConfig.narrow==1){$('body').addClass('layout-boxed')}
menuOpts={animationSpeed:300};if(window.navigator.userAgent.indexOf('MSIE')>-1){menuOpts={animationSpeed:0}}}else{menuOpts={animationSpeed:0}}
$('.sidebar-menu').tree(menuOpts);$(document).ready(function(){$('body').addClass('open-transition');$('#treeview_skins').bind('click',function(){if($('#sidebar_skins').html().length<=0){admincpOp.skins()}});if(cpConfig.fixed==1){$('#chk_sidebar_fixed').prop('checked',!0)}
$('#chk_sidebar_fixed').bind('click',function(){var setFixed=$(this).is(':checked')?1:0;admincpOp.config('fixed',setFixed,function(){if(setFixed){$('body').addClass('fixed')}else{$('body').removeClass('fixed')}})});if(bodyWidth>767){if(cpConfig.mini==1){$('#chk_sidebar_mini').prop('checked',!0)}
$('#chk_sidebar_mini').bind('click',function(){var setMini=$(this).is(':checked')?1:0;admincpOp.config('mini',setMini,function(){if(setMini){$('body').addClass('sidebar-collapse').addClass('sidebar-mini')}else{$('body').removeClass('sidebar-collapse').removeClass('sidebar-mini')}})});$('.sidebar-toggle[data-toggle="push-menu"]').bind('click',function(){$('body').addClass('sidebar-mini')});if(cpConfig.narrow==1){$('#chk_sidebar_narrow').prop('checked',!0)}
$('#chk_sidebar_narrow').bind('click',function(){var setNarrow=$(this).is(':checked')?1:0;admincpOp.config('narrow',setNarrow,function(){if(setNarrow){$('body').addClass('layout-boxed')}else{$('body').removeClass('layout-boxed')}})})}else{$('#chk_sidebar_mini').parents('div.checkbox').eq(0).hide();$('#chk_sidebar_narrow').parents('div.checkbox').eq(0).hide()}
if($('#menu_backstage_task').length>0){$('#menu_backstage_task').bind('click',function(){windowModal('采集任务',ulink('admin/backstage/backstageTask'),{lg:1})});winBackstageTask.count()}})},config:function(op,val,successFunc){ajaxOpen({type:'post',url:ulink('backstage/admincp'),data:{op:op,val:val},success:function(data){if(successFunc&&typeof(successFunc)=='function'){successFunc()}}})},skins:function(){var skinList={'blue':{'name':window.tpl_lang.skin_blue,'top_l_style':'background:#367fa9','top_r_class':'bg-light-blue','left_style':'background: #222d32','right_style':'background: #f4f5f7'},'black':{'name':window.tpl_lang.skin_black,'top_style':'box-shadow: 0 0 2px rgba(0,0,0,0.1)','top_l_style':'background: #fefefe','top_r_style':'background: #fefefe','left_style':'background: #222','right_style':'background: #f4f5f7'},'purple':{'name':window.tpl_lang.skin_purple,'top_l_class':'bg-purple-active','top_r_class':'bg-purple','left_style':'background: #222d32','right_style':'background: #f4f5f7'},'green':{'name':window.tpl_lang.skin_green,'top_l_class':'bg-green-active','top_r_class':'bg-green','left_style':'background: #222d32','right_style':'background: #f4f5f7'},'red':{'name':window.tpl_lang.skin_red,'top_l_class':'bg-red-active','top_r_class':'bg-red','left_style':'background: #222d32','right_style':'background: #f4f5f7'},'yellow':{'name':window.tpl_lang.skin_yellow,'top_l_class':'bg-yellow-active','top_r_class':'bg-yellow','left_style':'background: #222d32','right_style':'background: #f4f5f7'},'blue-light':{'name':window.tpl_lang.skin_blue_light,'top_l_style':'background: #367fa9','top_r_class':'bg-light-blue','left_style':'background: #f9fafc"','right_style':'background: #f4f5f7'},'black-light':{'name':window.tpl_lang.skin_black_light,'top_style':'box-shadow: 0 0 2px rgba(0,0,0,0.1)','top_l_style':'background: #fefefe','top_r_style':'background: #fefefe','left_style':'background: #f9fafc','right_style':'background: #f4f5f7'},'purple-light':{'name':window.tpl_lang.skin_purple_light,'top_l_class':'bg-purple-active','top_r_class':'bg-purple','left_style':'background: #f9fafc','right_style':'background: #f4f5f7'},'green-light':{'name':window.tpl_lang.skin_green_light,'top_l_class':'bg-green-active','top_r_class':'bg-green','left_style':'background: #f9fafc','right_style':'background: #f4f5f7'},'red-light':{'name':window.tpl_lang.skin_red_light,'top_l_class':'bg-red-active','top_r_class':'bg-red','left_style':'background: #f9fafc','right_style':'background: #f4f5f7'},'yellow-light':{'name':window.tpl_lang.skin_yellow_light,'top_l_class':'bg-yellow-active','top_r_class':'bg-yellow','left_style':'background: #f9fafc','right_style':'background: #f4f5f7'},};var html='';for(var skin in skinList){var skinSet=skinList[skin];html+='- '+''+'
'+''+'
'+''+'
'+''+''+skinSet.name+'
';+' '}
html+='
';$('#sidebar_skins').html(html);$('#sidebar_skins li a[data-skin]').bind('click',function(){var skin=$(this).attr('data-skin');admincpOp.config('skin',skin,function(){for(var i in skinList){i='skin-'+i;$('body').removeClass(i)}
$('body').addClass(skin)})})}};var globalOp={insertAtCaret:function(myField,myValue){myField=$(myField);var curObj=myField[0];if(document.selection){myField.focus();var sel=document.selection.createRange();sel.text=myValue;sel.select()}else if(curObj.selectionStart||curObj.selectionStart=='0'){var startPos=curObj.selectionStart;var endPos=curObj.selectionEnd;var restoreTop=curObj.scrollTop;var value=myField.val();value=value.substring(0,startPos)+myValue+value.substring(endPos,value.length);myField.val(value);myField.focus();curObj.selectionStart=startPos+myValue.length;curObj.selectionEnd=startPos+myValue.length}else{myField.val(myField.val()+myValue);myField.focus()}},urlUsertoken:function(){return'_usertoken_='+encodeURIComponent(window.site_config.usertoken)},openStoreUrl:function(url){if(url.indexOf('clientinfo=')<0&&window.site_config.clientinfo){url+=(url.indexOf('?')>-1?'&':'?')+'clientinfo='+encodeURIComponent(window.site_config.clientinfo)}
window.open(url,'_blank')},eleExchange:function(box,move,ele,options){if(!isObject(options)){options={}}
if(!window.ele_exchange_is_touch){window.ele_exchange_is_touch=1;if('ontouchstart' in window||navigator.maxTouchPoints){window.ele_exchange_is_touch=2}}
if(window.ele_exchange_is_touch==2){$(box).on('click',move,function(){var obj=$(this).parents(ele).eq(0);var next=obj.next(ele);if(next.length>0){next.after(obj)}})}else{var curTrTds={};$(box).on('mousedown',move,function(){var obj=$(this).parents(ele).eq(0);if(obj.is('tr')){curTrTds={};obj.children('th,td').each(function(index){curTrTds[index]={width:$(this).width(),colspan:toInt($(this).attr('colspan')),hidden:$(this).is(':hidden')?true:!1}})}});var sOpts={items:ele,handle:move,axis:'y',start:function(event,ui){if(ui&&ui.item){var obj=$(ui.item[0]);if(obj.is('tr')){obj.children('th,td').each(function(index){var curTrTd=curTrTds[index];if(isObject(curTrTd)){$(this).width(curTrTd.width);if(curTrTd.colspan>0){$(this).attr('colspan',curTrTd.colspan)}
if(curTrTd.hidden){$(this).hide()}}});$('.ui-sortable-placeholder').children('th,td').each(function(index){var curTrTd=curTrTds[index];if(isObject(curTrTd)){$(this).width(curTrTd.width);if(curTrTd.colspan>0){$(this).attr('colspan',curTrTd.colspan)}
if(curTrTd.hidden){$(this).hide()}}})}}}};for(var i in options){sOpts[i]=options[i]}
$(box).sortable(sOpts)}},visualizeData:function(data){var cacheData=data;data=isNull(data)?'':data;var options={lg:1,hidden_func:function(){window.win_visualize_data=null}};if(dataIsJson(data)){var jsonId='json_'+generateUUID();modal('JSON解析','',options);var jsonTreeFunc=function(){window.tool_json_tree.treeId='#'+jsonId;window.tool_json_tree.load(data)};if(window.tool_json_tree){jsonTreeFunc()}else{$.getScript(window.site_config.pub+'/static/js/admin/tool_json_tree.js',jsonTreeFunc)}}else{options.loaded_func=function(){data=data.replace(/