One Hat Cyber Team
  • Dir : ~/www/server/panel/BTPanel/static/js/
  • Edit File: files.js
    ':'')+ '
    ' + '' ) // 输入增高、回车、焦点、失去焦点 $((bt.get_cookie('rank') == 'icon'?'textarea':'input')+'[name=createArea]').on('input',function(){ if(bt.get_cookie('rank') == 'icon'){ this.style.height = 'auto'; this.style.height = this.scrollHeight + "px"; } }).keyup(function(e){ if(e.keyCode == 13) $(this).blur(); }).blur(function(e){ var _val = $(this).val().replace(/[\r\n]/g,""); if(that.match_unqualified_string(_val)) return layer.msg('Name cannot contain /\\:*?"<>| symbol',{icon:2}) if(_val == '') _val = (type == 'newBlankDir'? 'New directory':'New blank file'); setTimeout(function(){ //延迟处理,防止Li再次触发 that.create_file_req({type:(type == 'newBlankDir' ? 'folder':'file'),path:that.file_path+'/'+_val},function(res){ if(res.status) that.reader_file_list({path:that.file_path}); layer.msg(res.msg,{icon:res.status?1:2}); }) $('.createModel').remove(); // 删除模板 that.is_editor = false; },300) e.preventDefault(); }).focus(); }else{ return false; } e.stopPropagation(); e.preventDefault(); }) // 收藏夹列表跳转 $('.file_nav_view .favorites_file_path ul').on('click','li',function(e){ var _href = $(this).data('path'),_type = $(this).data('type'),nav_down_list = $('.favorites_file_path .nav_down_list'); if(_type == 'dir'){ that.reader_file_list({path:_href,is_operating:true}); }else{ if($(this).data('null') != undefined) return false; var _file = $(this).attr('title').split('.'),_fileT = _file[_file.length -1],_fileE = that.determine_file_type(_fileT); switch(_fileE){ case 'text': openEditorView(0,_href) break; case 'video': that.open_video_play(_href); break; case 'images': that.open_images_preview({filename:$(this).attr('title'),path:_href}); break; default: that.reader_file_list({path:that.retrun_prev_path(_href),is_operating:true}); break; } } //点击隐藏 nav_down_list.css({'display':function(){ setTimeout(function(){nav_down_list.removeAttr('style')},100) return 'none'; }}); e.stopPropagation(); e.preventDefault(); }) // 打开终端 $('.terminal_view').on('click',function(){ web_shell(); }); // 分享列表 $('.share_file_list').on('click',function(){ that.open_share_view(); }) // 打开硬盘挂载的目录 $('.mount_disk_list').on('click','.nav_btn',function(){ var path = $(this).data('menu'); that.reader_file_list({path:path,is_operating:true}); }); // 硬盘磁盘挂载 $('.mount_disk_list').on('click','.nav_down_list li',function(){ var path = $(this).data('disk'),disk_list = $('.mount_disk_list.thezoom .nav_down_list'); disk_list.css({'display':function(){ setTimeout(function(){disk_list.removeAttr('style')},100) return 'none'; }}); that.reader_file_list({path:path,is_operating:true}); }); // 全部权限备份按钮 $('.file_nav_view').on('click','.manage_backup',function(ev){ that.manage_backup(); ev.stopPropagation(); ev.preventDefault(); }); // 回收站 $('.file_nav_view').on('click','.recycle_bin',function(ev){ that.recycle_bin_view(); ev.stopPropagation(); ev.preventDefault(); }); // 批量操作 $('.file_nav_view .multi').on('click','.nav_btn_group',function(ev){ var batch_type = $(this).data('type'); if(typeof batch_type != 'undefined') that.batch_file_manage(batch_type); ev.stopPropagation(); ev.preventDefault(); }); // 批量操作 $('.file_nav_view .multi').on('click','.nav_btn_group li',function(ev){ var batch_type = $(this).data('type'); that.batch_file_manage(batch_type); ev.stopPropagation(); ev.preventDefault(); }); // 全部粘贴按钮 $('.file_nav_view').on('click','.file_all_paste',function(){ that.paste_file_or_dir(); }); // 表头点击事件,触发排序字段和排序方式 $('.file_list_header').on('click','.file_name,.file_size,.file_mtime,.file_accept,.file_user', function (e) { var _tid = $(this).attr('data-tid'), _reverse = $(this).find('.icon_sort').hasClass('active'), _active = $(this).hasClass('active'); if (!$(this).find('.icon_sort').hasClass('active') && $(this).hasClass('active')) { $(this).find('.icon_sort').addClass('active'); }else{ $(this).find('.icon_sort').removeClass('active'); } $(this).addClass('active').siblings().removeClass('active').find('.icon_sort').removeClass('active').empty(); $(this).find('.icon_sort').html(''); if (!_active) _reverse = true bt.set_cookie('files_sort', _tid); bt.set_cookie('name_reverse', _reverse ? 'True' : 'False'); that.reader_file_list({reverse: _reverse ? 'True' : 'False',sort: _tid}); return false; }); // 设置排序显示 $('.file_list_header .file_th').each(function (index, item) { var files_sort = bt.get_cookie('files_sort'), name_reverse = bt.get_cookie('name_reverse'); if ($(this).attr('data-tid') === files_sort){ $(this).addClass('active').siblings().removeClass('active').find('.icon_sort').removeClass('active').empty(); $(this).find('.icon_sort').html(''); if (name_reverse === 'False') $(this).find('.icon_sort').addClass('active'); } }); // 全选选中文件 $('.file_list_header .file_check').on('click', function (e){ var checkbox = parseInt($(this).data('checkbox')); switch(checkbox){ case 0: $(this).addClass('active').removeClass('active_2').data('checkbox',1); $('.file_list_content .file_tr').addClass('active').removeClass('active_2'); $('.nav_group.multi').removeClass('hide'); $('.file_menu_tips').addClass('hide'); that.file_table_arry = that.file_list.slice(); break; case 2: $(this).addClass('active').removeClass('active_2').data('checkbox',1); $('.file_list_content .file_tr').addClass('active'); $('.nav_group.multi').removeClass('hide'); $('.file_menu_tips').addClass('hide'); that.file_table_arry = that.file_list.slice(); break; case 1: $(this).removeClass('active active_2').data('checkbox',0); $('.file_list_content .file_tr').removeClass('active'); $('.nav_group.multi').addClass('hide'); $('.file_menu_tips').removeClass('hide'); that.file_table_arry = []; break; } that.calculate_table_active(); }); // 文件勾选 $('.file_list_content').on('click', '.file_checkbox', function (e) { //列表选择 var _tr = $(this).parents('.file_tr'),index = _tr.data('index'),filename = _tr.data('filename'); if(_tr.hasClass('active')){ _tr.removeClass('active'); that.remove_check_file(that.file_table_arry,'filename',filename); }else{ _tr.addClass('active'); _tr.attr('data-filename',that.file_list[index]['filename']); that.file_table_arry.push(that.file_list[index]); } that.calculate_table_active(); e.stopPropagation(); }); // 文件列表滚动条事件 $('.file_list_content').scroll(function(e){ if($(this).scrollTop() == ($(this)[0].scrollHeight - $(this)[0].clientHeight)){ $(this).prev().css('opacity',1); $(this).next().css('opacity',0); }else if($(this).scrollTop() > 0){ $(this).prev().css('opacity',1); }else if($(this).scrollTop() == 0){ $(this).prev().css('opacity',0); $(this).next().css('opacity',1); } }); // 选中文件 $('.file_table_view .file_list_content').on('click','.file_tr',function(e){ if($(e.target).hasClass('foo_menu_title') || $(e.target).parents().hasClass('foo_menu_title')) return true; $(this).addClass('active').siblings().removeClass('active'); that.file_table_arry = [that.file_list[$(this).data('index')]]; that.calculate_table_active(); e.stopPropagation(); e.preventDefault(); }); // 打开文件的分享、收藏状态 $('.file_table_view .file_list_content').on('click','.file_name .iconfont',function(e){ var file_tr = $(this).parents('.file_tr'),index = file_tr.data('index'),data = that.file_list[index]; data['index'] = index if($(this).hasClass('icon-share1')){that.info_file_share(data);} if($(this).hasClass('icon-favorites')){that.cancel_file_favorites(data);} e.stopPropagation(); }); // 打开文件夹和文件 --- 双击 $('.file_table_view .file_list_content').on('dblclick','.file_tr',function(e){ var index = $(this).data('index'),data = that.file_list[index]; if( $(e.target).hasClass('file_check') || $(e.target).parents('.foo_menu').length > 0 || $(e.target).hasClass('set_file_ps') || that.is_editor ) return false; if(data.type == 'dir'){ if(data['filename'] == 'Recycle_bin') return that.recycle_bin_view(); that.reader_file_list({path:that.file_path + '/' + data['filename'],is_operating:true}); }else{ switch(data.open_type){ case 'text': openEditorView(0,data.path) break; case 'video': that.open_video_play(data); break; case 'images': that.open_images_preview(data); break; case 'compress': that.unpack_file_to_path(data) break; } } e.stopPropagation(); e.preventDefault(); }); // 打开文件夹或文件 --- 文件名单击 $('.file_table_view .file_list_content').on('click','.file_title i,.file_ico_type .file_icon',function(e){ var file_tr = $(this).parents('.file_tr'),index = file_tr.data('index'),data = that.file_list[index]; if(data.type == 'dir'){ if(data['filename'] == 'Recycle_bin') return that.recycle_bin_view(); that.reader_file_list({path:that.file_path + '/' + data['filename'],is_operating:true}); }else{ layer.msg(data.open_type == 'compress'?'Double click to unzip the file':'Double click to edit the file'); } e.stopPropagation(); e.preventDefault(); }); // 禁用浏览器右键菜单 $('.file_list_content').on('contextmenu',function(ev){ if($(ev.target).attr('name') == 'createArea' || $(ev.target).attr('name') == 'rename_file_input'){ return true }else{ return false; } }) // 禁用菜单右键默认浏览器右键菜单 $('.selection_right_menu').on('contextmenu',function(ev){ return false; }); // 文件夹和文件鼠标右键 $('.file_list_content').on('mousedown','.file_tr',function(ev){ if(ev.which === 1 && ($(ev.target).hasClass('foo_menu_title') || $(ev.target).parents().hasClass('foo_menu_title'))){ that.render_file_groud_menu(ev,this); $(ev.target).parent().addClass('foo_menu_click'); $(this).siblings().find('.foo_menu').removeClass('foo_menu_click'); $(this).addClass('active').siblings().removeClass('active'); }else if(ev.which === 3 && !that.is_editor){ if(that.file_table_arry.length > 1){ that.render_files_multi_menu(ev); }else{ that.render_file_groud_menu(ev,this); $('.content_right_menu').removeAttr('style'); $(this).addClass('active').siblings().removeClass('active'); } }else{return true} ev.stopPropagation(); ev.preventDefault(); }); //设置单页显示的数量,默认为100,设置local本地缓存 $('.filePage').on('change','.showRow',function(){ var val = $(this).val(); bt.set_storage('local', 'showRow', val); var search = $('.file_search_input').val(); var data = { showRow: val, p: 1, is_operating: false, search: search, file_btn: !!search } if ($('#search_all').hasClass('active')) { data.all = 'True'; } that.reader_file_list(data); }); // 页码跳转 $('.filePage').on('click','div:nth-child(2) a',function(e){ var num = $(this).attr('href').match(/p=([0-9]+)$/)[1]; var search = $('.file_search_input').val(); var data = { path: that.path, p: num, search: search, file_btn: !!search } if ($('#search_all').hasClass('active')) { data.all = 'True'; } that.reader_file_list(data); e.stopPropagation(); e.preventDefault(); }) // 获取文件夹大小 $('.file_list_content').on('click','.folder_size',function(e){ var data = that.file_list[$(this).parents('.file_tr').data('index')],_this = this; that.get_file_size({path:data.path},function(res){ $(_this).text(bt.format_size(res.size)); }); e.stopPropagation(); e.preventDefault(); }); // 获取目录总大小 $('.filePage').on('click','#file_all_size',function(e){ if(that.file_path === '/'){ layer.tips('The current directory is document root (/),calculate size will occupymassive server IO,continue?',this,{tips:[1,'red'],time:5000}); return false; } that.get_dir_size({path:that.file_path}); }) // 文件区域【鼠标按下】 $('.file_list_content').on('mousedown',function(ev){ if( $(ev.target).hasClass('file_checkbox') || $(ev.target).hasClass('file_check') || $(ev.target).hasClass('icon-share1') || $(ev.target).hasClass('icon-favorites') || ev.target.localName == 'i' || $(ev.target).parents('.app_menu_group').length > 0 || $(ev.target).hasClass('createModel') || $(ev.target).hasClass('editr_tr') || $(ev.target).attr('name') == 'createArea' || $(ev.target).attr('name') == 'rename_file_input' || $(ev.target).hasClass('set_file_ps') || that.is_editor ) return true; if(ev.which == 3 && !that.is_editor){ $('.selection_right_menu').removeAttr('style'); that.render_file_all_menu(ev,this); return true; } //是否为右键 $('.file_list_content').bind('mousewheel', function() {return false;}); //禁止滚轮(鼠标抬起时解绑) var container = $(this), //当前选区容器 scroll_h = 0, con_t = container.offset().top, //选区偏移上 con_l = container.offset().left //选区偏移左 var startPos = { //初始位置 top: ev.clientY - $(this).offset().top, left: ev.clientX - $(this).offset().left }; // 鼠标按下后拖动 bt_file.window_mousemove = function(ev) { // 鼠标按下后移动到的位置 var endPos = { top: ev.clientY - con_t > 0 && ev.clientY - con_t < container.height() ? ev.clientY - con_t : (ev.clientY - (con_t+container.height()) > 1 ?container.height():0), left: ev.clientX - con_l > 0 && ev.clientX - con_l < container.width() ? ev.clientX - con_l : (ev.clientX - (con_l+container.width()) > 1 ?container.width():0) }; var fixedPoint = { // 设置定点 top: endPos.top > startPos.top ? startPos.top : endPos.top, left: endPos.left > startPos.left ? startPos.left : endPos.left }; var enter_files_box = that.enter_files_box() if(bt.get_cookie('rank') == 'list'){ //在列表模式下减去表头高度 fixedPoint.top = fixedPoint.top + 40 } // 拖拽范围的宽高 var w = Math.min(Math.abs(endPos.left - startPos.left), con_l + container.width() - fixedPoint.left); var h = Math.min(Math.abs(endPos.top - startPos.top), con_t + container.height() - fixedPoint.top); // 超出选区上时 if(ev.clientY - con_t < 0){ var beyond_t = Math.abs(ev.clientY - con_t); container.scrollTop(container.scrollTop() - beyond_t) if(container.scrollTop() != 0){ scroll_h += beyond_t } h = h+scroll_h } // 超出选区下时 if(ev.clientY - (con_t + container.height()) > 1){ var beyond_b = ev.clientY - (con_t + container.height()); container.scrollTop(container.scrollTop() + beyond_b) if(container[0].scrollHeight - container[0].scrollTop !== container[0].clientHeight){ scroll_h += beyond_b } h = h+ scroll_h fixedPoint.top = fixedPoint.top-scroll_h } if(startPos.top == endPos.top || startPos.left == endPos.left) return true; // 设置拖拽盒子位置 enter_files_box.show().css({ left: fixedPoint.left+'px', top: fixedPoint.top+'px', width: w+'px', height: h+'px' }); var box_offset_top = enter_files_box.offset().top; var box_offset_left = enter_files_box.offset().left; var box_offset_w = enter_files_box.offset().left + enter_files_box.width(); var box_offset_h = enter_files_box.offset().top + enter_files_box.height(); $(container).find('.file_tr').each(function(i,item){ var offset_top = $(item).offset().top; var offset_left = $(item).offset().left; var offset_h = $(item).offset().top + $(item).height(); var offset_w = $(item).offset().left + $(item).width(); if(bt.get_cookie('rank') == 'icon'){ // 为Icon模式时 if(offset_w >= box_offset_left && offset_left <= box_offset_w && offset_h >= box_offset_top && offset_top <= box_offset_h){ $(item).addClass('active'); }else{ $(item).removeClass('active') } }else{// 为List模式时 if (offset_w >= box_offset_left && offset_h >= box_offset_top && offset_top <= box_offset_h ) { $(item).addClass('active') }else{ $(item).removeClass('active') } } }); } // 鼠标抬起 bt_file.window_mouseup = function(ev) { var _move_array = [],enter_files_box = that.enter_files_box(); var box_offset_top = enter_files_box.offset().top; var box_offset_left = enter_files_box.offset().left; var box_offset_w = enter_files_box.offset().left + enter_files_box.width(); var box_offset_h = enter_files_box.offset().top + enter_files_box.height(); if(box_offset_top && box_offset_left && box_offset_w && box_offset_h){ $(container).find('.file_tr').each(function(i,item){ var offset_top = $(item).offset().top; var offset_left = $(item).offset().left; var offset_h = $(item).offset().top + $(item).height(); var offset_w = $(item).offset().left + $(item).width(); if(bt.get_cookie('rank') == 'icon'){ // 为Icon模式时 if(offset_w >= box_offset_left && offset_left <= box_offset_w && offset_h >= box_offset_top && offset_top <= box_offset_h){ _move_array.push($(item).data('index')) } }else{// 为List模式时 if (offset_w >= box_offset_left && offset_h >= box_offset_top && offset_top <= box_offset_h ) { _move_array.push($(item).data('index')) } } }); that.render_file_selected(_move_array); //渲染数据 } enter_files_box.remove(); //删除盒子 $('.file_list_content').unbind('mousewheel'); //解绑滚轮事件 $(document).unbind('mousemove',bt_file.window_mousemove); } $(document).one('mouseup',bt_file.window_mouseup); $(document).on('mousemove',bt_file.window_mousemove); ev.stopPropagation(); ev.preventDefault(); }) // 备注设置 $('.file_list_content').on('blur','.set_file_ps',function(ev){ var tr_index = $(this).parents('.file_tr').data('index'),item = that.file_list[tr_index],nval = $(this).val(),oval = $(this).data('value'),_this = this; if(nval == oval) return false; bt_tools.send('files/set_file_ps',{filename:item.path,ps_type:0,ps_body:nval},function(rdata){ $(_this).data('value',nval); },{tips:'Set ps',tips:true}); }); // 备注回车事件 $('.file_list_content').on('keyup','.set_file_ps',function(ev){ if(ev.keyCode == 13){ $(this).blur(); } ev.stopPropagation(); }); // 表头拉伸 $('.file_list_header').on('mousedown','.file_width_resize',function(ev){ return false; if(ev.which == 3) return false; var th = $(this),Minus_v = $(this).prev().offset().left,_header = $('.file_list_header').innerWidth(),maxlen = 0; maxlen = _header - $('.file_main_title').data $(document).unbind('mousemove').mousemove(function(ev){ var thatPos = ev.clientX - Minus_v; that.set_style_width(th.prev().data('tid'),thatPos); }) $(document).one('mouseup',th,function(ev){ $(document).unbind('mousemove'); }) ev.stopPropagation(); ev.preventDefault(); }) // 视图调整 $('.cut_view_model').on('click',function(){ var type = $(this).data('type'); $('.file_table_view').addClass(type == 'icon'?'icon_view':'list_view').removeClass(type != 'icon'?'icon_view':'list_view').scrollLeft(0); bt.set_cookie('rank',type); $(this).addClass('active').siblings().removeClass('active'); }); //老版快捷操作 $('.file_list_content').on('click','.set_operation_group a',function(ev){ var data = $(this).parents('.file_tr').data(),type = $(this).data('type'),item = that.file_list[data.index] if(type == 'more') return true; item.open = type; item.index = data.index; item.type_tips = item.type == 'file' ? 'File' : 'Directory'; that.file_groud_event(item); }); // 文件搜索 $('.replace_content').on('click', function () { that.replace_content_view() }) }, // 上传文件 file_drop: function () { var path = $('#fileInputPath').attr('data-path'); uploadFiles.init_upload_path(path); uploadFiles.upload_layer(); }, /** * @descripttion: 文件拖拽范围 * @author: Lifu * @return: 拖拽元素 */ enter_files_box: function () { if ($('#web_mouseDrag').length == 0) { $('
    ', { id: 'web_mouseDrag', style: [ 'position:absolute; top:0; left:0;', 'border:1px solid #072246; background-color: #cce8ff;', 'filter:Alpha(Opacity=15); opacity:0.15;', 'overflow:hidden;display:none;z-index:9;' ].join('')}).appendTo('.file_table_view'); } return $('#web_mouseDrag'); }, /** * @description 清除表格选中数据和样式 * @returns void */ clear_table_active:function(){ this.file_table_arry = []; $('.file_list_header .file_check').removeClass('active active_2'); $('.file_list_content .file_tr').removeClass('active app_menu_operation'); $('.file_list_content .file_tr .file_ps .foo_menu').removeClass('foo_menu_click'); $('.app_menu_group').remove(); }, /** * @description 计算表格中选中 * @returns void */ calculate_table_active:function(){ var that = this,header_check = $('.file_list_header .file_check'); //判断数量 if(this.file_table_arry.length == 0){ header_check.removeClass('active active_2').data('checkbox',0); }else if(this.file_table_arry.length == this.file_list.length){ header_check.addClass('active').removeClass('active_2').data('checkbox',1); }else{ header_check.addClass('active_2').removeClass('active').data('checkbox',2); } //数量大于0开启键盘事件 if(this.file_table_arry.length > 0){ $(document).unbind('keydown').on('keydown',function(e){ var keyCode = e.keyCode,tagName = e.target.localName.toLowerCase(),is_mac = window.navigator.userAgent.indexOf('Mac') > -1 if(tagName == 'input' || tagName == 'textarea' ) return true; // Ctrl + c 复制事件 if(e.ctrlKey && keyCode == 67){ if(that.file_table_arry.length == 1){ that.file_groud_event($.extend(that.file_table_arry[0],{open:'copy'})); $('.file_all_paste').removeClass('hide'); }else if(that.file_table_arry.length > 1){ that.batch_file_manage('copy') //批量 } } // Ctrl + x 剪切事件 if(e.ctrlKey && keyCode == 88){ if(that.file_table_arry.length == 1){ that.file_groud_event($.extend(that.file_table_arry[0],{open:'shear'})); $('.file_all_paste').removeClass('hide'); }else if(that.file_table_arry.length > 1){ that.batch_file_manage('shear') //批量 } } }) //数量超过一个显示批量操作 if(this.file_table_arry.length > 1){ $('.nav_group.multi').removeClass('hide'); $('.file_menu_tips').addClass('hide'); }else{ $('.nav_group.multi').addClass('hide'); $('.file_menu_tips').removeClass('hide'); } }else{ $('.nav_group.multi').addClass('hide'); $('.file_menu_tips.multi').removeClass('hide'); $(document).unbind('keydown'); } $('.selection_right_menu,.file_path_input .file_dir_item .nav_down_list').removeAttr('style'); // 删除右键样式、路径下拉样式 that.set_menu_line_view_resize(); }, /** * @description 设置文件路径视图自动调整 * @returns void */ set_dir_view_resize:function(){ var file_path_input = $('.file_path_input'),file_dir_view = $('.file_path_input .file_dir_view'),_path_width = file_dir_view.attr('data-width'),file_item_hide = null; if(_path_width){ parseInt(_path_width); }else{ _path_width = file_dir_view.width(); file_dir_view.attr('data-width',_path_width); } if(file_dir_view.width() - _path_width < 90){ var width = 0; $($('.file_path_input .file_dir_view .file_dir_item').toArray().reverse()).each(function(){ var item_width = 0; if(!$(this).attr('data-width')){ $(this).attr('data-width',$(this).width()); item_width = $(this).width(); }else{ item_width = parseInt($(this).attr('data-width')); } width += item_width; if((file_path_input.width() - width) <= 90){ $(this).addClass('hide'); }else{ $(this).removeClass('hide'); } }); } var file_item_hide = file_dir_view.children('.file_dir_item.hide').clone(true); if(file_dir_view.children('.file_dir_item.hide').length == 0){ file_path_input.removeClass('active').find('.file_dir_omit').addClass('hide'); }else{ file_item_hide.each(function(){ if($(this).find('.glyphicon-hdd').length == 0){ $(this).find('.file_dir').before(''); } }); file_path_input.addClass('active').find('.file_dir_omit').removeClass('hide'); file_path_input.find('.file_dir_omit .nav_down_list').empty().append(file_item_hide); file_path_input.find('.file_dir_omit .nav_down_list .file_dir_item').removeClass('hide'); } }, /** * @descripttion 设置菜单栏视图自动调整 * @return: 无返回值 */ set_menu_line_view_resize:function(){ //menu_width 菜单栏宽度、all_group所有按钮组宽度 var menu_width = $('.file_nav_view').width(),disk_list_width = 0,batch_list_width = 0,_width = 0,disk_list = $('.mount_disk_list'),batch_list = $('.nav_group.multi'); if(!disk_list.attr('data-width')) disk_list.attr('data-width',disk_list.innerWidth()); if(!batch_list.attr('data-width') && batch_list.innerWidth() != 0 && batch_list.innerWidth() != -1){ batch_list.attr('data-width',batch_list.innerWidth()) } disk_list_width = parseInt(disk_list.attr('data-width')); batch_list_width = parseInt(batch_list.attr('data-width')); $('.file_nav_view>.nav_group').not('.mount_disk_list').each(function(){ _width += $(this).innerWidth(); }); _width += $('.menu-header-foot').innerWidth(); if(menu_width - _width < (disk_list_width+5)){ $('.nav_group.mount_disk_list').addClass('thezoom').find('.disk_title_group_btn').removeClass('hide'); }else{ $('.nav_group.mount_disk_list,.nav_group.multi').removeClass('thezoom'); } if(this.area[0] < 1760){ indexs = Math.ceil(((1760 - this.area[0]) / 68)); $('.batch_group_list>.nav_btn_group').each(function(index){ if(index >= $('.batch_group_list>.nav_btn_group').length - (indexs+2)){ $(this).hide(); }else{ $(this).show(); } }); $('.batch_group_list>.nav_btn_group:last-child').removeClass('hide').show(); }else{ $('.batch_group_list>.nav_btn_group').css('display','inline-block'); $('.batch_group_list>.nav_btn_group:last-child').addClass('hide'); } }, /** * @description 设置文件前进或后退状态 * @returns void */ set_file_forward:function(){ var that = this,forward_path = $('.forward_path span'); if(that.file_operating.length == 1){ forward_path.addClass('active'); }else if(that.file_pointer == that.file_operating.length -1){ forward_path.eq(0).removeClass('active'); forward_path.eq(1).addClass('active'); }else if(that.file_pointer == 0){ forward_path.eq(0).addClass('active'); forward_path.eq(1).removeClass('active'); }else{ forward_path.removeClass('active'); } }, /** * @description 设置文件视图 * @returns void */ set_file_view:function(){ var file_list_content = $('.file_list_content'),height = this.area[1] - $('.file_table_view')[0].offsetTop - 170; $('.file_bodys').height(this.area[1] - 100); if((this.file_list.length * 50) > height){ file_list_content.attr('data-height',file_list_content.data('height') || file_list_content.height()).css({'overflow':'hidden','overflow-y':'auto','height':height+'px'}); $('.file_shadow_bottom').css('opacity',1); }else{ file_list_content.css({'overflow':'hidden','overflow-y':'auto','height':height+'px'}); $('.file_shadow_top,.file_shadow_bottom').css('opacity',0); } }, /** * @description 打开分享列表 * @returns void */ open_share_view:function(){ var that = this; layer.open({ type: 1, shift: 5, closeBtn: 2, area: ['850px','580px'], title: 'Share list', content: '
    \ \ \ \
    Share nameShare addressExpiration dateOpt
    \
    \
    ', success:function(){ that.render_share_list(); // 分享列表详情操作 $('.download_url_list').on('click','.info_down',function(){ var indexs = $(this).attr('data-index'); that.file_share_view(that.file_share_list[indexs],'list'); }); // 分页 $('.download_table .download_url_page').on('click','a',function(e){ var _href = $(this).attr('href').match(/p=([0-9]+)$/)[1] that.render_share_list({p:_href}); e.stopPropagation(); e.preventDefault(); }); } }) }, /** * @description 渲染分享列表 * @param {Number} page 分页 * @returns void */ render_share_list:function(param){ var that = this,_list = '' if(typeof param == 'undefined') param = {p:1} bt_tools.send('files/get_download_url_list',param,function(res){ that.file_share_list = res.data; if(res.data.length > 0){ $.each(res.data,function(index,item){ _list += '' +''+ item.ps +'' +''+ item.filename +'' +''+ bt.format_data(item.expire) +'' +'' +'Details | ' +'Close' +'' }) }else{ _list = 'No share data' } $('.download_url_list').html(_list); $('.download_url_page').html(res.page); // 删除操作 $('.download_table').on('click','.del_down',function(){ var id = $(this).attr('data-id'),_ps = $(this).attr('data-ps'); that.remove_download_url({id:id,fileName:_ps},function(res){ if(res.status) that.render_share_list(param) layer.msg(res.msg,{icon:res.status?1:2}) }); }); },'Share list'); }, /** * @description 删除选中数据 * @param {Array} arry * @param {*} value * @return void */ remove_check_file:function(arry,key,value){ var len = arry.length; while(len--){ if(arry[len][key] == value) arry.splice(len,1) } }, /** * @description 打开文件下载视图 * @return void */ open_download_view:function(){ var that = this; that.reader_form_line({ url:'DownloadFile', beforeSend:function(data){ return {url:data.url,path:data.path,filename:data.filename}; }, overall:{width:'310px'}, data:[ {label:'URL address:', name:'url', placeholder:'URL address', value:'http://',eventType:['input','focus'],input:function(){ var value = $(this).val(),url_list = value.split('/'); $('[name="filename"]').val(url_list[url_list.length-1]); }}, {label:'Download to:', name:'path', placeholder:'Download to', value:that.file_path}, {label:'File name:', name:'filename', placeholder:'Save file name', value:'',eventType:'enter',enter:function(){ $('.download_file_view .layui-layer-btn0').click(); }} ] },function(form,html){ var loadT = bt.open({ type:1, title:'Download file', area: '500px', shadeClose: false, skin:'download_file_view', content:html[0].outerHTML, btn:['Confirm','Close'], success:function(){ form.setEvent(); }, yes:function(indexo,layero){ var ress = form.getVal(); if(!bt.check_url(ress.url)){ layer.msg('Please enter valid URL address..',{icon:2}) return false; } form.submitForm(function(res){ that.render_present_task_list(); layer.msg(res.msg,{icon:res.status?1:2}) loadT.close(); }); } }); }); }, /** * @description 设置样式文件 * @param {String} type 表头类型 * @param {Number} width 宽度 * @return void */ set_style_width: function (type, width) { var _content = bt.get_cookie('formHeader') || $('#file_list_info').html(),_html = '',_reg = new RegExp("\\.file_" + type + "\\s?\\{width\\s?\\:\\s?(\\w+)\\s\\!important;\\}","g"),_defined_config = {name:150,type:80,size:80,mtime:150,accept:80,user:80,ps:150}; _html = _content.replace(_reg, function (match, $1, $2, $3) { return '.file_' + type + '{width:' + ( width < 80?_defined_config[type]+'px':width+'px') +' !important;}' }); $('#file_list_info').html(_html); }, /** * @description 设置文件表格 * @return void */ set_file_table_width:function(){ var that = this,file_header_width = $('.file_table_view')[0].offsetWidth,auto_num = 0,width = 0,auto_all_width = 0,css = '',_width = 0,tr_heigth = 45,other = '',config ={}; $.each(this.file_header,function(key,item){ if(item == 'auto'){ auto_num ++; config[key] = 0; }else{ width += item; css += '.'+key+'{width:'+ (key != 'file_operation'?item:item - 16) +'px !important;}'; } }); if(this.is_mobile) $('.file_operation.file_th').attr('style','margin-right:-10px !important;'); if((this.file_list.length * tr_heigth) > $('.file_list_content').height()){ config['file_tr'] = file_header_width - (this.is_mobile?0:this.scroll_width); file_header_width = file_header_width; other += '.file_td.file_operation{width:'+ (this.file_header['file_operation'] - (this.is_mobile?0:this.scroll_width) - 10) +'px !important;}'; other += '.file_th.file_operation{padding-right:'+ (10 + (this.is_mobile?0:this.scroll_width)) +'px !important}'; }else{ file_header_width = file_header_width; config['file_tr'] = file_header_width; if(this.is_mobile) other += '.file_td.file_operation{width:' + (this.file_header['file_operation'] -20) +'px !important;}'; } config['file_list_header'] = file_header_width; auto_all_width = file_header_width - width; _width = auto_all_width / auto_num; $.each(config,function(key,item){ css += '.'+ key +'{width:'+ (item == 0?_width:item) +'px !important;}'; }); $('#file_list_info').html(css + other); }, /** * @description 渲染路径列表 * @param {Function} callback 回调函数 * @return void */ render_path_list: function (callback){ var that = this,html = '
    ', path_before = '',dir_list = this.file_path.split("/").splice(1),first_dir = this.file_path.split("/")[0]; if(bt.os === 'Windows'){ if(dir_list.length == 0) dir_list = []; dir_list.unshift('Local disk ('+ first_dir +')'); }else{ if(this.file_path == '/') dir_list = []; dir_list.unshift('Root dir'); } for(var i = 0; i < dir_list.length; i++){ path_before += '/' + dir_list[i]; if (i == 0) path_before = '/'; html += '
    \ ' + dir_list[i] + '\ \ \
    '; } $('.path_input').val('').attr('data-path',this.file_path); var file_dir_view = $('.file_path_input .file_dir_view'); file_dir_view.html(html); file_dir_view.attr('data-width',file_dir_view.width()); that.set_dir_view_resize.delay(that,100); }, /** * @description 渲染路径下拉列表 * @param {Object} el Dom选择器 * @param {String} path 路径 * @param {Function} callback 回调函数 */ render_path_down_list: function (el, path, callback) { var that = this,_html = '',next_path = $(el).parent().next().find('.file_dir').attr('title'); this.get_dir_list({ path: path }, function (res) { $.each(that.data_reconstruction(res.DIR),function(index,item){ var _path = (path != '/' ? path : '') + '/' + item.filename; _html += '
  • ' + item.filename + '
  • '; }); $(el).html(_html); }); }, /** * @description 渲染文件列表 * @param {Object} data 参数对象,例如分页、显示数量、排序,不传参数使用默认或继承参数 * @param {Function} callback 回调函数 * @return void */ reader_file_list:function (data, callback){ var that = this,select_page_num = '',next_path = '',model = bt.get_cookie('rank'),isPaste = bt.get_cookie('record_paste_type'); if(isPaste != 'null' && isPaste != undefined){//判断是否显示粘贴 $('.file_nav_view .file_all_paste').removeClass('hide'); }else{ $('.file_nav_view .file_all_paste').addClass('hide'); } $('.file_table_view').removeClass('.list_view,.icon_view').addClass(model == 'list'?'list_view':'icon_view'); $('.cut_view_model:nth-child('+(model == 'list'?'2':'1')+')').addClass('active').siblings().removeClass('active'); this.file_images_list = []; this.get_dir_list(data,function(res){ if(res.status === false && res.msg.indexOf('The specified directory does not exist!') > -1){ return that.reader_file_list({path:'/www'}) } that.file_path = that.path_check(res.PATH); that.file_list = $.merge(that.data_reconstruction(res.DIR,'DIR'),that.data_reconstruction(res.FILES)); that.is_recycle = res.FILE_RECYCLE; that.file_store_list = res.STORE; bt.set_cookie('Path',that.path_check(res.PATH)); that.reader_file_list_content(that.file_list,function(rdata){ $('.path_input').attr('data-path',that.file_path); $('.file_nav_view .multi').addClass('hide'); $('.selection_right_menu').removeAttr('style'); $.each(['100','200','500','1000','2000'],function(index,item){ select_page_num += ''; }); var page = $(res.PAGE); page.append('per pageitem(s)'); $('.filePage').html('
    Total '+ rdata.is_dir_num +' directory, '+ (that.file_list.length - rdata.is_dir_num) +'file(s), size:Click to calculate
    ' + page[0].outerHTML); if(data && data.is_operating && that.file_operating[that.file_pointer] != res.PATH){ next_path = that.file_operating[that.file_pointer + 1]; if(typeof next_path != "undefined" && next_path != res.PATH) that.file_operating.splice(that.file_pointer+1); that.file_operating.push(res.PATH); that.file_pointer = that.file_operating.length - 1; } that.render_path_list(); // 渲染文件路径地址 that.set_file_forward(); // 设置前进后退状态 that.render_favorites_list(); //渲染收藏夹列表 that.set_file_view(); // 设置文件视图 that.set_file_table_width() //设置表格头部宽度 if(callback) callback(res); }); }); }, /** * @descripttion 重组数据结构 * @param {Number} data 数据 * @param {String} type 类型 * @return: 返回重组后的数据 */ data_reconstruction:function(data,type,callback){ var that = this,arry = [],info_ps = [ ['/etc','PS: System files directory'], ['/home','PS: Home directory'], ['/tmp','PS: Common temporary files directory'], ['/root','PS: Main directory of system admin'], ['/usr','PS: System application directory'], ['/boot','PS: System run directory'], ['/lib','PS: System source file directory'], ['/mnt','PS: Store temporary mapped file system'], ['/www','PS: Aapanel program directory'], ['/bin','PS: Store binary executable file directory'], ['/dev','PS: Storage device file directory'], ['/www/wwwlogs','PS: Default site logs directory'], ['/www/server','PS: Aapanel soft installed directory'], ['/www/wwwlogs','PS: Site logs directory'], ['/www/Recycle_bin',lan.files.recycle_bin_dir], ['/www/server/panel','PS: Aapanel main program directory, do not move'], ['/www/server/panel/plugin','PS: Aapanel plugin directory'], ['/www/server/panel/BTPanel','PS: Aapanel directory'], ['/www/server/panel/BTPanel/static','PS: Aapanel static directory'], ['/www/server/panel/BTPanel/templates','PS: Aapanel templates directory'], [bt.get_cookie('backup_path'),'PS: Default backup directory'], [bt.get_cookie('sites_path'),'PS: Default site directory'] ]; if(data.length < 1) return []; $.each(data,function(index,item){ var itemD = item.split(";"),fileMsg ='',fileN = itemD[0].split('.'),extName = fileN[fileN.length - 1]; switch(itemD[0]) { case '.user.ini': fileMsg = lan.files.php_profile; break; case '.htaccess': fileMsg = lan.files.apache_profile; break; case 'swap': fileMsg = lan.files.swap_file; break; } if(itemD[0].indexOf('Recycle_bin') != -1) fileMsg = lan.files.swap_file; if(itemD[0].indexOf('.upload.tmp') != -1) fileMsg = lan.files.recycle_bin_dir; for(var i=0;i 0){ $.each(this.file_store_list,function(index,item){ html += '
  • ' +'' +''+item['name']+'' +'
  • ' }) html+='
  • Management
  • ' }else{html = '
  • (Empty)
  • '} $('.favorites_file_path .nav_down_list').html(html) }, /** * @descripttion 收藏夹目录视图 * @return: 无返回值 */ set_favorites_manage:function(){ var that = this; layer.open({ type:1, title: "Manage Favorites", area: ['850px','580px'], closeBtn: 2, shift: 5, shadeClose: false, content: "
    \
    \ \ \ \
    PathOpt
    ", success: function(layers) { that.render_favorites_type_list(); setTimeout(function(){                 $(layers).css('top',($(window).height() - $(layers).height()) /2);             },50) }, cancel:function(){ that.reader_file_list({path:that.file_path}) } }) }, /** * @description 渲染收藏夹分类列表 * @return void */ render_favorites_type_list:function(){ var _detail = ''; this.$http('get_files_store',function(rdata){ if(rdata.length > 0){ $.each(rdata,function(ind,item){ _detail += '' +''+item['path']+'' +'' +'Del' +'' +'' }) }else{ _detail = 'No favorites' } $('.favorites_body').html(_detail); if(jQuery.prototype.fixedThead){ $('.stroe_tab_list .divtable').fixedThead({resize:false}); }else{ $('.stroe_tab_list .divtable').css({'overflow':'auto'}); } }) }, /** * @description 重新获取收藏夹列表 * @return void */ load_favorites_index_list:function(){ var that = this; this.$http('get_files_store',function(rdata){ that.file_store_list = rdata; that.render_favorites_list() }) }, /** * @description 删除收藏夹 * @param {String} path 文件路径 * @return void */ del_favorites:function(path){ var that = this layer.confirm('Confirm delete path【'+path+'】?', { title: 'Delete favorites', closeBtn: 2, icon: 3 }, function (index) { that.$http('del_files_store',{path:path},function(res){ if(res.status){ that.render_favorites_type_list(); } layer.msg(res.msg,{icon:res.status?1:2}) }) }) }, /** * @description 渲染文件列表内容 * @param {Object} data 文件列表数据 * @param {Function} callback 回调函数 * @return void */ reader_file_list_content:function(data,callback){ var _html = '',that = this,is_dir_num = 0,images_num = 0; $.each(data,function(index,item){ var _title = item.filename,only_id = bt.get_random(10),path = (that.file_path +'/'+ item.filename).replace('//','/'),is_compress = that.determine_file_type(item.ext,'compress'),is_editor_tips = (function(){ var _openTitle = 'open'; switch(that.determine_file_type(item.ext)){ case 'images': _openTitle = 'Preview'; break; case 'video': _openTitle = 'Play'; break; default: if(that.determine_file_type(item.ext) == 'compress'){ _openTitle = ''; }else{ _openTitle = 'Edit'; } break; } item.type == 'dir'?_openTitle = 'Open':''; return _openTitle; }(item)); that.file_list[index]['only_id'] = only_id; _html += '
    '+ '
    '+ '
    '+ '
    '+ ''+ item.filename+item.soft_link +''+ (item.caret?'':'') + (item.down_id != 0?'':'') + '
    '+ '
    '+ (item.type == 'dir'?'directory':that.ext_type_tips(item.ext)) +'
    '+ '
    ' + item.user +' / '+item.root_level + '
    '+ '
    '+ (item.type == 'dir'?'Calculate':bt.format_size(item.size)) +'
    '+ '
    ' + bt.format_data(item.mtime) + '
    '+ '
    ' + (item.is_os_ps?item.ps:'') + '
    '+ '
    '+ ''+ is_editor_tips +' | '+ 'Copy | '+ 'Cut | '+ 'Rename | '+ 'PMSN | '+ ''+ (is_compress?'Unzip':'Zip') +' | '+ 'Del | '+ 'More'+ '
    '+ '
    '; if(item.type == 'dir') is_dir_num ++; item.path = path; // 文件路径; item.open_type = that.determine_file_type(item.ext); // 打开类型; if(item.open_type == 'images'){ item.images_id = images_num; that.file_images_list.push(item.path); images_num ++; } }); $('.file_list_content').html(_html); if(callback) callback({is_dir_num:is_dir_num}) that.clear_table_active(); // 清除表格选中内容 }, /** * @description 渲染文件磁盘列表 * @return void */ render_file_disk_list:function(){ var that = this,html = '',_li = ''; that.get_disk_list(function(res){ $.each(res,function(index,item){ html += ''; _li += '
  • '+(item.path == '/'?'Root dir':item.path)+' ('+ item.size[2] +')
  • ' }); $('.mount_disk_list').html('
    '+lan.files.mounted_disk+'
    '+html+'
    '); that.set_menu_line_view_resize(); }); }, /** * @description 渲染右键鼠标菜单 * @param {Object} ev 事件event对象 * @param {Object} el 事件对象DOM * @return void */ render_file_groud_menu: function(ev, el) { var that = this, index = $(el).data('index'), _openTitle = 'Open', data = that.file_list[index], compression = ['zip', 'rar', 'gz', 'war', 'tgz', 'bz2'], offsetNum = 0, config = { open:_openTitle, split_0:true, download:'Download', share:'Share file', cancel_share:'Cancel share', favorites:'Favorites file', cancel_favorites:'Cancel favorites', split_1:true, // dir_kill:'目录查杀', authority:'Permission', split_2:true, copy:'Copy', shear:'Cut', rename:'Rename', del:'Delete', split_3:true, compress:'Compress', unzip:'Unzip', open_find_dir:'Open file location', split_4:true, property:'Properties' }; // 文件类型判断 switch (that.determine_file_type(data.ext)) { case 'images': _openTitle = 'Preview'; break; case 'video': _openTitle = 'Play'; break; default: _openTitle = 'Edit'; break; } config['open'] = (data.type == 'dir' ? 'Open' : _openTitle); if(data.type === 'dir') delete config['download']; // 判断是否文件或文件夹,禁用下载 if(data.open_type == 'compress') delete config['open']; // 判断是否压缩文件,禁用操作 if(data.down_id != 0){ delete config['share']; //已分享 }else{ delete config['cancel_share']; //未分享 config['share'] = (data.type == 'dir' ? 'Share dir' : 'Share file'); } if (data.caret !== false) { delete config['favorites']; // 已分享 }else{ delete config['cancel_favorites']; // 未分享 config['favorites'] = (data.type == 'dir' ? 'Favorites dir' : 'Favorites file'); } // if (data.ext == 'php') config['dir_kill'] = '文件查杀'; if (data.ext == 'php') delete config['dir_kill']; if (data.ext != 'php' && data.type != 'dir') delete config['dir_kill']; var num = 0; $.each(compression, function(index, item) { // 判断压缩文件 if (item == data.ext) num++; }); if(num == 0) delete config['unzip']; if(!data.is_search){ delete config['open_find_dir']; // 判断是否为搜索文件,提供打开目录操作 }else{ config['open_find_dir'] = (data.type == 'dir' ? 'Open dir' : 'Open file location'); } that.file_selection_operating = config; that.reader_menu_list({ el: $('.selection_right_menu'), ev: ev, data: data, list: config }); }, /** * @description 渲染右键全局菜单 * @param {Object} ev 事件event对象 * @param {Object} el 事件对象DOM * @return void */ render_file_all_menu: function(ev, el) { var that = this, config = { refresh:'Refresh', split_0:true, upload:'Upload', create:['New file/folder',{ create_dir:'New folder', create_files:'New file', soft_link:'Softlink' }], web_shell:'Terminal', split_1:true, paste:'Paste' }, offsetNum = 0, isPaste = bt.get_cookie('record_paste_type'); if (isPaste == 'null' || isPaste == undefined) { delete config['split_1'] delete config['paste'] } that.reader_menu_list({ el: $('.selection_right_menu'), ev: ev, data: {}, list: config }); }, /** * @descripttion 文件多选时菜单 * @param {Object} ev 事件event对象 * @return: 无返回值 */ render_files_multi_menu:function(ev){ var that = this,config_group =[['copy','Copy'],['shear','cut'],['authority','Permission'],['compress','Compress'],['del','Delete']],el = $('.selection_right_menu').find('ul'),el_height = el.height(),el_width = el.width(),left = ev.clientX - ((this.area[0] - ev.clientX) < el_width?el_width:0); el.empty(); $.each(config_group,function(index,mitem){ var $children = null; if(mitem[0] == 'split'){ el.append('
  • '); }else{ el.append($('
  • '+ mitem[1] +'
  • ').append($children).on('click',{type:mitem[0],data:that.file_table_arry},function(ev){ $('.selection_right_menu').removeAttr('style'); that.batch_file_manage(ev.data.type); ev.stopPropagation(); ev.preventDefault(); })); } }); $('.selection_right_menu').css({ left: left, top: ev.clientY - ((this.area[1] - ev.clientY) < el_height?el_height:0) }).removeClass('left_menu right_menu').addClass(this.area[0] - (left + el_width) < 230?'left_menu':'right_menu'); $(document).one('click',function(e){ $(ev.currentTarget).removeClass('selected'); $('.selection_right_menu').removeAttr('style'); e.stopPropagation(); e.preventDefault(); }); }, /** * @description 渲染菜单列表 * @param {Object} el 菜单DOM * @param {Object} config 菜单配置列表和数据 * @returns void */ reader_menu_list: function(config) { var that = this, el = config.el.find('ul'), el_height = 0, el_width = el.width(), left = config.ev.clientX - ((this.area[0] - config.ev.clientX) < el_width ? el_width : 0), top = 0; el.empty(); $.each(config.list, function(key, item){ var $children = null, $children_list = null; if (typeof item == "boolean") { el.append('
  • '); } else { if (Array.isArray(item)) { $children = $('
    '); $children_list = $children.find('.set_group'); $.each(item[1], function(keys, items) { $children_list.append($('
  • ' + items + '
  • ').on('click', { type: keys, data: config.data }, function(ev) { that.file_groud_event($.extend(ev.data.data, { open: ev.data.type, index: parseInt($(config.ev.currentTarget).data('index')), element: config.ev.currentTarget, type_tips: config.data.type == 'dir' ? 'folder' : 'file' })); config.el.removeAttr('style'); ev.stopPropagation(); ev.preventDefault(); })) }); } el.append($('
  • ' + (Array.isArray(item)?item[0]:item) + '
  • ').append($children).on('click', { type: key, data: config.data }, function(ev) { that.file_groud_event($.extend(ev.data.data, { open: ev.data.type, index: parseInt($(config.ev.currentTarget).data('index')), element: config.ev.currentTarget, type_tips: config.data.type == 'dir' ? 'folder' : 'file' })); // 有子级拉下时不删除样式,其余删除 if (key != 'compress' && key != 'create') { config.el.removeAttr('style'); } ev.stopPropagation(); ev.preventDefault(); })); } }); el_height = el.innerHeight(); top = config.ev.clientY - ((this.area[1] - config.ev.clientY) < el_height ? el_height : 0); var element = $(config.ev.target); if (element.hasClass('foo_menu_title') || element.parents().hasClass('foo_menu_title')) { left = config.ev.clientX - el_width; top = ((this.area[1] - config.ev.clientY) < el_height) ? (config.ev.clientY - el_height - 20) : (config.ev.clientY + 15); } config.el.css({ left: (left + 10), top: top }).removeClass('left_menu right_menu').addClass(this.area[0] - (left + el_width) < 230 ? 'left_menu' : 'right_menu'); }, /** * @description 返回后缀类型说明 * @param {String} ext 后缀类型 * @return {String} 文件类型 */ ext_type_tips:function(ext){ var config = {ai:"Adobe Illustrator format",apk:"Android package",asp:"Dynamic web file",bat:"Shell File",bin:"Bin File",bas:"BASIC File",bak:"Backup File",css:'CSS',cad:"备份文件",cxx:"C++",crt:"Certificate file",cpp:"C++ File",conf:"Configuration file",dat:"",der:"Certification file",doc:"Microsoft Office Word 97-2003",docx:"Microsoft Office Word 2007",exe:"",gif:"Graphic file",go:"Golang source files",htm:"Hypertext document",html:"Hypertext document",ico:"",java:"Java source files",access:'Database file',jsp:"HTML Page",jpe:"Graphic file",jpeg:"Graphic file",jpg:"Graphic file",log:"Log file",link:"Shortcut file",js:"Javascript source files",mdb:"Microsoft Access database",mp3:"Audio file",ape:'CloudMusic.ape',mp4:"Video",avi:'Video',mkv:'Video',rm:'Video',mov:'Video',mpeg:'Video',mpg:'Video',rmvb:'Video',webm:'Video',wma:'Video',wmv:'Video',swf:'Shockwave Flash Object',mng:"Multi-image network graphics",msi:"Windows package",png:"Graphic file",py:"Python source file",pyc:"Python Bytecode file",pdf:"pdf",ppt:"Microsoft Powerpoint 97-2003",pptx:"Microsoft Powerpoint2007",psd:"Adobe photoshop",pl:"Perl Scripting language",rar:"RAR compressed package",reg:"Registry file",sys:"System Files",sql:"Database file",sh:"Shell script file",txt:"text format",vb:"Visual Basic",xml:"",xls:"Microsoft Office Excel 97-2003",xlsx:"Microsoft Office Excel 2007",gz:"Compressed file",zip:"ZIP compressed file",z:"","7z":"7Z Compressed file",json:'JSON',php:'PHP',mht:'MHTML',bmp:'BMP',webp:'WEBP',cdr:'CDR'}; return typeof config[ext] != "undefined"?config[ext]:('Unknown file'); }, /** * @description 文件类型判断,或返回格式类型(不传入type) * @param {String} ext * @param {String} type * @return {Boolean|Object} 返回类型或类型是否支持 */ determine_file_type:function(ext,type){ var config = { images:['jpg','jpeg','png','bmp','gif','tiff','ico','JPG','webp'], compress:['zip','rar','gz','war','tgz'], video:['mp4','mp3', 'mpeg', 'mpg', 'mov', 'avi', 'webm', 'mkv','mkv','mp3','rmvb','wma','wmv'], ont_text:['iso','xlsx','xls','doc','docx','tiff','exe','so','7z','bz','dmg','apk','pptx','ppt','xlsb','pdf'] },returnVal = false; if(type != undefined){ if(type == 'text'){ $.each(config,function(key,item){ $.each(item,function(index,items){ if(items == ext){ returnVal = true; return false; } }) }); returnVal = !returnVal }else{ if(typeof config[type] == "undefined") return false; $.each(config[type],function(key,item){ if(item == ext){ returnVal = true; return false; } }); } }else{ $.each(config,function(key,item){ $.each(item,function(index,items){ if(items == ext){ returnVal = key; return false; } }) }); if(typeof returnVal == "boolean") returnVal = 'text'; } return returnVal; }, /** * @description 右键菜单事件组 * @param {Object} data 当前文件或文件夹右键点击的数据和数组下标,以及Dom元素 * @return void */ file_groud_event:function(data){ var that = this; switch(data.open){ case 'open': // 打开目录、文件编辑、预览图片、播放视频 if(data.type == 'dir'){ this.reader_file_list({path:data.path}); }else{ switch(data.open_type){ case 'text': openEditorView(0,data.path) break; case 'video': this.open_video_play(data); break; case 'images': this.open_images_preview(data); break; } } break; case 'download': //下载 this.down_file_req(data); break; case 'share': // 添加分享文件 this.set_file_share(data); break; case 'cancel_share': // 取消分享文件 this.info_file_share(data); break; case 'favorites': //添加收藏夹 this.$http('add_files_store',{path:data.path},function(res){ if(res.status){ that.file_list[data.index] = $.extend(that.file_list[data.index],{caret:true}); that.reader_file_list_content(that.file_list); that.load_favorites_index_list(); } layer.msg(res.msg,{icon:res.status?1:2}) }) break; case 'cancel_favorites': //取消收藏 this.cancel_file_favorites(data); break; case 'authority': // 权限 this.set_file_authority(data); break; case 'dir_kill': //目录查杀 this.set_dir_kill(data); break; case 'copy': // 复制内容 this.copy_file_or_dir(data); break; case 'shear': // 剪切内容 this.cut_file_or_dir(data); break; case 'rename': // 重命名 this.rename_file_or_dir(data); break; case'compress': data['open'] = 'tar_gz'; this.compress_file_or_dir(data); break; case 'tar_gz': // 压缩gzip文件 case 'rar': // 压缩rar文件 case 'zip': // 压缩zip文件 this.compress_file_or_dir(data); break; case 'unzip': case 'folad': //解压到... this.unpack_file_to_path(data) break; case 'refresh': // 刷新文件列表 $('.file_path_refresh').click(); break; case 'upload': //上传文件 var path = $('#fileInputPath').attr('data-path'); uploadFiles.init_upload_path(path); uploadFiles.upload_layer(); break; case 'soft_link': //软链接创建 this.set_soft_link(); break; case 'create_dir': // 新建文件目录 $('.file_nav_view .create_file_or_dir li').eq(0).click(); break; case 'create_files': // 新建文件列表 $('.file_nav_view .create_file_or_dir li').eq(1).click(); break; case 'del': //删除 this.del_file_or_dir(data); break; case 'paste': //粘贴 this.paste_file_or_dir(); break; case 'web_shell': // 终端 web_shell() break; case 'open_find_dir': // 打开文件所在目录 this.reader_file_list({path: this.retrun_prev_path(data.path)}); break; case 'property': this.open_property_view(data) break; } }, /** * @descripttion 列表批量处理 * @param {String} stype 操作 * @return: 无返回值 */ batch_file_manage:function(stype){ var that = this, _api = '', _fname = [], _obj = {}, _path = $('') types = []; $.each(this.file_table_arry,function(index,item){ if (item.type && types.indexOf(item.type) == -1) { types.push(item.type); } _fname.push(item.filename); }) switch(stype){ case 'copy': //复制 case 'shear': //剪切 _api = 'SetBatchData'; _obj['data'] = JSON.stringify(_fname); _obj['type'] = stype == 'copy'?'1':'2'; _obj['path'] = that.file_path; break; case 'del': //删除 _obj['data'] = JSON.stringify(_fname); _obj['type'] = '4'; _obj['path'] = that.file_path; return that.batch_file_delect(_obj) break; case 'authority': //权限 _obj['filename'] = '批量'; _obj['type'] = '3' _obj['filelist'] = JSON.stringify(_fname); _obj['path'] = that.file_path; return that.set_file_authority(_obj,true) break; case 'compress': //压缩 var arry_f = that.file_path.split('/'),file_title = arry_f[arry_f.length -1]; _obj['filename'] = _fname.join(','); _obj['open'] = 'tar_gz' _obj['path'] = that.file_path+'/'+file_title; if (types.length > 1) { _obj['type_tips'] = 'folder and file'; } else if (types[0] == 'dir') { _obj['type_tips'] = 'folder'; } else if (types[0] == 'file') { _obj['type_tips'] = 'file'; } else { _obj['type_tips'] = ''; } return that.compress_file_or_dir(_obj,true) } // 批量标记 that.$http(_api,_obj,function(res){ if(res.status){ bt.set_cookie('record_paste_type',stype == 'copy'?'1':'2') that.clear_table_active(); $('.nav_group.multi').addClass('hide'); $('.file_menu_tips').removeClass('hide'); $('.file_nav_view .file_all_paste').removeClass('hide'); } layer.msg(res.msg,{icon:res.status?1:2}) }); }, /** * @descripttion 批量删除 * @param {Object} obj.data 需删除的数据 * @param {Object} obj.type 批量删除操作 * @return: 无返回值 */ batch_file_delect:function(obj){ var that = this; if(this.is_recycle){ layer.confirm(lan.files.del_to_recycle_bin,{title:lan.files.del_in_bulk,closeBtn:2,icon:3},function(){ that.$http('SetBatchData',obj,function(res){ if(res.status) that.reader_file_list({path:that.file_path}) layer.msg(res.msg,{icon:res.status?1:2}) }); }) }else{ bt.show_confirm(lan.files.del_in_bulk,''+lan.files.recycle_bin_warning+'',function(){ that.$http('SetBatchData',obj,function(res){ if(res.status) that.reader_file_list({path:that.file_path}) layer.msg(res.msg,{icon:res.status?1:2}) }); }) } }, /** * @description 批量文件粘贴 * @return void */ batch_file_paste:function(){ var that = this, _pCookie = bt.get_cookie('record_paste_type'); this.check_exists_files_req({dfile:this.file_path},function(result){ if(result.length > 0){ var tbody = ''; for(var i=0;i'+ToSize(result[i].size)+''+getLocalTime(result[i].mtime)+''; } var mbody = '
    \ '+tbody+'\
    File nameSizeLast edit time
    '; SafeMessage('The following files will be overwritten',mbody,function(){ that.$http('BatchPaste',{type:_pCookie,path:that.file_path},function(rdata){ if(rdata.status){ bt.set_cookie('record_paste_type',null); that.reader_file_list({path:that.file_path}) } layer.msg(rdata.msg,{icon:rdata.status?1:2}) }) }); }else{ that.$http('BatchPaste',{type:_pCookie,path:that.file_path},function(rdata){ if(rdata.status){ bt.set_cookie('record_paste_type',null); that.reader_file_list({path:that.file_path}) } layer.msg(rdata.msg,{icon:rdata.status?1:2}) }) } }) }, /** * @description 文件内容搜索替换 * @return void */ replace_content_view: function() { layer.open({ title: 'Search Files Content', type: 1, skin: 'replace_content_view', area: '710px', zIndex:19900, closeBtn: 2, content: '
    ' + '
    ' + 'Search' + '
    ' + '' + ''+ '' + '
      '+ '
      ' + '
      ' + '
      ' + 'Suffix' + '
      ' + '' + '
      ' + '
      ' + '
      ' + 'Folder' + '
      ' + '' + '
      ' + ''+ 'Subdir' + '
      ' + '
      ' + '
      ' + '
      ' + 'Mode' + '
      ' + '
      ' + '
      ' + ''+ 'Words' + '
      ' + '
      ' + ''+ 'Regex' + '
      ' + '
      ' + '
      ' + '
      ' + ''+ 'Match whole word' + '
      ' + '
      ' + ''+ 'Match case' + '
      ' + '
      ' + '
      ' + '
      ' + '
      '+ '
      '+ '
      '+ '
      '+ '
      Type search content to search in the file
      Options to narrow down the search
      '+ '
      '+ '' + '
      ', success:function(){ //单选、复选框按钮事件 $('.checkbox_config,.file_path_switch').click(function(e){ if(e.target.localName == 'i' || e.target.localName == 'span'){ var is_radio = $(this).find('i').hasClass('file_find_radio'),i_box = $(this).find('i'); if(is_radio){//是否单选 i_box.addClass('active').parent('div').siblings().find('i').removeClass('active'); if($(this).find('.laberText').text() == 'Words'){ $('.hide_option').removeClass('hide') }else{ //正则模式下取消全词匹配 $('.hide_option').addClass('hide').find('i').removeClass('active') } }else{//是否复选 if(i_box.hasClass('active')){ i_box.removeClass('active') }else{ i_box.addClass('active') } } } }) // 历史输入 $('.history_search').click(function(e){ var list = JSON.parse(bt.get_cookie('file_search_list')),h_html = ''; if($.type(list) === 'undefined' || list == null){ h_html = 'No records'; $('.history_search_list').html(h_html).removeClass('hide'); }else{ $('.history_search_list').empty(); $.each(list,function(index,item){ $('.history_search_list').append($('
    • ').attr('data-key',item).text(item)).removeClass('hide') }) } $(document).one('click', function() { $('.history_search_list').addClass('hide'); e.stopPropagation(); }); e.stopPropagation(); }) //选择历史输入 $('.history_search_list').on('click','li',function(){ $('#replaceContentValue').val($(this).data('key')); $('.history_search_list').addClass('hide'); }) } }) }, /** * @description 文件内容搜索結果 * @returns void */ searchReplaceContent: function() { var that = this, file_num = 0, //文件数量 match_num = 0, //文件内查询到的数量 match_file_html = '', data = { text: $('#replaceContentValue').val(), exts: $("#replaceFileExtsType").val() || 'html,php', path: $('#replaceContentPath').val(), //路径 is_subdir: !$('.replaceHasChild').find('i').hasClass('active') ? '0' : '1', //0不包含子目录 1 包含子目录 mode: !$('.regularMatchRe').find('i').hasClass('active') ? '0' : '1', //为普通模式 1 为正则模式 isword: !$('.allMatchRe').find('i').hasClass('active') ? '0' : '1', //全词匹配 0 默认 iscase: !$('.distinguishCaseRe').find('i').hasClass('active') ? '1' : '0', //不区分大小写 0 默认 noword: '0' //不输出行信息 0 默认 } this.$http('files_search',data,function(res) { var reg = new RegExp("("+that.escodeChange(data.text)+")"); if(res.error) return layer.msg(res.error, {icon: 2}); if (data.text.indexOf('\n') < 0 && data.text != '') that.setSearchHistoryList(data.text); //设置搜索历史列表 if($.isEmptyObject(res)){ $('.replace_content_view .matchContent_main').html('
      No data found
      ') $('.matchRresult').html('') return } $.each(res,function(fileName,item){ file_num++; var contentNum = Object.keys(item).length match_file_html+='
      '+ '
      '+ ''+fileName+'  (Match '+contentNum+' times)'+ 'Edit'+ '
      '+ '
      ' $.each(item,function(index,lineItem){ match_num++ var html = $('
      ').text(lineItem.trim()).html().replace(reg,''+ $('
      ').text(data.text).html() +'
      ') match_file_html += '
      line '+index+':    '+html+'
      '; }) match_file_html+= '
      ' }) $('.matchRresult').html('Search results: '+ match_num +' matches in '+ file_num +' files') $('.matchContent_main').html(match_file_html); // 隐藏显示内容 $('.matchContent_main .match_result_file_title').click(function(e){ var parent_box = $(this).parents('.match_content_item'), is_icon_top = $(this).find('i').hasClass('glyphicon-triangle-top') //是否图标向上(未打开) if(is_icon_top){ parent_box.find('.match_result_file_content').addClass('matchShow') $(this).find('i').removeClass('glyphicon-triangle-top').addClass('glyphicon-triangle-bottom') }else{ $(this).find('i').removeClass('glyphicon-triangle-bottom').addClass('glyphicon-triangle-top') parent_box.find('.match_result_file_content').removeClass('matchShow') } e.stopPropagation() }) //编辑跳转 $('.editFile').click(function(){ openEditorView(0,$(this).data('filename'),function(val,aceEitor){ aceEitor.ace.find(data.text) aceEitor.ace.execCommand('find') }) }) }) }, /** * @description 设置搜索历史列表 * @param {String} text 查找的文本 * @returns void */ setSearchHistoryList:function(text){ var h_cookie = JSON.parse(bt.get_cookie('file_search_list')); if($.type(h_cookie) === 'undefined' || h_cookie == null){ bt.set_cookie('file_search_list', JSON.stringify([text])) }else{ if($.inArray(text,h_cookie) != -1) return true; //如果已在列表中则跳过 h_cookie.unshift(text) //数组首位添加查找内容 if(h_cookie.length > 7) h_cookie.pop() //超过7位时删除最后一条搜索记录 bt.set_cookie('file_search_list', JSON.stringify(h_cookie)) } }, /** * @description 转义查找输入的内容特殊字符 * @param {String} e 查找的内容 * @returns 返回转义结果 */ escodeChange:function(e){ if(/(\+|\-|\$|\||\!|\(|\)|\{|\}|\[|\]|\^|\”|\~|\*|\?|\:|\\)/g.test(e)){ e = e.replace(/(\+|\-|\$|\||\!|\(|\)|\{|\}|\[|\]|\^|\”|\~|\*|\?|\:|\\)/g,'\\$1').replace(/&/g, "&").replace(/\>/g, ">").replace(/\\
      \
      \ '+ lan.files.recycle_bin_on + '\
      \ \ \
      \ '+ lan.files.recycle_bin_on_db + '\
      \ \ \
      \
      \ '+ lan.files.recycle_bin_ps + '\ \
      \
      \
      \

      '+lan.files.recycle_bin_type1+'

      \

      '+lan.files.recycle_bin_type2+'

      \

      '+lan.files.recycle_bin_type3+'

      \

      '+lan.files.recycle_bin_type4+'

      \

      '+lan.files.recycle_bin_type5+'

      \

      '+lan.files.recycle_bin_type6+'

      \
      \
      \
      \ \ \ \ \ \ \ \ \ \ \ \
      '+lan.files.recycle_bin_th1+''+lan.files.recycle_bin_th2+''+lan.files.recycle_bin_th3+''+lan.files.recycle_bin_th4+''+lan.files.recycle_bin_th5+'
      \
      \
      \
      \ ', success:function(){ if(window.location.href.indexOf("database") != -1){ $(".re-con-menu p:last-child").addClass("on").siblings().removeClass("on"); that.render_recycle_list(6) }else{ that.render_recycle_list(1) } $(".re-con-menu").on('click','p',function(){ var _type = $(this).data('type'); $(this).addClass("on").siblings().removeClass("on"); that.render_recycle_list(_type); }) } }) }, // 回收站渲染列表 render_recycle_list:function(num){ var that = this; this.$http('Get_Recycle_bin',function(rdata){ var body = ''; $('#Set_Recycle_bin').attr('checked',rdata.status); $('#Set_Recycle_bin_db').attr('checked',rdata.status_db); switch (num) { case 1: for (var i = 0; i < rdata.dirs.length; i++) { var shortwebname = rdata.dirs[i].name.replace(/'/, "\\'"); var shortpath = rdata.dirs[i].dname; if (shortwebname.length > 20) shortwebname = shortwebname.substring(0, 20) + "..."; if (shortpath.length > 20) shortpath = shortpath.substring(0, 20) + "..."; body += '\ ' + shortwebname + '\ ' + shortpath + '\ '+ ToSize(rdata.dirs[i].size) + '\ '+ getLocalTime(rdata.dirs[i].time) + '\ \ ' + lan.files.recycle_bin_re + '\ | ' + lan.files.recycle_bin_del + '\ \ '; } for (var i = 0; i < rdata.files.length; i++) { if (rdata.files[i].name.indexOf('BTDB_') != -1) { var shortwebname = rdata.files[i].name.replace(/'/, "\\'"); var shortpath = rdata.files[i].dname; if (shortwebname.length > 20) shortwebname = shortwebname.substring(0, 20) + "..."; if (shortpath.length > 20) shortpath = shortpath.substring(0, 20) + "..."; body += '\ ' + shortwebname.replace('BTDB_', '') + '\ mysql://' + shortpath.replace('BTDB_', '') + '\ -\ '+ getLocalTime(rdata.files[i].time) + '\ \ ' + lan.files.recycle_bin_re + '\ | ' + lan.files.recycle_bin_del + '\ \ ' continue; } var shortwebname = rdata.files[i].name.replace(/'/, "\\'"); var shortpath = rdata.files[i].dname; if (shortwebname.length > 20) shortwebname = shortwebname.substring(0, 20) + "..."; if (shortpath.length > 20) shortpath = shortpath.substring(0, 20) + "..."; body += '\ ' + shortwebname + '\ ' + shortpath + '\ '+ ToSize(rdata.files[i].size) + '\ '+ getLocalTime(rdata.files[i].time) + '\ \ ' + lan.files.recycle_bin_re + '\ | ' + lan.files.recycle_bin_del + '\ \ ' } $("#RecycleBody").html(body); return; break; case 2: for (var i = 0; i < rdata.dirs.length; i++) { var shortwebname = rdata.dirs[i].name.replace(/'/, "\\'"); var shortpath = rdata.dirs[i].dname; if (shortwebname.length > 20) shortwebname = shortwebname.substring(0, 20) + "..."; if (shortpath.length > 20) shortpath = shortpath.substring(0, 20) + "..."; body += '\ ' + shortwebname + '\ ' + shortpath + '\ '+ ToSize(rdata.dirs[i].size) + '\ '+ getLocalTime(rdata.dirs[i].time) + '\ \ ' + lan.files.recycle_bin_re + '\ | ' + lan.files.recycle_bin_del + '\ \ ' } $("#RecycleBody").html(body); return; break; case 3: for (var i = 0; i < rdata.files.length; i++) { if (rdata.files[i].name.indexOf('BTDB_') != -1) continue; var shortwebname = rdata.files[i].name.replace(/'/, "\\'"); var shortpath = rdata.files[i].dname; if (shortwebname.length > 20) shortwebname = shortwebname.substring(0, 20) + "..."; if (shortpath.length > 20) shortpath = shortpath.substring(0, 20) + "..."; body += '\ ' + shortwebname + '\ ' + shortpath + '\ '+ ToSize(rdata.files[i].size) + '\ '+ getLocalTime(rdata.files[i].time) + '\ \ ' + lan.files.recycle_bin_re + '\ | ' + lan.files.recycle_bin_del + '\ \ ' } $("#RecycleBody").html(body); return; break; case 4: for (var i = 0; i < rdata.files.length; i++) { if (ReisImage(getFileName(rdata.files[i].name))) { var shortwebname = rdata.files[i].name.replace(/'/, "\\'"); var shortpath = rdata.files[i].dname; if (shortwebname.length > 20) shortwebname = shortwebname.substring(0, 20) + "..."; if (shortpath.length > 20) shortpath = shortpath.substring(0, 20) + "..."; body += '\ ' + shortwebname + '\ ' + shortpath + '\ '+ ToSize(rdata.files[i].size) + '\ '+ getLocalTime(rdata.files[i].time) + '\ \ ' + lan.files.recycle_bin_re + '\ | ' + lan.files.recycle_bin_del + '\ \ ' } } $("#RecycleBody").html(body); return; break; case 5: for (var i = 0; i < rdata.files.length; i++) { if (rdata.files[i].name.indexOf('BTDB_') != -1) continue; if (!(ReisImage(getFileName(rdata.files[i].name)))) { var shortwebname = rdata.files[i].name.replace(/'/, "\\'"); var shortpath = rdata.files[i].dname; if (shortwebname.length > 20) shortwebname = shortwebname.substring(0, 20) + "..."; if (shortpath.length > 20) shortpath = shortpath.substring(0, 20) + "..."; body += '\ ' + shortwebname + '\ ' + shortpath + '\ '+ ToSize(rdata.files[i].size) + '\ '+ getLocalTime(rdata.files[i].time) + '\ \ ' + lan.files.recycle_bin_re + '\ | ' + lan.files.recycle_bin_del + '\ \ ' } } $("#RecycleBody").html(body); return; case 6: for (var i = 0; i < rdata.files.length; i++) { if (rdata.files[i].name.indexOf('BTDB_') != -1) { var shortwebname = rdata.files[i].name.replace(/'/, "\\'"); var shortpath = rdata.files[i].dname; if (shortwebname.length > 20) shortwebname = shortwebname.substring(0, 20) + "..."; if (shortpath.length > 20) shortpath = shortpath.substring(0, 20) + "..."; body += '\ ' + shortwebname.replace('BTDB_', '') + '\ mysql://' + shortpath.replace('BTDB_', '') + '\ -\ '+ getLocalTime(rdata.files[i].time) + '\ \ ' + lan.files.recycle_bin_re + '\ | ' + lan.files.recycle_bin_del + '\ \ ' } } $("#RecycleBody").html(body); return; break; } function getFileName(name) { var text = name.split("."); var n = text.length - 1; text = text[n]; return text; } function ReisImage(fileName) { var exts = ['jpg', 'jpeg', 'png', 'bmp', 'gif', 'tiff', 'ico']; for (var i = 0; i < exts.length; i++) { if (fileName == exts[i]) return true } return false; } $('#RecycleBody').html(body); }) }, /** * @description 回收站视图 * @return void */ recycle_bin_view: function() { var that = this; layer.open({ title:lan.files.recycle_bin_title, type:1, skin:'recycle_view', area:['80%','672px'], closeBtn:2, content:'
      \
      \
      \ ' + lan.files.recycle_bin_on + '\
      \ \ \
      \ ' + lan.files.recycle_bin_on_db + '\
      \ \ \
      \
      \ ' + lan.files.recycle_bin_ps + '\ \
      \
      \
      \

      ' + lan.files.recycle_bin_type1 + '

      \

      ' + lan.files.recycle_bin_type2 + '

      \

      ' + lan.files.recycle_bin_type3 + '

      \

      ' + lan.files.recycle_bin_type4 + '

      \

      ' + lan.files.recycle_bin_type5 + '

      \

      ' + lan.files.recycle_bin_type6 + '

      \
      \
      \
      \
      ', success:function(){ if (window.location.href.indexOf("database") != -1) { $(".re-con-menu p:last-child").addClass("on").siblings().removeClass("on"); $(".re-con-menu p:eq(5)").click(); } else { $(".re-con-menu p:eq(0)").click(); } var render_recycle = that.render_recycle_list(); $(".re-con-menu").on('click', 'p', function() { var _type = $(this).data('type'); $(this).addClass("on").siblings().removeClass("on"); render_recycle.$refresh_table_list(true); }); } }) }, /** * @description 回收站渲染列表 * @return void */ render_recycle_list: function() { var that = this; $('#recycle_table').empty() var recycle_list = bt_tools.table({ el: '#recycle_table', url: '/files?action=Get_Recycle_bin', height: 488, dataFilter: function (res) { var files = []; switch($('.re-con-menu p.on').index()){ case 0: for (var i = 0; i < res.dirs.length; i++){ var item = res.dirs[i]; if (item.name.indexOf('BTDB_') > -1) { item.dname = item.dname.replace('BTDB_', ''); item.name = item.name.replace('BTDB_', ''); files.push($.extend(item,{type:'files'})); } else { var item = res.dirs[i]; files.push($.extend(item,{type:'folder'})); } } for (var j = 0; j < res.files.length; j++){ var item = res.files[j],ext_list = item.dname.split('.') ,ext = that.determine_file_type(ext_list[ext_list.length - 1]); if(ext == 'images'){ files.push($.extend(item,{type:ext})); }else{ files.push($.extend(item,{type:'files'})); } } break; case 1: for (var i = 0; i < res.dirs.length; i++){ var item = res.dirs[i]; files.push($.extend(item,{type:'folder'})); } break; case 2: for (var j = 0; j < res.files.length; j++){ var item = res.files[j],ext_list = item.dname.split('.') ,ext = that.determine_file_type(ext_list[ext_list.length - 1]); if(item.name.indexOf('BTDB') == -1) files.push($.extend(item,{type:ext})); } break; case 3: for (var j = 0; j < res.files.length; j++){ var item = res.files[j],ext_list = item.dname.split('.') ,ext = that.determine_file_type(ext_list[ext_list.length - 1]); if(ext == 'images') files.push($.extend(item,{type:ext})); } break; case 4: for (var j = 0; j < res.files.length; j++){ var item = res.files[j],ext_list = item.dname.split('.') ,ext = that.determine_file_type(ext_list[ext_list.length - 1]); if(ext != 'images' && ext != 'compress' && ext != 'video' && item.name.indexOf('BTDB') == -1) files.push($.extend(item,{type:ext})); } break; case 5: for (var j = 0; j < res.dirs.length; j++){ var item = res.dirs[j]; if (item.name.indexOf('BTDB_') > -1) { item.dname = item.dname.replace('BTDB_',''); item.name = item.name.replace('BTDB_',''); files.push($.extend(item,{type:'files'})); } } break; } $('#Set_Recycle_bin').attr('checked', res.status); $('#Set_Recycle_bin_db').attr('checked', res.status_db); return {data:files} }, column:[ {type:'checkbox',class:'',width:18}, {fid:'name',title:lan.files.recycle_bin_th1, width: 150, template:function(row){ return '
      '+ row.name +'
      '; }}, {fid:'dname',title:lan.files.recycle_bin_th2, width: 150, template:function(row){ return '
      '+ row.dname +'
      '; }}, {fid:'size',title:lan.files.recycle_bin_th3,width:85,template:function(row){ return ''+ bt.format_size(row.size) +''; }}, { fid: 'time', title: lan.files.recycle_bin_th4, width: 130, template:function(row, index){ return ''+ bt.format_data(row.time) + '' } }, { type: 'group', align: 'right', width: 170, title: lan.files.recycle_bin_th5, group: [ { title: lan.files.recycle_bin_re, event: function (row, index, ev, key, that) { bt_file.ReRecycleBin(row.rname, function () { that.$delete_table_row(index); }); } }, { title:lan.files.recycle_bin_del, event: function (row, index, ev, key, that) { bt_file.DelRecycleBin(row.rname, function () { that.$delete_table_row(index); }); } } ] } ], tootls: [{ // 批量操作 type: 'batch',//batch_btn positon: ['left', 'bottom'], placeholder: 'Please Choose', buttonValue: 'Execute', disabledSelectValue: 'Please select the port that needs batch operation!', selectList:[{ title:"Restore", url:'/files?action=Re_Recycle_bin', load:true, param:function(row){ return {path:row.rname}; }, callback:function(that){ bt.confirm({title:'Restore files',msg:'Batch restore selected files, do you want to continue?',icon:0},function(index){ layer.close(index); that.start_batch({},function(list){ var html = ''; for(var i=0;i
      '+ (item.request.status?'Successful recovery':'Recovery failed') +'
      '; } recycle_list.$batch_success_table({title:'Restore files',th:'File name',html:html}); recycle_list.$refresh_table_list(true); }); }); } },{ title:"Delete files permanently", url:'/files?action=Del_Recycle_bin', load:true, param:function(row){ return {path:row.rname}; }, callback:function(that){ bt.confirm({title:'Delete selected files',msg:'Delete the selected file. The file will be completely deleted and cannot be recovered. Do you want to continue?',icon:0},function(index){ layer.close(index); that.start_batch({},function(list){ var html = ''; for(var i=0;i'+ item.name +''+ (item.request.status?'Successfully deleted':'Failed to delete') +''; } recycle_list.$batch_success_table({title:'Delete multiple files',th:'File name',html:html}); recycle_list.$refresh_table_list(true); }); }); } }] }] }); bt_tools.$fixed_table_thead('#recycle_table .divtable'); return recycle_list; }, // 回收站开关 Set_Recycle_bin:function(db) { var loadT = layer.msg(lan.public.the, { icon: 16, time: 0, shade: [0.3, '#000'] }); var that = this,data = {} if (db == 1) { data = { db: db }; } $.post('/files?action=Recycle_bin', data, function (rdata) { layer.close(loadT); if(rdata.status){ if(db == undefined) that.is_recycle = $('#Set_Recycle_bin').prop('checked'); } layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 }); }); }, // 回收站恢复 ReRecycleBin:function(path, obj) { layer.confirm(lan.files.recycle_bin_re_msg, { title: lan.files.recycle_bin_re_title, closeBtn: 2, icon: 3 }, function () { var loadT = layer.msg(lan.files.recycle_bin_re_the, { icon: 16, time: 0, shade: [0.3, '#000'] }); $.post('/files?action=Re_Recycle_bin', 'path=' + encodeURIComponent(path), function (rdata) { layer.close(loadT); layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 }); $(obj).parents('tr').remove(); }); }); }, //回收站删除 DelRecycleBin:function(path, obj) { layer.confirm(lan.files.recycle_bin_del_msg, { title: lan.files.recycle_bin_del_title, closeBtn: 2, icon: 3 }, function () { var loadT = layer.msg(lan.files.recycle_bin_del_the, { icon: 16, time: 0, shade: [0.3, '#000'] }); $.post('/files?action=Del_Recycle_bin', 'path=' + encodeURIComponent(path), function (rdata) { layer.close(loadT); layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 }); $(obj).parents('tr').remove(); }); }); }, //清空回收站 CloseRecycleBin:function(){ var _this = this; layer.confirm(lan.files.recycle_bin_close_msg, { title: lan.files.recycle_bin_close, closeBtn: 2, icon: 3 }, function () { var loadT = layer.msg("
      " + lan.files.recycle_bin_close_the + "
      ", { icon: 16, time: 0, shade: [0.3, '#000'] }); setTimeout(function () { getSpeed('.myspeed'); }, 1000); $.post('/files?action=Close_Recycle_bin', '', function (rdata) { layer.close(loadT); layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 }); _this.render_recycle_list() }); }); }, /** * @description 打开属性视图 * @param {Object} data 当前文件的数据对象 * @return void */ open_property_view:function (data) { var _this = this; _this.$http('get_file_attribute',{filename:data.path},function (res) { layer.open({ type: 1, closeBtn: 2, title: '[ ' + data.filename +' ] - '+ (data.is_dir?'Folder':'File') +' properties', area: ["580px", "500px"], shadeClose: false, // btn:['确认','取消'], content:'
      \
      \ General\ Detail\ History\
      \
      \
      \
      \
      \
      \
      \
      \
      \
      Type:
      \
      '+ ((res.is_dir || res.is_link)?res.st_type:_this.ext_type_tips(res.st_type)) +'
      \
      \
      \
      Location:
      \
      \ '+ (res.path + '/' + data.filename).replace('//','/') +'\ \
      \
      \
      \
      Size:
      \
      '+ bt.format_size(res.st_size) +' ('+(_this.font_thousandth(res.st_size) + ' byte')+')'+'
      \
      \
      \
      \
      Permissions:
      \
      '+ res.mode +'
      \
      \
      \
      Group:
      \
      '+ res.group +'
      \
      \
      \
      User:
      \
      '+ res.user +'
      \
      \
      \
      \
      Visit time:
      \
      '+ bt.format_data(res.st_atime) +'
      \
      \
      \
      Modified time:
      \
      '+ bt.format_data(res.st_mtime) +'
      \
      \
      \
      \ \ \ \
      Properties
      Value
      \
      \
      \ \ \ \
      Modified time
      Size
      MD5
      OPT
      \
      \
      \
      ', success:function(layero,index){ var copy_properyt_path = new ClipboardJS('.copyProperytPath'); copy_properyt_path.on('success', function (e) { layer.msg(lan.public.cp_success, { icon: 1 }); }); $('.bt-property-setting .tab-nav span').click(function () { var index = $(this).index(); $(this).addClass('on').siblings().removeClass('on'); $('.property-box:eq('+index +')').addClass('active').siblings().removeClass('active'); }) $('.history_box_view').on('click','.open_history_file',function(){ var _history = $(this).attr('data-time'); openEditorView(0,data.path) setTimeout(function () { aceEditor.openHistoryEditorView({filename:data.path,history:_history},function(){ layer.close(index) $('.ace_conter_tips').show(); $('.ace_conter_tips .tips').html('Read-only file, the file is '+ _item.path +', historic version [ '+ bt.format_data(new Number(_history)) +' ]Click to restore'); }); },500) }); $('.history_box_view').on('click','.recovery_file_historys',function(){ aceEditor.event_ecovery_file(this); }); var config = { filename:['Name',data.filename], type:['Type',(res.is_dir || res.is_link)?res.st_type:_this.ext_type_tips(res.st_type)], path:'Location', st_size:['Size',bt.format_size(res.st_size) +' ('+(_this.font_thousandth(res.st_size) + ' byte')+')'], st_atime:['Visit time',bt.format_data(res.st_atime)],st_mtime:['Modified time',bt.format_data(res.st_mtime)],st_ctime:['Metadata modification time',bt.format_data(res.st_ctime)], md5:'MD5',sha1:'sha1', user:'User',group:'Group',mode:'Permissions', st_uid:'UID',st_gid:'GID', st_nlink:'Num of inode links',st_ino:'inode node num',st_mode:'inode protection mode',st_dev:'inode resident device', },html = '',html2= ''; for (var key in config) { if (Object.hasOwnProperty.call(config, key)) { var element = config[key],value = ($.isArray(element)?element[1]:res[key]); html += '
      '+ ($.isArray(element)?element[0]:element) +'
      '+ value +'
      '; } } for (let i = 0; i < res.history.length; i++) { const item = res.history[i]; html2 += '
      '+ bt.format_data(item.st_mtime) +'
      '+ bt.format_size(item.st_size) +'
      '+ item.md5 +'
      view  |  restore
      ' } if(html2 === '') html2 += '
      No historical version
      ' $('.details_list').html(html); $('.history_list ').html(html2); _this.fixed_table_thead('.details_box_view'); _this.fixed_table_thead('.history_box_view '); } }) }) }, /** * @description 固定表头 * @param {string} el DOM选择器 * @return void */ fixed_table_thead:function(el) { $(el).scroll(function () { var scrollTop = this.scrollTop; this.querySelector('thead').style.transform = 'translateY(' + scrollTop + 'px)'; }) }, /** * @description 字符千分隔符 * @param {string} el DOM选择器 * @return void */ font_thousandth:function(num) { var source = String(num).split(".");//按小数点分成2部分 source[0] = source[0].replace(new RegExp('(\\d)(?=(\\d{3})+$)','ig'),"$1,");//只将整数部分进行都好分割 return source.join(".");//再将小数部分合并进来 }, /** * @description 打开图片预览 * @param {Object} data 当前文件的数据对象 * @return void */ open_images_preview:function(data){ var that = this,mask = $('
      '+ '
      '+ ''+ data.filename +''+ ''+ ''+ ''+ '
      '+ '
      '+ '
      '+ ''+ ''+ ''+ ''+ ''+ ''+ '
      '+ '
      '+ ''+ ''+ '
      '+ '
      '), images_config = {natural_width:0,natural_height:0,init_width:0,init_height:0,preview_width:0,preview_height:0,current_width:0,current_height:0,current_left:0,current_top:0,rotate:0,scale:1,images_mouse:false}; if($('.preview_images_mask').length > 0){ $('#preview_images').attr('src','/download?filename=' + data.path); return false; } $('body').css('overflow','hidden').append(mask); images_config.preview_width = mask[0].clientWidth; images_config.preview_height = mask[0].clientHeight; // 图片预览 $('.preview_body img').load(function(){ var img = $(this)[0]; if(!$(this).attr('data-index')) $(this).attr('data-index',data.images_id); images_config.natural_width = img.naturalWidth; images_config.natural_height = img.naturalHeight; auto_images_size(false); }); //图片头部拖动 $('.preview_images_mask .preview_head').on('mousedown',function(e){ e = e || window.event; //兼容ie浏览器 var drag = $(this).parent(); $('body').addClass('select'); //webkit内核和火狐禁止文字被选中 $(this).onselectstart = $(this).ondrag = function () { //ie浏览器禁止文字选中 return false; } if ($(e.target).hasClass('preview_close')) { //点关闭按钮不能拖拽模态框 return; } var diffX = e.clientX - drag.offset().left; var diffY = e.clientY - drag.offset().top; $(document).on('mousemove',function(e){ e = e || window.event; //兼容ie浏览器 var left = e.clientX - diffX; var top = e.clientY - diffY; if (left < 0) { left = 0; } else if (left > window.innerWidth - drag.width()) { left = window.innerWidth - drag.width(); } if (top < 0) { top = 0; } else if (top > window.innerHeight - drag.height()) { top = window.innerHeight - drag.height(); } drag.css({ left:left, top:top, margin:0 }); }).on('mouseup',function(){ $(this).unbind('mousemove mouseup'); }); }); //图片拖动 $('.preview_images_mask #preview_images').on('mousedown',function(e){ e = e || window.event; $(this).onselectstart = $(this).ondrag = function(){ return false; } var images = $(this); var preview = $('.preview_images_mask').offset(); var diffX = e.clientX - preview.left; var diffY = e.clientY - preview.top; $('.preview_images_mask').on('mousemove',function(e){ e = e || window.event var offsetX = e.clientX - preview.left - diffX, offsetY = e.clientY - preview.top - diffY, rotate = Math.abs(images_config.rotate / 90), preview_width = (rotate % 2 == 0?images_config.preview_width:images_config.preview_height), preview_height = (rotate % 2 == 0?images_config.preview_height:images_config.preview_width), left,top; if(images_config.current_width > preview_width){ var max_left = preview_width - images_config.current_width; left = images_config.current_left + offsetX; if(left > 0){ left = 0 }else if(left < max_left){ left = max_left } images_config.current_left = left; } if(images_config.current_height > preview_height){ var max_top = preview_height - images_config.current_height; top = images_config.current_top + offsetY; if(top > 0){ top = 0 }else if(top < max_top){ top = max_top } images_config.current_top = top; } if(images_config.current_height > preview_height && images_config.current_top <= 0){ if((images_config.current_height - preview_height) <= images_config.current_top){ images_config.current_top -= offsetY } } images.css({'left':images_config.current_left,'top':images_config.current_top}); }).on('mouseup',function(){ $(this).unbind('mousemove mouseup'); }).on('dragstart',function(){ e.preventDefault(); }); }).on('dragstart',function(){ return false; }); //关闭预览图片 $('.preview_close').click(function(e){ $('.preview_images_mask').remove(); }); //图片工具条预览 $('.preview_toolbar a').click(function(){ var index = $(this).index(),images = $('#preview_images'); switch(index){ case 0: //左旋转,一次旋转90度 case 1: //右旋转,一次旋转90度 images_config.rotate = index?(images_config.rotate + 90):(images_config.rotate - 90); auto_images_size(); break; case 2: case 3: if(images_config.scale == 3 && index == 2|| images_config.scale == 0.2 && index == 3){ layer.msg((images_config.scale >= 1?'The image is the maximum size':'The image is the minimum size')); return false; } images_config.scale = (index == 2?Math.round((images_config.scale + 0.4)*10):Math.round((images_config.scale - 0.4)*10))/10; auto_images_size(); break; case 4: var scale_offset = images_config.rotate % 360; if(scale_offset >= 180){ images_config.rotate += (360 - scale_offset); }else{ images_config.rotate -= scale_offset; } images_config.scale = 1; auto_images_size(); break; } }); // 最大最小化图片 $('.preview_full,.preview_small').click(function(){ if($(this).hasClass('preview_full')){ $(this).addClass('hidden').prev().removeClass('hidden'); images_config.preview_width = that.area[0]; images_config.preview_height = that.area[1]; mask.css({width:that.area[0],height:that.area[1],top:0,left:0,margin:0}).data('type','full'); auto_images_size(); }else{ $(this).addClass('hidden').next().removeClass('hidden'); $('.preview_images_mask').removeAttr('style'); images_config.preview_width = 750; images_config.preview_height = 650; auto_images_size(); } }); // 上一张,下一张 $('.preview_cut_view a').click(function(){ var images_src = '',preview_images = $('#preview_images'),images_id = parseInt(preview_images.attr('data-index')); if(!$(this).index()){ images_id = images_id === 0?(that.file_images_list.length - 1) : images_id - 1; images_src = that.file_images_list[images_id]; }else{ images_id = (images_id == (that.file_images_list.length - 1))?0:(images_id+1); images_src = that.file_images_list[images_id]; } preview_images.attr('data-index',images_id).attr('src','/download?filename='+images_src); $('.preview_title').html(that.get_path_filename(images_src)); }); // 自动图片大小 function auto_images_size(transition){ var rotate = Math.abs(images_config.rotate / 90),preview_width = (rotate % 2 == 0?images_config.preview_width:images_config.preview_height),preview_height = (rotate % 2 == 0?images_config.preview_height:images_config.preview_width),preview_images = $('#preview_images'),css_config = {}; images_config.init_width = images_config.natural_width; images_config.init_height = images_config.natural_height; if(images_config.init_width > preview_width){ images_config.init_width = preview_width; images_config.init_height = parseFloat(((preview_width / images_config.natural_width) * images_config.init_height).toFixed(2)); } if(images_config.init_height > preview_height){ images_config.init_width = parseFloat(((preview_height / images_config.natural_height) * images_config.init_width).toFixed(2)); images_config.init_height= preview_height; } images_config.current_width = parseFloat(images_config.init_width * images_config.scale); images_config.current_height = parseFloat(images_config.init_height * images_config.scale); images_config.current_left = parseFloat(((images_config.preview_width - images_config.current_width) / 2).toFixed(2)); images_config.current_top = parseFloat(((images_config.preview_height - images_config.current_height) / 2).toFixed(2)); css_config = { 'width':images_config.current_width , 'height':images_config.current_height, 'top':images_config.current_top, 'left':images_config.current_left, 'display':'inline', 'transform':'rotate('+ images_config.rotate +'deg)', 'opacity':1, 'transition':'all 100ms', } if(transition === false) delete css_config.transition; preview_images.css(css_config); } }, /** * @description 打开视频播放 * @param {Object} data 当前文件的数据对象 * @return void */ open_video_play:function(data){ var old_filename = data.path, imgUrl = '/download?filename=' + data.path, p_tmp = data.path.split('/'), path = p_tmp.slice(0, p_tmp.length - 1).join('/') layer.open({ type: 1, closeBtn: 2, title: 'Playing [' + p_tmp[p_tmp.length-1] + ']', area: ["890px","402px"], shadeClose: false, skin:'movie_pay', content: '
      ', success: function () { $.post('/files?action=get_videos', { path: path }, function (rdata) { var video_list = '',index = 0; for (var i = 0; i < rdata.length; i++) { var filename = path + '/' + rdata[i].name; if(filename === old_filename) index = i; video_list += ''; } video_list += '
      File nameSize
      ' + rdata[i].name + '' + ToSize(rdata[i].size) + '
      '; $('.video-list').html(video_list).scrollTop(index * 34); }); } }); }, /** * @description 切换播放 * @param {String} obj * @param {String} filename 文件名 * @return void */ play_file:function(obj,filename) { if($('#btvideo video').attr('data-filename')== filename) return false; var imgUrl = '/download?filename=' + filename + '&play=true'; var v = '' $("#btvideo").html(v); var p_tmp = filename.split('/') $(".btvideo-title").html(p_tmp[p_tmp.length-1]); $(".video-avt").removeClass('video-avt'); $(obj).parents('tr').addClass('video-avt'); }, /** * @description 复制文件和目录 * @param {Object} data 当前文件的数据对象 * @return void */ copy_file_or_dir:function(data){ bt.set_cookie('record_paste',data.path); bt.set_cookie('record_paste_type','copy'); $('.file_all_paste').removeClass('hide'); layer.msg('Copy successfully. Please click [Paste] or Ctrl + V to paste'); }, /** * @description 剪切文件和目录 * @param {Object} data 当前文件的数据对象 * @return void */ cut_file_or_dir:function(data){ bt.set_cookie('record_paste',data.path); bt.set_cookie('record_paste_type','cut'); $('.file_all_paste').removeClass('hide'); layer.msg('Cut successfully. Please click [Paste] or Ctrl + V to paste'); }, /** * @descripttion 粘贴文件和目录 * @return: 无返回值 */ paste_file_or_dir:function(){ var that = this,_isPaste = bt.get_cookie('record_paste_type'),_paste = bt.get_cookie('record_paste'),_filename = ''; if(_paste != 'null' && _paste != undefined){_filename = _paste.split('/').pop()} if(that.file_path.indexOf(_paste) > -1){ layer.msg('Can not paste ['+_filename+'] here, Because the item cannot be pasted into itself.',{icon:0}) return false; } if(_isPaste != 'null' && _isPaste != undefined){ switch(_isPaste){ case 'cut': case 'copy': this.check_exists_files_req({dfile:this.file_path,filename:_filename},function(result){ if(result.length > 0){ var tbody = ''; for(var i=0;i'+ToSize(result[i].size)+''+getLocalTime(result[i].mtime)+''; } var mbody = '
      \ '+tbody+'\
      File nameSizeLast edit time
      '; SafeMessage('This files will be overwritten',mbody,function(){ that.config_paste_to(_paste,_filename); }); }else{ that.config_paste_to(_paste,_filename); } }) break; case '1': case '2': that.batch_file_paste(); break; } } }, /** * @descripttion 粘贴到 * @param {String} path 复制/剪切路径 * @param {String} _filename 文件名称 * @return: 无返回值 */ config_paste_to:function(path,_filename){ var that = this,_type= bt.get_cookie('record_paste_type'); this.$http(_type == 'copy'?'CopyFile':'MvFile',{sfile:path,dfile:(this.file_path+'/'+_filename)},function(rdata){ if(rdata.status){ bt.set_cookie('record_paste',null); bt.set_cookie('record_paste_type',null); that.reader_file_list({path:that.file_path}) } layer.msg(rdata.msg,{icon:rdata.status?1:2}) }) }, /** * @description 重命名文件和目录 * @param {Object} data 当前文件的数据对象 * @return void */ rename_file_or_dir:function(data){ var that = this; that.is_editor = true; $('.file_list_content .file_tr:nth-child('+(data.index+1)+')').addClass('editr_tr').find('.file_title').empty().append($((bt.get_cookie('rank') == 'icon'?'':''))) if(bt.get_cookie('rank') == 'icon'){ $('textarea[name=rename_file_input]').css({'height':$('textarea[name=rename_file_input]')[0].scrollHeight}) } $((bt.get_cookie('rank') == 'icon'?'textarea':'input')+'[name=rename_file_input]').on('input',function(){ if(bt.get_cookie('rank') == 'icon'){ this.style.height = 'auto'; this.style.height = this.scrollHeight + "px"; } if(data.type == 'file'){ var ext_arry = $(this).val().split('.'),ext = ext_arry[ext_arry.length- 1]; $(this).parent().prev().find('.file_icon').removeAttr('class').addClass('file_icon file_'+ ext); } }).keyup(function(e){ if(e.keyCode == 13) $(this).blur(); e.stopPropagation(); e.preventDefault(); }).blur(function(){ var _val = $(this).val().replace(/[\r\n]/g,""),config = {sfile:data.path,dfile: that.path_resolve(that.file_path,_val)} if(data.filename == _val || _val == ''){ $('.file_list_content .file_tr:nth-child('+(data.index+1)+')').removeClass('editr_tr').find('.file_title').empty().append($(''+data.filename+'')); that.is_editor = false; return false; } if(that.match_unqualified_string(_val)) return layer.msg('The name cannot have /\\:*?"<>| symbol',{icon:2}); that.rename_file_req(config,function(res){ that.reader_file_list({path:that.file_path},function(){layer.msg(res.msg,{icon:res.status?1:2})}); }); that.is_editor = false; }).focus(); }, /** * @description 设置文件和目录分享 * @param {Object} data 当前文件的数据对象 * @returns void */ set_file_share:function(data){ var that = this; this.loadY = bt.open({ type: 1, shift: 5, closeBtn: 2, area: '450px', title: 'Set share '+ data.type_tips +'-['+ data.filename +']', btn:['Create','Cancel'], content: '' + '
      Share name
      ' + '
      Expiration date
      ' +'' +'' +'' +'
      ' + '
      Extraction code
      ' + '
      ', yes:function(indexs,layers){ var ps = $('[name=ps]').val(),expire = $('[name=expire]:checked').val(),password = $('[name=password]').val(); if(ps === ''){ layer.msg('No sharing name!',{icon:2}) return false; } that.create_download_url({ filename:data.path, ps:ps, password:password, expire:expire },function(res){ if(!res.status){ layer.msg(res.msg,{icon:res.status?1:2}) return false; }else{ var rdata = res.msg; that.file_list[data.index] = $.extend(that.file_list[data.index],{down_id:rdata.id,down_info:rdata}); that.loadY.close(); that.info_file_share(data); that.reader_file_list_content(that.file_list); } }); }, success: function (layers, index) { $('#random_paw').click(function(){ $(this).prev().val(bt.get_random(6)); }); } }); }, /** * @description 分享信息查看 * @param {Object} data 当前文件的数据对象 * @returns void */ info_file_share:function(data){ var that = this; if(typeof data.down_info == "undefined"){ this.get_download_url_find({id:data.down_id},function(res){ that.file_list[data.index] = $.extend(that.file_list[data.index],{down_info:res}); that.file_share_view(that.file_list[data.index],'fonticon'); }) return false; } this.file_share_view(data,'fonticon'); }, /** * @description 分享信息视图 * @param {Object} data 当前文件的数据对象 * @param {String} type 区别通过右键打开或是图标点击 * @returns void */ file_share_view:function(datas,type){ var data = datas if(type == 'fonticon'){data = datas.down_info} var that = this,download_url = location.origin + '/down/'+ data.token; this.loadY = bt.open({ type: 1, shift: 5, closeBtn: 2, area: '550px', title: 'Share details-['+ data.filename +']', content: '
      ' + '
      Share name
      ' + '' + '' + '
      Expiration date
      '+((data.expire > (new Date('2099-01-01 00:00:00').getTime())/1000)?'Permanent':bt.format_data(data.expire))+'
      ' + '
      ' + '' + '' + '
      ' + '
      ', success: function (layers,index) { var copy_url = new ClipboardJS('.copy_url'); var copy_paw = new ClipboardJS('.copy_paw'); copy_url.on('success', function(e) { layer.msg('Copy link succeeded!',{icon:1}); e.clearSelection(); }); copy_paw.on('success', function(e) { layer.msg('Copy link and extraction code succeeded!',{icon:1}); e.clearSelection(); }); $('.layer_close').click(function(){ layer.close(index); }); $('.QR_code').click(function(){ layer.closeAll('tips'); layer.tips('
      ','.QR_code',{ area:['150px','150px'], tips: [1, '#ececec'], time:0, shade:[0.05, '#000'], shadeClose:true, success:function(){ jQuery('#QR_code').qrcode({ render: "canvas", text: download_url, height:130, width:130 }); } }); }); $('.close_down').click(function(){ that.remove_download_url({id:data.id,fileName:data.filename},function(res){ that.loadY.close(); if(type == 'fonticon'){ that.file_list[datas.index].down_id = 0; that.reader_file_list_content(that.file_list); } if(type == 'list'){that.render_share_list();} layer.msg(res.msg,{icon:res.status?1:2}) }) }); } }); }, /** * @description 删除文件和目录 * @param {Object} data 当前文件的数据对象 * @return void */ del_file_or_dir:function(data){ var that = this; if(that.is_recycle){ bt.confirm({ title:'Delete '+ data.type_tips +'[ '+ data.filename +' ]', msg:'Confirm delete '+ data.type_tips +'[ '+ data.path +' ],it will move to recycle bin after delete, continue?' },function(){ that.del_file_req(data,function(res){ that.reader_file_list({path:that.file_path}) layer.msg(res.msg,{icon:res.status?1:2}) }); }); }else{ bt.show_confirm('Delete '+ data.type_tips +'[ '+ data.filename +' ]','Recycle bin is not currently open, delete '+ (data.type == 'dir'?'directory':'file') +' cannot be restored after, continue?',function(){ that.del_file_req(data,function(res){ that.reader_file_list({path:that.file_path}) layer.msg(res.msg,{icon:res.status?1:2}) }); }) } }, /** * @description 取消文件收藏 * @param {Object} data 当前文件的数据对象 * @param {Object} el 当前元素对象 * @returns void */ cancel_file_favorites:function(data){ var that = this,index = data.index; this.loadY = bt.confirm({title:data['filename'] +lan.files.unfavorite1, msg:lan.files.unfavorite1+' ['+ data['path'] + '] ' + lan.files.continue},function(){ that.$http('del_files_store',{path:data.path},function(res){ if(res.status){ that.file_list[index].caret = false; that.reader_file_list_content(that.file_list); that.load_favorites_index_list(); } layer.msg(res.msg,{icon:res.status?1:2}) }) }); }, /** * @description 创建软链接 * @param {Object} data 当前文件的数据对象 */ set_soft_link:function(data){ var that = this; bt_tools.open({ title:'Create Softlink', area:'520px', content:{ class:'pd20', formLabelWidth:'110px', form:[{ label:'Source file', group:{ type:'text', name:'sfile', width:'280px', placeholder:'Please select the folder and file to be linked', icon:{type:'glyphicon-folder-open',event:function(ev){},select:'all'}, value:'', input:function(ev){} } },{ label: "Softlink name", group: { type: "text", name: "name", width: "280px", placeholder: "Please enter the name of the softlink", value: "" } }] }, init: function() { var e = null, t = setInterval(function() { if ($('input[name="sfile"]').length < 1 && clearInterval(t),e != $('input[name="sfile"]').val()){ e = $('input[name="sfile"]').val(); var i = e.split("/"); i.length > 1 && $('[name="name"]').val(i[i.length - 1]) } }, 100) }, yes:function(e, i, a){ e = $.extend(e, {dfile: that.file_path + "/" + e.name}), delete e.name, bt_tools.send("files/CreateLink", e, function(e) { e.status && (layer.close(i), bt.msg(e), that.reader_file_list()) }, { tips: "Create Softlink" }) } }); }, /** * @description 设置文件权限 - ok * @param {Object} data 当前文件的数据对象 * @param {Boolean} isPatch 是否多选 * @returns void */ set_file_authority:function(data,isPatch){ var that = this; that.get_file_authority({path:data.path},function(rdata){ var tex = '
      \ \ \ \
      \ \
      '; that.loadY = layer.open({ type: 1, closeBtn: 2, title: lan.files.set_auth + '[' + data.filename + ']', area: '465px', shadeClose: false, content: '
      \
      \
      Set permission
      \
      Backups list
      \
      \
      ' + tex + '\
      \ '+ lan.files.file_own + '\

      '+ lan.files.file_read + '

      \

      '+ lan.files.file_write + '

      \

      '+ lan.files.file_exec + '

      \
      \
      \ '+ lan.files.file_group + '\

      '+ lan.files.file_read + '

      \

      '+ lan.files.file_write + '

      \

      '+ lan.files.file_exec + '

      \
      \
      \ '+ lan.files.file_public + '\

      '+ lan.files.file_read + '

      \

      '+ lan.files.file_write + '

      \

      '+ lan.files.file_exec + '

      \
      \
      ' + lan.files.file_menu_auth + ',\ '+ lan.files.file_own + '\ \ \
      \
      \
      \
      \ \ \
      \
      ', success: function (index,layers) { that.edit_access_authority(); $("#access").keyup(function () { that.edit_access_authority(); }); $("input[type=checkbox]").change(function () { var idName = ['owner', 'group', 'public']; var onacc = ''; for (var n = 0; n < idName.length; n++) { var access = 0; access += $("#" + idName[n] + "_x").prop('checked') ? 1 : 0; access += $("#" + idName[n] + "_w").prop('checked') ? 2 : 0; access += $("#" + idName[n] + "_r").prop('checked') ? 4 : 0; onacc += access; } $("#access").val(onacc); }); //提交 $('.set_access_authority').click(function(){ var chmod = $("#access").val(); var chown = $("#chown").val(); var all = $("#accept_all").prop("checked") ? 'True' : 'False'; var _form = {} _form = { user:chown, access:chmod, all:all } if(isPatch){ _form['type'] = data.type _form['path'] = data.path _form['data'] = data.filelist }else{ _form['filename'] = data.path } that.$http(isPatch?'SetBatchData':'SetFileAccess',_form,function(res){ if (res.status){ layer.close(layers); that.reader_file_list({path:that.file_path,is_operating:false} )} layer.msg(res.msg, { icon: res.status ? 1 : 2 }); }) }) $('.layer_close').click(function () { layer.close(layers); }); that.$http('get_path_premissions',{path: data.path},function(edata){ if(edata.length == 0) $('.backuptip').text('No backup'); }); $('button.restore').click(function () { that.backup_files_permission(data.path,1); }); $(".tolist").click(function () { $(".backup-list").click(); }); $(".bt_tab_list .bt_tab_index").click(function () { $(this).addClass('active').siblings().removeClass('active'); if($(this).index()==0){ $('.backup_lists').empty(); $('.chmodset').show(); }else{ that.backup_files_list(data.path); } }); } }); }); }, /** * @description 备份权限弹窗 * @returns void */ backup_files_permission:function(file, type){ //文件夹type为0 var sub_type = 1; if (type == 1) { sub_type = $("#accept_all").prop("checked") ? 1 : 0; } // if (file == '' || typeof (file) == 'undefined') { // layer.msg('Please select a directory or file', { // icon: 2, // time: 1900 // }); // return false; // } var that = this; var layerss = layer.open({ type: 1, closeBtn: 2, title: 'Confirm backup?', area: '300px', shadeClose: false, btn: ['Yes', 'No'], content: '
      \

      Please enter the current backup name

      \
      Remarks\ \
      \
      ', yes: function (layerss, index) { $('.layer_close').click(function () { layer.close(index); }); that.$http('back_path_permissions',{back_sub_dir: sub_type,path: file,remark: $("input.form-control").val()},function(edata){ layer.close(layerss); if (!edata.status) { layer.msg(edata.msg, { time: 1900, icon: 2, }); return false; } if (type == 0) { var new_back = that.backup_list(); $(".buplist").html(new_back); } else if (type == 3) { var chmod = $("#access").val(); var chown = $("#chown").val(); var all = $("#accept_all").prop("checked") ? 'True' : 'False'; var data = 'filename=' + encodeURIComponent(file) + '&user=' + chown + '&access=' + chmod + '&all=' + all; Oksend(data); layer.closeAll(); } layer.msg(edata.msg, { time: 1900, icon: 1, }); }); }, btn2: function () { layer.close(layerss); }, cancel: function () { layer.close(layerss); } }); }, /** * @description 全部备份权限列表 * @returns void */ backup_list:function(){ var all_back = '',that = this; that.$http('get_all_back',function(edata){ for (var i = 0; i < edata.length; i++) { var d = new Date(edata[i][2] * 1000); var minut = d.getMinutes(); var hours = d.getHours(); var second = d.getSeconds(); if (minut <= 9) minut = '0' + minut + ''; if (hours <= 9) hours = '0' + hours + ''; if (second <= 9) second = '0' + second + ''; var date = (d.getFullYear()) + "/" + (d.getMonth() + 1) + "/" + (d.getDate()) + " " + (hours) + ":" + (minut) + ":" + (second); all_back += '\ ' + date + '\ \ ' + edata[i][3] + '\ \ ' + edata[i][1] + '\ Del\ '; } $(".allback .buplist").html(all_back); }); }, /** * @description 全部备份权限弹窗 * @returns void */ manage_backup:function(){ var that = this; var layerss = layer.open({ type: 1, closeBtn: 2, title: 'Manage Backups', area: ['630px', '500px'], shadeClose: false, content: '
      \
      \ \
      \ \ \
      \
      \ \ \ \ \ \ \ \ \ \
      Backup timeBackup pathNameDelect
      \
      \ \ \
      \
      \
      ', cancel: function () { layer.close(layerss); }, success: function () { that.backup_list() $("#btn-backup").click(function (e) { var backup_path = $("#server_path").val(); that.backup_files_permission(backup_path,0); }); $(".allback").on('click', '.del_back', function () { var _id = $(this).parents('tr').attr('data-id'); that.del_backup(_id); }); } }); }, /** * @description 删除备份 * @returns void */ del_backup:function(id){ var that = this; layer.confirm('The backup cannot be restored after deletion.
      Continue to delete?',{title: 'Confirm delete?',btn: ['Yes', 'No'],closeBtn:2},function(index, layero){ that.$http('del_path_premissions',{id: id},function(edata){ var file = $(".layui-layer-title:eq(0)").text(); if(file!=='Manage Backups'){ file = $(".backup_list").attr('data-path'); that.backup_files_list(file); }else{ $(".allback tbody tr[data-id=" + id + "]").remove(); } layer.msg(edata.msg, { icon: edata.status ? 1 : 2 }); }); }); }, /** * @description 本文件备份列表 * @returns void */ backup_files_list:function(fileName){ var that = this; that.$http('get_path_premissions',{path: fileName},function(edata){ var tbody = '',cont=''; if(edata.length==0){ tbody='No data' }else{ for (var i = 0; i < edata.length; i++) { var d = new Date(edata[i][3] * 1000), minut = d.getMinutes(), hours = d.getHours(); if (minut <= 9) minut = '0' + minut + ''; if (hours <= 9) hours = '0' + hours + ''; var date = (d.getFullYear()) + "/" + (d.getMonth() + 1) + "/" + (d.getDate()); tbody += '\ '+edata[i][4]+'\ '+edata[i][2]+'\ '+edata[i][1]+'\ '+date+'\ Restore | Del\ '; } } cont = '
      \
      \ \ Fix all permissions to [ Folder: 755, File: 644 ]\ \
      \ \ \ \ \ \ \ \ \ \ \ \ '+tbody+'\ \
      NamepermissionOwnerBackup TimeOpt
      \
      '; $('.chmodset').hide(); $('.backup_lists').html(cont); $(".fixper").click(function () { layer.confirm('Note: Under the file or folder all permissions will be fixed to [ Folder: 755, File: 644 ]', {title: 'Fix Permissions?',btn: ['Confirm', 'Cancel'],closeBtn:2},function(index, layero){ that.$http('fix_permissions',{path: fileName},function(res){ layer.closeAll(); that.reader_file_list({path:that.file_path,is_operating:false}); layer.msg(res.msg, { icon: res.status ? 1 : 2 }); }); }); }); $(".restore_backup").click(function () { that.restore_file_permission($(this).attr('data-time'),fileName); }); $(".backup_list").on('click', '.del_back', function () { var _id = $(this).attr('data-id'); that.del_backup(_id); }); }); }, /** * @description 权限备份的还原 * @returns void */ restore_file_permission:function(restore_time,fileName){ var that = this, sub_type = $("#accept_all").prop("checked") ? 1 : 0; var layerss = layer.open({ type: 1, closeBtn: 2, title: 'Confirm restore', area: '330px', shadeClose: false, btn: ['Yes', 'No'], content: '
      \ Restore would overwrite the current settings, continue?\
      ', yes: function (layerss, index) { that.$http('restore_path_permissions',{restore_sub_dir: sub_type,date: restore_time,path: fileName},function(edata){ layer.closeAll(); layer.msg(edata.msg, { icon: 1, time: 1900 }); }); }, btn2: function () { layer.close(layerss); }, cancel: function () { layer.close(layerss); } }); }, /** * @description 获取实时任务视图 * @returns void */ get_present_task_view:function(){ this.file_present_task = layer.open({ type: 1, title: "Real-time task queue", area: '500px', closeBtn: 2, skin:'present_task_list', shadeClose: false, shade: false, offset: 'auto', content: '
      ' }) }, /** * @description 渲染实时任务列表数据 * @returns void */ render_present_task_list:function(){ var that = this; this.get_task_req({status:-3},function(lists){ if(lists.length == 0){ layer.close(that.file_present_task) that.file_present_task = null; that.reader_file_list({path:that.file_path,is_operating:false}) return } var task_body = '',is_add = false; $.each(lists,function(index,item){ if(item.status == -1){ if(!that.file_present_task) that.get_present_task_view(); if(item.type == '1'){ task_body +='
      \
        \
      • \
        '+lan.layout.download + item.shell + '' + item.log.pre + '%'+lan.public.cancel+'
        \
        \
        '+ item.log.used + '/' + ToSize(item.log.total) + '' + (item.log.speed == 0 ? lan.layout.connect : item.log.speed) + '/s'+lan.files.expected_to_be+': ' + item.log.time +'
        \
      • \
      \
      ' }else{ task_body += '
      ' + item.name + ': ' + item.shell + ''+lan.public.cancel+'
      \
      \ '+ item.log +'\
      ' } }else{ if (!is_add) { task_body += '
      '+lan.layout.wait_task+'
        '; is_add = true; } task_body += '
      • ' + item.name + ': ' + item.shell + 'X
      • '; } }) if(that.file_present_task){ if(is_add) task_body+= '
      ' $(".message-list").html(task_body); } setTimeout(function () { that.render_present_task_list(); }, 1000); }) }, /** * @description 取消实时任务列表 * @returns void */ remove_present_task:function(id){ var that = this; layer.confirm('Do you want to cancel the current task queue?', { title: 'Cancel task queue', icon: 0 }, function (indexs) { layer.close(indexs); var loadT = bt.load('Canceling task...'); $.post('/task?action=remove_task', { id: id }, function(rdata) { loadT.close() bt.msg(rdata); }); }); }, /** * @descripttion 设置访问权限 * @returns void */ edit_access_authority:function(){ var access = $("#access").val(); var idName = ['owner', 'group', 'public']; for (var n = 0; n < idName.length; n++) { $("#" + idName[n] + "_x").prop('checked', false); $("#" + idName[n] + "_w").prop('checked', false); $("#" + idName[n] + "_r").prop('checked', false); } for (var i = 0; i < access.length; i++) { var onacc = access.substr(i, 1); if (i > idName.length) continue; if (onacc > 7) $("#access").val(access.substr(0, access.length - 1)); switch (onacc) { case '1': $("#" + idName[i] + "_x").prop('checked', true); break; case '2': $("#" + idName[i] + "_w").prop('checked', true); break; case '3': $("#" + idName[i] + "_x").prop('checked', true); $("#" + idName[i] + "_w").prop('checked', true); break; case '4': $("#" + idName[i] + "_r").prop('checked', true); break; case '5': $("#" + idName[i] + "_r").prop('checked', true); $("#" + idName[i] + "_x").prop('checked', true); break; case '6': $("#" + idName[i] + "_r").prop('checked', true); $("#" + idName[i] + "_w").prop('checked', true); break; case '7': $("#" + idName[i] + "_r").prop('checked', true); $("#" + idName[i] + "_w").prop('checked', true); $("#" + idName[i] + "_x").prop('checked', true); break; } } }, /** * @description 获取文件权限 - ok * @param {Object} data 当前文件的数据对象 * @param {Object} el 当前元素对象 * @returns void */ get_file_authority:function(data,callback){ this.$http('GetFileAccess',{filename:data.path},function(rdata){if(callback) callback(rdata)}); }, /** * @description 文件夹目录查杀 * @param {Object} data 当前文件的数据对象 * @returns void */ set_dir_kill:function(data){ var that = this; if(data.ext == 'php'){ that.$http('file_webshell_check',{filename:data.path},function(rdata){ layer.msg(rdata.msg,{icon:rdata.status?1:2}) }) }else{ layer.confirm('目录查杀将包含子目录中的php文件,是否操作?', { title: '目录查杀['+data['filename']+']', closeBtn: 2, icon: 3 }, function (index) { that.$http('dir_webshell_check',{path:data.path},function(rdata){ layer.msg(rdata.msg,{icon:rdata.status?1:2}) }) }) } }, /** * @description 文件路径合并 * @param {String} paths 旧路径 * @param {String} param 新路径 * @return {String} 新的路径 */ path_resolve:function(paths, param){ var path = '',split = ''; if(!Array.isArray(param)) param = [param]; paths.replace(/([\/|\/]*)$/,function($1){ split = $1; return 'www'; }); $.each(param,function(index,item){ path += '/' + item; }); return (paths+path).replace('//','/'); }, /** * @descripttion 取扩展名 * @return: 返回扩展名 */ get_ext_name:function(fileName){ var extArr = fileName.split("."); var exts = ["folder", "folder-unempty", "sql", "c", "cpp", "cs", "flv", "css", "js", "htm", "html", "java", "log", "mht", "php", "url", "xml", "ai", "bmp", "cdr", "gif", "ico", "jpeg", "jpg", "JPG", "png", "psd", "webp", "ape", "avi", "mkv", "mov", "mp3", "mp4", "mpeg", "mpg", "rm", "rmvb", "swf", "wav", "webm", "wma", "wmv", "rtf", "docx", "fdf", "potm", "pptx", "txt", "xlsb", "xlsx", "7z", "cab", "iso", "rar", "zip", "gz", "bt", "file", "apk", "bookfolder", "folder-empty", "fromchromefolder", "documentfolder", "fromphonefolder", "mix", "musicfolder", "picturefolder", "videofolder", "sefolder", "access", "mdb", "accdb", "fla", "doc", "docm", "dotx", "dotm", "dot", "pdf", "ppt", "pptm", "pot", "xls", "csv", "xlsm"]; var extLastName = extArr[extArr.length - 1]; for(var i=0; i'); }, yes:function(){ var ress = form.getVal(); if(ress.dfile == '') return layer.msg('Please select a valid address',{icon:2}) form.submitForm(function(res,datas){ setTimeout(function(){ that.reader_file_list({path:datas.path}) }, 1000); if(res == null || res == undefined){ layer.msg(lan.files.zip_ok, { icon: 1 }); } if(res.status){ that.render_present_task_list(); } layer.close(loadT) }) } }) }) }, /** * @description 文件、文件夹解压 * @param {*} data 文件目录参数 */ unpack_file_to_path:function(data){ var that = this,_type = 'zip',spath = ''; spath = data.path.substring(0,data.path.lastIndexOf('\/')) this.reader_form_line({ url: 'UnZip', overall: {width: '310px'}, data:[ {label:'File name',name:'z_name',placeholder:'Compress file name',value:data.path}, {label:'Compress path',name:'z_path',placeholder:'Compress path',value:spath}, {label:'Encoding',name:'z_code',type:'select',value:'UTF-8',list:[ ['UTF-8','UTF-8'], ['gb18030','GBK'] ]} ], beforeSend:function(updata){ return {sfile:updata.z_name,dfile:updata.z_path,type:_type,coding:updata.z_code,password:updata.z_password} } },function(form,html){ var loadT = layer.open({ type:1, title:'Decompress file', area: '520px', shadeClose: false, closeBtn:2, skin:'unpack_file_view', btn:['Confirm','Cancel'], content: html[0].outerHTML, success:function(){ if(data.ext == 'gz') _type = 'tar' //解压格式 if(_type == 'zip') { // 判断是否插入解压密码 $('.unpack_file_view .line:nth-child(2)').append('
      Password
      ') } }, yes:function(){ var ress = form.getVal(); if(ress.z_name == '') return layer.msg('Please enter the file name path',{icon:2}) if(ress.z_path == '') return layer.msg('Please enter the decompression address',{icon:2}) form.submitForm(function(res,datas){ layer.close(loadT) setTimeout(function(){ that.reader_file_list({path:datas.path}) }, 1000); if(res.status){ that.render_present_task_list(); } layer.msg(res.msg,{icon:res.status?1:2}) }) } }) }) }, /** * @description 匹配非法字符 * @param {Array} item 配置对象 * @return 返回匹配结果 */ match_unqualified_string:function(item){ var containSpecial = RegExp(/[(\*)(\|)(\\)(\:)(\")(\/)(\<)(\>)(\?)(\)]+/); return containSpecial.test(item) }, /** * @description 渲染表单 * @param {Array} config 配置对象 * @param {Function} callback 回调函数 * @return void */ reader_form_line:function(config,callback){ var that = this,random = bt.get_random(10),html = $(''),data = config,eventList = [],that = this; if(!Array.isArray(config)) data = config.data; $.each(data,function(index,item){ var labelWidth = item.labelWidth || config.overall.labelWidth || null,event_random = bt.get_random(10), width = item.labelWidth || config.overall.width || null, form_line = $('
      '+ (item.label || '') +'
      '), form_el = $((function(){ switch(item.type){ case 'select': return ''; break; case 'text': default: return ''; break; } }(item))); if(item.eventType || item.event){ if(!Array.isArray(item.eventType)) item.eventType = [item.eventType]; $.each(item.eventType,function(index,items){ eventList.push({el:event_random,type:items || 'click',event:item[items] || null}); if(config.el){ var els = $('[data-event="'+ item.el +'"]'); if(item[items]){ if(items == 'enter'){ els.on('keyup',function(e){ if(e.keyCode == 13) item.event(e) }) }else{ els.on(item || 'click',item.event); } }else{ if(items == 'focus'){ var vals = els.val(); if(vals != ''){ els.val('').focus().val(vals); } }else{ els[items](); } } } }); } form_line.find('.info-r').append(form_el) html.append(form_line); }); if(config.el) $(config.el).empty().append(html); if(callback) callback({ // 获取内容 getVal:function(){ return $('#'+random).serializeObject(); }, // 设置事件,没有设置el参数,需要 setEvent:function(){ $.each(eventList,function(index,item){ var els = $('[data-event="'+ item.el +'"]'); if(item.event === null){ if(item.type == 'focus'){ var vals = els.val(); if(vals != ''){ els.val('').focus().val(vals); } }else{ els[item.type](); } }else{ if(item.type == 'enter'){ els.on('keyup',function(e){ if(e.keyCode == 13) item.event(e) }) }else{ els.on(item.type,item.event); } } }); }, // 提交表单 submitForm:function(callback){ var data = this.getVal(); if(config.beforeSend) data = config.beforeSend(data); that.loadT = bt.load('submitting the form, please wait...'); bt.send(config.url,('files/'+config.url),data,function(rdata){ that.loadT.close(); if(callback) callback(rdata,data) }) } },html); }, /** * @description 文件管理请求方法 * @param {*} data * @param {*} data * @param {*} callback */ $http:function(data,parem,callback){ var that = this,loadT = ''; if(typeof data == "string"){ if(typeof parem != "object") callback = parem,parem = {}; if(!Array.isArray(that.method_list[data])) that.method_list[data] = ['files',that.method_list[data]]; that.$http({method:data,tips:(that.method_list[data][1]?that.method_list[data][1]:false),module:that.method_list[data][0],data:parem,msg:true},callback); }else { if(typeof data.tips != 'undefined' && data.tips) loadT = bt.load(data.tips); bt.send(data.method,(data.module || 'files') +'/' + data.method,data.data || {},function(res){ if(loadT != '') loadT.close(); if(typeof res == "string") res = JSON.parse(res); if(res.status === false && res.msg){ bt.msg(res); return false; } if(parem) parem(res) }); } } } bt_file.init(); Function.prototype.delay = function(that,arry,time){ if(!Array.isArray(arry)) time = arry,arry = []; if(typeof time == "undefined") time = 0; setTimeout(this.apply(that,arry),time); return this; } jQuery.prototype.serializeObject = function () { var a,o,h,i,e; a = this.serializeArray(); o={}; h=o.hasOwnProperty; for(i=0;i