You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
skycaiji/public/static/js/admin.js

57 lines
28 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/*
|--------------------------------------------------------------------------
| SkyCaiji (蓝天采集器)
|--------------------------------------------------------------------------
| Copyright (c) 2018 https://www.skycaiji.com All rights reserved.
|--------------------------------------------------------------------------
| 使用协议 https://www.skycaiji.com/licenses
|--------------------------------------------------------------------------
*/
'use strict';function admincpInit(){var bodyWidth=$(document.body).width();var admincp_skin=getCookie('admincp_skin');if(admincp_skin){$('body').removeClass('skin-blue').addClass(admincp_skin)}
if(bodyWidth>767){var admincp_sd_mini=getCookie('admincp_sd_mini');if(admincp_sd_mini==1){$('body').addClass('sidebar-collapse').addClass('sidebar-mini')}}
$(document).ready(function(){$('#treeview_skins').bind('click',function(){if($('#sidebar_skins').html().length<=0){initSkins()}});if(bodyWidth>767){var admincp_sd_mini=getCookie('admincp_sd_mini');if(admincp_sd_mini==1){$('#chk_sidebar_mini').attr('checked','checked')}
$('#chk_sidebar_mini').bind('click',function(){var setMini=0;if($(this).is(':checked')){$('body').addClass('sidebar-collapse').addClass('sidebar-mini');setMini=1}else{$('body').removeClass('sidebar-collapse').removeClass('sidebar-mini')}
setCookie('admincp_sd_mini',setMini,30)});$('.sidebar-toggle[data-toggle="push-menu"]').bind('click',function(){$('body').addClass('sidebar-mini')})}else{$('#chk_sidebar_mini').parents('li').eq(0).hide()}
if($('#menu_backstage_task').length>0){$('#menu_backstage_task').bind('click',function(){windowModal('后台任务',ulink('admin/backstage/backstageTask'),{lg:1})});backstageTask()}})}
function insertAtCaret(myField,myValue){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()}}
function initSkins(){var $skinsList=$('<ul />',{'class':'list-unstyled clearfix'});var $skinBlue=$('<li />',{style:'float:left; width: 33.33333%; padding: 5px;'}).append('<a href="javascript:void(0)" data-skin="skin-blue" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">'+'<div><span style="display:block; width: 20%; float: left; height: 7px; background: #367fa9"></span><span class="bg-light-blue" style="display:block; width: 80%; float: left; height: 7px;"></span></div>'+'<div><span style="display:block; width: 20%; float: left; height: 20px; background: #222d32"></span><span style="display:block; width: 80%; float: left; height: 20px; background: #f4f5f7"></span></div>'+'</a>'+'<p class="text-center no-margin">'+window.tpl_lang.skin_blue+'</p>');$skinsList.append($skinBlue);var $skinBlack=$('<li />',{style:'float:left; width: 33.33333%; padding: 5px;'}).append('<a href="javascript:void(0)" data-skin="skin-black" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">'+'<div style="box-shadow: 0 0 2px rgba(0,0,0,0.1)" class="clearfix"><span style="display:block; width: 20%; float: left; height: 7px; background: #fefefe"></span><span style="display:block; width: 80%; float: left; height: 7px; background: #fefefe"></span></div>'+'<div><span style="display:block; width: 20%; float: left; height: 20px; background: #222"></span><span style="display:block; width: 80%; float: left; height: 20px; background: #f4f5f7"></span></div>'+'</a>'+'<p class="text-center no-margin">'+window.tpl_lang.skin_black+'</p>');$skinsList.append($skinBlack);var $skinPurple=$('<li />',{style:'float:left; width: 33.33333%; padding: 5px;'}).append('<a href="javascript:void(0)" data-skin="skin-purple" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">'+'<div><span style="display:block; width: 20%; float: left; height: 7px;" class="bg-purple-active"></span><span class="bg-purple" style="display:block; width: 80%; float: left; height: 7px;"></span></div>'+'<div><span style="display:block; width: 20%; float: left; height: 20px; background: #222d32"></span><span style="display:block; width: 80%; float: left; height: 20px; background: #f4f5f7"></span></div>'+'</a>'+'<p class="text-center no-margin">'+window.tpl_lang.skin_purple+'</p>');$skinsList.append($skinPurple);var $skinGreen=$('<li />',{style:'float:left; width: 33.33333%; padding: 5px;'}).append('<a href="javascript:void(0)" data-skin="skin-green" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">'+'<div><span style="display:block; width: 20%; float: left; height: 7px;" class="bg-green-active"></span><span class="bg-green" style="display:block; width: 80%; float: left; height: 7px;"></span></div>'+'<div><span style="display:block; width: 20%; float: left; height: 20px; background: #222d32"></span><span style="display:block; width: 80%; float: left; height: 20px; background: #f4f5f7"></span></div>'+'</a>'+'<p class="text-center no-margin">'+window.tpl_lang.skin_green+'</p>');$skinsList.append($skinGreen);var $skinRed=$('<li />',{style:'float:left; width: 33.33333%; padding: 5px;'}).append('<a href="javascript:void(0)" data-skin="skin-red" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">'+'<div><span style="display:block; width: 20%; float: left; height: 7px;" class="bg-red-active"></span><span class="bg-red" style="display:block; width: 80%; float: left; height: 7px;"></span></div>'+'<div><span style="display:block; width: 20%; float: left; height: 20px; background: #222d32"></span><span style="display:block; width: 80%; float: left; height: 20px; background: #f4f5f7"></span></div>'+'</a>'+'<p class="text-center no-margin">'+window.tpl_lang.skin_red+'</p>');$skinsList.append($skinRed);var $skinYellow=$('<li />',{style:'float:left; width: 33.33333%; padding: 5px;'}).append('<a href="javascript:void(0)" data-skin="skin-yellow" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">'+'<div><span style="display:block; width: 20%; float: left; height: 7px;" class="bg-yellow-active"></span><span class="bg-yellow" style="display:block; width: 80%; float: left; height: 7px;"></span></div>'+'<div><span style="display:block; width: 20%; float: left; height: 20px; background: #222d32"></span><span style="display:block; width: 80%; float: left; height: 20px; background: #f4f5f7"></span></div>'+'</a>'+'<p class="text-center no-margin">'+window.tpl_lang.skin_yellow+'</p>');$skinsList.append($skinYellow);var $skinBlueLight=$('<li />',{style:'float:left; width: 33.33333%; padding: 5px;'}).append('<a href="javascript:void(0)" data-skin="skin-blue-light" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">'+'<div><span style="display:block; width: 20%; float: left; height: 7px; background: #367fa9"></span><span class="bg-light-blue" style="display:block; width: 80%; float: left; height: 7px;"></span></div>'+'<div><span style="display:block; width: 20%; float: left; height: 20px; background: #f9fafc"></span><span style="display:block; width: 80%; float: left; height: 20px; background: #f4f5f7"></span></div>'+'</a>'+'<p class="text-center no-margin">'+window.tpl_lang.skin_blue_light+'</p>');$skinsList.append($skinBlueLight);var $skinBlackLight=$('<li />',{style:'float:left; width: 33.33333%; padding: 5px;'}).append('<a href="javascript:void(0)" data-skin="skin-black-light" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">'+'<div style="box-shadow: 0 0 2px rgba(0,0,0,0.1)" class="clearfix"><span style="display:block; width: 20%; float: left; height: 7px; background: #fefefe"></span><span style="display:block; width: 80%; float: left; height: 7px; background: #fefefe"></span></div>'+'<div><span style="display:block; width: 20%; float: left; height: 20px; background: #f9fafc"></span><span style="display:block; width: 80%; float: left; height: 20px; background: #f4f5f7"></span></div>'+'</a>'+'<p class="text-center no-margin">'+window.tpl_lang.skin_black_light+'</p>');$skinsList.append($skinBlackLight);var $skinPurpleLight=$('<li />',{style:'float:left; width: 33.33333%; padding: 5px;'}).append('<a href="javascript:void(0)" data-skin="skin-purple-light" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">'+'<div><span style="display:block; width: 20%; float: left; height: 7px;" class="bg-purple-active"></span><span class="bg-purple" style="display:block; width: 80%; float: left; height: 7px;"></span></div>'+'<div><span style="display:block; width: 20%; float: left; height: 20px; background: #f9fafc"></span><span style="display:block; width: 80%; float: left; height: 20px; background: #f4f5f7"></span></div>'+'</a>'+'<p class="text-center no-margin">'+window.tpl_lang.skin_purple_light+'</p>');$skinsList.append($skinPurpleLight);var $skinGreenLight=$('<li />',{style:'float:left; width: 33.33333%; padding: 5px;'}).append('<a href="javascript:void(0)" data-skin="skin-green-light" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">'+'<div><span style="display:block; width: 20%; float: left; height: 7px;" class="bg-green-active"></span><span class="bg-green" style="display:block; width: 80%; float: left; height: 7px;"></span></div>'+'<div><span style="display:block; width: 20%; float: left; height: 20px; background: #f9fafc"></span><span style="display:block; width: 80%; float: left; height: 20px; background: #f4f5f7"></span></div>'+'</a>'+'<p class="text-center no-margin">'+window.tpl_lang.skin_green_light+'</p>');$skinsList.append($skinGreenLight);var $skinRedLight=$('<li />',{style:'float:left; width: 33.33333%; padding: 5px;'}).append('<a href="javascript:void(0)" data-skin="skin-red-light" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">'+'<div><span style="display:block; width: 20%; float: left; height: 7px;" class="bg-red-active"></span><span class="bg-red" style="display:block; width: 80%; float: left; height: 7px;"></span></div>'+'<div><span style="display:block; width: 20%; float: left; height: 20px; background: #f9fafc"></span><span style="display:block; width: 80%; float: left; height: 20px; background: #f4f5f7"></span></div>'+'</a>'+'<p class="text-center no-margin">'+window.tpl_lang.skin_red_light+'</p>');$skinsList.append($skinRedLight);var $skinYellowLight=$('<li />',{style:'float:left; width: 33.33333%; padding: 5px;'}).append('<a href="javascript:void(0)" data-skin="skin-yellow-light" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">'+'<div><span style="display:block; width: 20%; float: left; height: 7px;" class="bg-yellow-active"></span><span class="bg-yellow" style="display:block; width: 80%; float: left; height: 7px;"></span></div>'+'<div><span style="display:block; width: 20%; float: left; height: 20px; background: #f9fafc"></span><span style="display:block; width: 80%; float: left; height: 20px; background: #f4f5f7"></span></div>'+'</a>'+'<p class="text-center no-margin">'+window.tpl_lang.skin_yellow_light+'</p>');$skinsList.append($skinYellowLight);$('#sidebar_skins').html($skinsList);var mySkins=new Array('skin-blue','skin-black','skin-red','skin-yellow','skin-purple','skin-green','skin-blue-light','skin-black-light','skin-red-light','skin-yellow-light','skin-purple-light','skin-green-light');$('#sidebar_skins li a[data-skin]').bind('click',function(){var skin=$(this).attr('data-skin');for(var i in mySkins){$('body').removeClass(mySkins[i])}
$('body').addClass(skin);setCookie('admincp_skin',skin,30)})}
function urlUsertoken(){return'_usertoken_='+encodeURIComponent(window.site_config.usertoken)}
function openStoreUrl(url){if(url.indexOf('clientinfo=')<0&&window.site_config.clientinfo){url+=(url.indexOf('?')>-1?'&':'?')+'clientinfo='+encodeURIComponent(window.site_config.clientinfo)}
window.open(url,'_blank')}
function eleExchange(box,up,down,ele){$(box).on('click',up,function(){var obj=$(this).parents(ele).eq(0);var prev=obj.prev(ele);if(prev.length>0){prev.before(obj)}});$(box).on('click',down,function(){var obj=$(this).parents(ele).eq(0);var next=obj.next(ele);if(next.length>0){next.after(obj)}})}
function showPanelCollapse(id){$(id).parent().find('a[data-toggle][href="'+id+'"]').attr('aria-expanded',!0).removeClass('collapsed');$(id).addClass('in').attr('aria-expanded',!0).attr('style','')}
function inputSelectCustom(sltObj,iptName,onOptions){if(sltObj&&iptName){$(sltObj).bind('change',function(){var ipt=$(this).parents('.input-select-custom').eq(0).find('[name="'+iptName+'"]');if($(this).val()=='custom'){ipt.show()}else{ipt.hide()}})}else if(onOptions&&typeof(onOptions)=='object'){$(onOptions.box).on('change',onOptions.slt,function(){var ipt=$(this).parents('.input-select-custom').eq(0).find(onOptions.ipt);if($(this).val()=='custom'){ipt.show()}else{ipt.hide()}})}}
function visualizeData(data){var cacheData=data;data=isNull(data)?'':data;var options={lg:1,hidden_func:function(){window.win_visualize_data=null}};if(dataIsJson(data)){var jsonId='json_'+generateUUID();modal('JSON解析','<div id="'+jsonId+'"></div>',options);var jsonTreeFunc=function(){window.tool_json_tree.treeId='#'+jsonId;window.tool_json_tree.load(data)};if(window.tool_json_tree){jsonTreeFunc()}else{$.getScript(window.site_config.pub+'/static/js/admin/tool_json_tree.js',jsonTreeFunc)}}else{options.loaded_func=function(){data=data.replace(/<script[^<>]*>[\s\S]*?<\/script>/ig,'');data=data.replace(/<meta[^<>]*charset[^<>]*>/i,'');var ifrId='#myModalIframe';$(ifrId).bind('load',function(){if($(ifrId).contents().find('body').html().length<=0){$(ifrId).contents().find('body').html(data)}});$(ifrId).contents().find('body').html(data)};windowIframe('HTML预览','',options)}(function(data){if(data){$('#myModal .modal-footer .close').addClass('btn btn-default').removeClass('close');$('#myModal .modal-footer').prepend('<button type="button" class="btn btn-info btn-back" data-dismiss="modal">返回</button>');$('#myModal .modal-footer .btn-back').bind('click',function(){visualizeData(data)})}})(window.win_visualize_data);window.win_visualize_data=cacheData}
function cpEasyBrowser(url,pageSource,inputUrls){pageSource=pageSource?pageSource:'';inputUrls=inputUrls?inputUrls:{};var data={type:'browser_url',page_source:pageSource,test_url:url,input_urls:inputUrls};data=JSON.stringify(data);window.top.postMessage(data,'*')}
function cpBrowserUrl(collId,pageSource,testUrl,inputedUrls){inputedUrls=inputedUrls?inputedUrls:{};var url='cpattern_test/browser?coll_id=_collid_&page_source=_source_&test_url=_url_';if(inputedUrls){for(var i in inputedUrls){url+='&'+i+'='+encodeURIComponent(inputedUrls[i])}}
url=ulink(url,{'_collid_':collId,'_source_':pageSource,'_url_':testUrl});return url}
function loadPluginFunc(params){params=params?params:{};var boxObj=$(params.boxObj);var funcObj=boxObj.find(params.funcObj);var paramObj=params.paramObj?boxObj.find(params.paramObj):null;var funcVal=params.funcVal?params.funcVal:'';var winCacheName='win_cache_plugin_func_'+params.module;if(paramObj&&paramObj.length>0){if(!funcObj.attr('data-change-pla')){funcObj.attr('data-change-pla',1);funcObj.bind('change',function(){var reStrFunc=function(str){if(str){var regLineR=new RegExp("\\\\r",'g');var regLineN=new RegExp("\\\\n",'g');str=str.replace(regLineR,"\r").replace(regLineN,"\n")}else{str=''}
return str};paramObj=boxObj.find(params.paramObj);var placeholder=paramObj.attr('data-placeholder');placeholder=reStrFunc(placeholder);if($(this).val()){var sltOption=$(this).find('option:selected');var funcPrams=sltOption.attr('data-params');funcPrams=funcPrams?funcPrams:'';var funcComment=sltOption.attr('data-comment');funcComment=funcComment?funcComment:'';if(funcPrams||funcComment){if(funcPrams){placeholder+="\r\n函数参数"+reStrFunc(funcPrams)}
if(funcComment){placeholder+="\r\n函数注释"+reStrFunc(funcComment)}}}
var rows=2;if(placeholder){var regLine=new RegExp("[\\r\\n]+",'g');var matchLine=placeholder.split(regLine);if(matchLine&&typeof(matchLine)=='object'){rows=parseInt(matchLine.length)+1}}
if(rows>8){rows=8}
if(rows<2){rows=2}
paramObj.attr('placeholder',placeholder).attr('rows',rows)})}}
var setFuncVal=function(){funcObj.val(funcVal).trigger('change')};if(funcObj.attr('data-is-loaded')){setFuncVal()}else{if(params.cache&&window[winCacheName]){funcObj.attr('data-is-loaded',1).append(window[winCacheName]);setFuncVal()}else{ajaxOpen({type:'GET',dataType:'json',url:ulink('Collector/plugin_func'),async:params.cache?false:!0,data:{module:params.module},success:function(data){if(funcObj.attr('data-is-loaded')){setFuncVal()}else{funcObj.attr('data-is-loaded',1);if(data.code==1){var html='';var apps=data.data;if(apps&&typeof(apps)=='object'){for(var app in apps){var appData=apps[app];appData=appData?appData:{};var methods=appData.methods;if(methods){html+='<optgroup label="'+htmlspecialchars(appData.name+''+app+'')+'">';for(var m in methods){var mMethod=methods[m];mMethod=mMethod?mMethod:{};html+='<option value="'+app+':'+m+'" data-params="'+(mMethod.params?mMethod.params:'')+'" data-comment="'+(mMethod.comment?mMethod.comment:'')+'">'+m+''+(mMethod.comment_cut?mMethod.comment_cut:'')+'</option>'}
html+='</optgroup>'}}}
funcObj.append(html);if(params.cache){window[winCacheName]=html}}}},error:function(xhr,status,error){funcObj.removeAttr('data-is-loaded');toastr.error('函数插件载入失败:'+status+' '+error)},complete:function(xhr,status){setFuncVal()}})}}}
function pluginFuncTips(module){var tips='';if(module=='process'){tips='<p>如需扩展系统函数,请在根目录/data/config.php中添加配置</p>'+"<p>'EXTEND_PROCESS_FUNC'=&gt;array('PHP函数名'=&gt;'描述')</p>"+'<p>如需扩展插件函数,可创建<a href="'+ulink('Develop/func')+'" target="_blank">函数插件</a></p>'}else if(module=='processIf'){tips='<p>选择函数,取反可获取函数结果的相反值</p>'+'<p>默认将当前字段值作为参数传入,如需传入多个参数,一行一个值,用###表示当前字段值或输入任意内容</p>'+'<p>请按函数传参,否则运行出错!</p>'+'<p>如需扩展系统函数,请在根目录/data/config.php中添加配置</p>'+"<p>'EXTEND_PROCESS_IF'=&gt;array('PHP函数名'=&gt;'描述')</p>"+'<p>如需扩展插件函数,可创建<a href="'+ulink('Develop/func')+'" target="_blank">函数插件</a></p>'}else if(module=='downloadImg'){window.open(ulink('Develop/func'));return!1}
confirmRight({msg:tips,yes:'确定',width:500,textAlign:'left'})}
function collectorEchoMsg(op,params){if(op=='start'){params=isNull(params)?{}:params;if(!params.is_backstage){var html='';if(params.server_is_cli){html='当前使用web服务器运行采集您已开启cli命令行可切换至<a href="javascript:;" id="win_c_e_m_backstage1" title="切换cli后台模式">cli后台模式</a>,运行更稳定!'}else{var isRealTime=!1;var jsTime=new Date().getTime();if(Math.abs(jsTime-(toInt(params.js_time)*1000))<=3000){isRealTime=!0}
if(!isRealTime){html='您的web服务器不能实时显示内容请修改'+(isNull(params.server)?'':params.server)+'缓冲区大小或使用<a href="javascript:;" id="win_c_e_m_backstage1" title="切换后台模式">后台模式</a>'}}
if(html){$('#myModal .modal-title').html(html).css({'font-size':'14px'});$('#win_c_e_m_backstage1').bind('click',function(){collectorEchoMsg('set_backstage',1)})}}}else if(op=='end'){window.win_c_e_m_end=!0;$('#myModal .modal-title').find('.loading-sm').remove()}else if(op=='set_backstage'){ajaxOpen({type:'get',dataType:'json',async:!0,url:ulink('admin/collector/echo_msg?op=set_backstage&backstage=_bk_',{'_bk_':params}),success:function(data){ajaxDataMsg(data)}})}else if(op=='set_interval'){ajaxOpen({type:'get',dataType:'json',async:!0,url:ulink('admin/collector/echo_msg?op=set_interval&interval=_num_',{'_num_':params}),success:function(data){ajaxDataMsg(data)}})}else if(op=='run'){window.win_c_e_m_end=!1;params=isNull(params)?{}:params;var isBackstage=toInt(params.is_backstage);isBackstage=isBackstage>0?true:!1;var serverIsCli=params.server_is_cli?true:!1;var differSeconds=toInt(params.differ_seconds);var interval=toInt(params.interval);if(interval<=0){interval=2}
var winParams=window.win_collector_window_params;winParams=winParams?winParams:{};var uri=winParams.uri?winParams.uri:'';var uriVals=winParams.uriVals?winParams.uriVals:{};var options=winParams.options?winParams.options:{};var title='';if(uri){var logid=generateUUID();var closeFuncs=new Array();if(!isNull(options.close_func)){if(typeof(options.close_func)=='object'){closeFuncs=options.close_func}else{closeFuncs.push(options.close_func)}}
closeFuncs.push(function(){if(window.win_c_e_m_read_ajax){window.win_c_e_m_read_ajax.abort()}
if(window.win_c_e_m_read_timeout){window.clearTimeout(window.win_c_e_m_read_timeout)}
ajaxOpen({type:'get',url:ulink('admin/collector/echo_msg?op=stop&logid=_logid_',{'_logid_':logid}),dataType:'json',async:!0,success:function(data){}})});options.close_func=closeFuncs;var url='';uri+=(uri.indexOf('?')>-1?'&':'?')+'logid=_logid_';uriVals._logid_=logid;if(!isBackstage){uri+='&differ_seconds=_differ_';uriVals._differ_=differSeconds;url=ulink(uri,uriVals);title=winParams.title;windowIframe(title,url,options)}else{uri+='&backstage=1';url=ulink(uri,uriVals);title=winParams.title+'<small style="margin-left:10px;">'+(serverIsCli?'cli':'')+'后台模式,日志读取间隔<input type="number" class="form-control input-sm" style="display:inline;width:40px;height:20px;padding:1px 2px 1px 2px;margin:0px 3px 0px 3px;" id="win_c_e_m_interval" value="'+interval+'" />秒<button type="button" class="btn btn-default btn-xs" id="win_c_e_m_interval_btn" style="margin-left:3px;">保存</button> <span style="margin:0px 5px 0px 5px">|</span> <a href="javascript:;" id="win_c_e_m_backstage0" title="切换'+(serverIsCli?'web服务器':'实时')+'模式">'+(serverIsCli?'web服务器':'实时')+'模式</a></small>';windowIframe(title,url,options);$('#myModal iframe').hide();$('#myModal #win_c_e_m_interval_btn').bind('click',function(){collectorEchoMsg('set_interval',$('#win_c_e_m_interval').val())});$('#myModal #win_c_e_m_backstage0').bind('click',function(){collectorEchoMsg('set_backstage',0)});var logIfr=document.createElement('iframe');$(logIfr).attr('id','win_c_e_m_ifr');$(logIfr).attr('width','100%');$(logIfr).attr('height','100%');$(logIfr).attr('frameborder','0');$(logIfr).attr('scrolling','yes');$(logIfr).bind('load',function(){window.win_c_e_m_line=0;var readFunc=function(){var eleId='start_line_'+window.win_c_e_m_line;if($('#win_c_e_m_ifr').contents().find('#'+eleId).length<=0){$('#win_c_e_m_ifr').contents().find('body').append('<div id="'+eleId+'" style="display:none;"></div>')}
window.win_c_e_m_read_ajax=ajaxOpen({type:'get',dataType:'json',async:!0,url:ulink('admin/collector/echo_msg?op=read&logid=_logid_&line=_line_',{'_logid_':logid,'_line_':window.win_c_e_m_line}),success:function(data){if(data.code==1&&data.data){var list=data.data.list;if(list){var lines=Object.keys(list);var line=parseInt(data.data.line);if(lines&&lines.length>0&&line>0){window.win_c_e_m_line=line;var eleObj=$('#win_c_e_m_ifr').contents().find('#'+eleId);var html='';for(var line in list){html+=list[line]}
eleObj.html(html).hide().fadeIn()}}}},complete:function(){window.win_c_e_m_read_timeout=setTimeout(function(){if($('#win_c_e_m_ifr').is(':visible')){if(!window.win_c_e_m_end){readFunc()}}},interval*1000)}})};readFunc()});$('#myModal .modal-body').append(logIfr)}}}}
function collectorWindow(title,uri,uriVals,options){options=options?options:{};title=isNull(title)?'':title;title+='<div class="loading-sm" style="margin-left:5px;"></div>';window.win_collector_window_params={title:title,uri:uri,uriVals:uriVals,options:options};var jsTime=new Date().getTime();windowModal(title,ulink('admin/collector/echo_msg?op=collect&js_time=_time_',{'_time_':jsTime}),{lg:options.lg})}
function backstageTask(delay){delay=toInt(delay);if(delay>0){setTimeout("_backstageTask()",delay)}else{_backstageTask()}}
function _backstageTask(){ajaxOpen({type:'get',dataType:'json',async:!0,url:ulink('admin/backstage/backstageTask?op=count'),success:function(data){if(data.code==1&&data.data){var count=parseInt(data.data.count);count=count>0?count:'';$('#menu_backstage_task .label').text(count)}else{$('#menu_backstage_task .label').text('')}}})}
function winBackstageTask(module,params){params=isNull(params)?{}:params;if(module=='init'){$('#win_backstage_task a[href="#win_bk_task0"],#win_backstage_task a[href="#win_bk_task1"]').bind('click',function(){var op=$($(this).attr('href')).attr('data-op');winBackstageTask('list',{op:op})});$('#win_backstage_task a[href="#win_bk_task0"]').trigger('click')}else if(module=='init_list'){params.taskType=parseInt(params.taskType);if(!window.interval_bk_tasks){window.interval_bk_tasks={}}
$('#win_bk_task_list_'+(params.taskType==0?1:0)).html('');$('#win_bk_task_list_0 a[data-parent="#win_bk_task_list_0"]').bind('click',function(){var taskId=$($(this).attr('href')).attr('data-task-id');winBackstageTask('collected',{taskId:taskId});if(window.interval_bk_tasks[taskId]){clearInterval(window.interval_bk_tasks[taskId])}
window.interval_bk_tasks[taskId]=setInterval(function(){if($('#win_bk_task_list_0 #win_bk_t_list_'+taskId).is(':visible')){winBackstageTask('collected',{taskId:taskId})}else{clearInterval(window.interval_bk_tasks[taskId])}},3000)});$('#win_bk_task_list_1 a[data-parent="#win_bk_task_list_1"]').bind('click',function(){var taskId=$($(this).attr('href')).attr('data-task-id');winBackstageTask('collected',{taskId:taskId})});$('[id^="win_bk_task_list_"] .fa-remove').bind('click',function(){var obj=$(this);var taskId=$(this).attr('data-task-id');ajaxOpen({type:'get',dataType:'json',async:!0,url:ulink('admin/task/bkdelete?id='+taskId),success:function(data){obj.parents('.panel').remove()}})});$('#win_bk_task_list_'+params.taskType+' .pagination').addClass('pagination-sm');$('#win_bk_task_list_'+params.taskType+' .pagination a').bind('click',function(){var op=$(this).parents('.tab-pane[data-op]').eq(0).attr('data-op');winBackstageTask('list',{op:op,url:$(this).attr('href')});return!1})}else if(module=='init_collected'){$('[id^="win_bk_t_list_"] .pagination').addClass('pagination-sm');$('[id^="win_bk_t_list_"] .pagination a').bind('click',function(){var taskId=$(this).parents('[id^="win_bk_t_list_"]').eq(0).attr('data-task-id');if(window.interval_bk_tasks[taskId]){clearInterval(window.interval_bk_tasks[taskId])}
winBackstageTask('collected',{taskId:taskId,url:$(this).attr('href')});return!1});if(toInt(params.taskStatus)>0){$('#win_bk_task_list_0').find('a[href="#win_bk_t_list_'+params.taskId+'"]').find('.is_loading').html('<small>已结束</small>');backstageTask()}}else if(module=='list'){var op=params.op;var url=params.url;$('#win_bk_'+op).html('<div class="loading-sm"></div>');ajaxOpen({type:'get',dataType:'json',async:!0,url:(url?url:ulink('admin/backstage/backstageTask?op='+op)),success:function(data){if(data.code==1&&data.data){var count0=toInt(data.data.count0);var count1=toInt(data.data.count1);$('#win_backstage_task').find('a[href="#win_bk_task0"]').find('span').text(count0);$('#win_backstage_task').find('a[href="#win_bk_task1"]').find('span').text(count1);$('#win_backstage_task').find('a[href="#win_bk_'+op+'"]').tab('show');$('#win_bk_'+op).html(data.data.html)}else{$('#win_bk_'+op).html('无任务')}
backstageTask()}})}else if(module=='collected'){var taskId=params.taskId;var url=params.url;ajaxOpen({type:'get',dataType:'html',async:!0,url:(url?url:ulink('admin/backstage/backstageTask?op=collected&tid='+taskId)),success:function(data){$('#win_bk_t_list_'+taskId).html(data)}})}}