From 1360d2d0663cd9e5933b9eb57cd249f6f64c0030 Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Wed, 25 Dec 2024 21:19:53 +0800 Subject: [PATCH 1/2] Update files.js --- web/static/app/files.js | 66 ++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 34 deletions(-) diff --git a/web/static/app/files.js b/web/static/app/files.js index 75f1f79abc..d126a4c00b 100755 --- a/web/static/app/files.js +++ b/web/static/app/files.js @@ -156,14 +156,14 @@ function recycleBin(type){ var tablehtml = '
\
\ - 文件回收站\ -
\ - \ - \ -
\ -
\ + 文件回收站\ +
\ + \ + \ +
\ +
\ 注意:关闭回收站,删除的文件无法恢复!\ - \ + \ \
\
\ @@ -290,7 +290,7 @@ function openFilename(obj){ } if (inArray(ext,['png','jpeg','jpg','gif','webp','bmp','ico'])){ - getImage(path); + getImage(path); } if (inArray(ext,['svg'])){ @@ -303,19 +303,19 @@ function openFilename(obj){ maxmin:true, shadeClose: true, content: '' + src="'+url+'"\ + frameborder="0"\ + border="0"\ + marginwidth="0"\ + marginheight="0"\ + scrolling="yes"\ + noresize=""\ + allowfullscreen="allowfullscreen"\ + mozallowfullscreen="mozallowfullscreen"\ + msallowfullscreen="msallowfullscreen"\ + oallowfullscreen="oallowfullscreen"\ + webkitallowfullscreen="webkitallowfullscreen"\ + allowfullscreen="true">' }); } } @@ -374,16 +374,15 @@ function getFiles(Path) { Path = getCookie('open_dir_path'); } - var args = {}; - args['p'] = p; var post = {}; post['path'] = Path; + post['p'] = p; var file_row = $.cookie('file_row'); if(!file_row) { file_row = '100'; } - args['row'] = file_row; + post['row'] = file_row; var body = ''; var totalSize = 0; @@ -392,13 +391,13 @@ function getFiles(Path) { var search_file = $("#search_file").val(); if(search_file.length > 0){ - args['search'] = search_file; + post['search'] = search_file; } var search_all = ''; var all = $('#search_all').hasClass('active'); if(all){ - args['all'] = 'yes'; + post['all'] = 'yes'; } var file_order = $.cookie('file_order'); @@ -406,10 +405,9 @@ function getFiles(Path) { post['order'] = file_order.replace('|',' '); } - var query_str = toUrlParam(args); var loadT = layer.load(); - $.post('/files/get_dir?' + query_str, post, function(rdata) { + $.post('/files/get_dir', post, function(rdata) { layer.close(loadT); //构建分页 @@ -1428,9 +1426,9 @@ function isCompressFile(fileName){ var extName = ext[ext.length-1].toLowerCase(); var support = ['zip','gz','tgz','rar']; for (x in support) { - if (support[x]==extName){ - return true; - } + if (support[x]==extName){ + return true; + } } return false; } @@ -1638,8 +1636,8 @@ function setChmod(action,fileName){
\
\ \ - \ -
\ + \ +
\ ' }); @@ -1717,7 +1715,7 @@ function rightMenuClick(type,path,name){ {text: "剪切", onclick: function() {cutFile(path)}}, {text: "重命名", onclick: function() {reName(0,name)}}, {text: lan.files.file_menu_auth, onclick: function() {setChmod(0,path)}}, - {text: lan.files.file_menu_zip, onclick: function() {zip(path)}}, + {text: lan.files.file_menu_zip, onclick: function() {zip(path)}}, ]}; if(type == "dir"){ options.items.push({text: lan.files.file_menu_del, onclick: function() { From 41c048594e6587c0d782fc91057b8735349d098d Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Wed, 25 Dec 2024 21:21:54 +0800 Subject: [PATCH 2/2] Update files.js --- web/static/app/files.js | 3274 +++++++++++++++++++-------------------- 1 file changed, 1637 insertions(+), 1637 deletions(-) diff --git a/web/static/app/files.js b/web/static/app/files.js index d126a4c00b..c42c81f6bf 100755 --- a/web/static/app/files.js +++ b/web/static/app/files.js @@ -1,1860 +1,1860 @@ //判断磁盘数量超出宽度 function isDiskWidth(){ - var comlist_width = $("#comlist").width(); - var body_width = $(".file-box").width(); - $("#comlist").css({"width":(body_width-520)+"px","height":"34px","overflow":"auto"}); + var comlist_width = $("#comlist").width(); + var body_width = $(".file-box").width(); + $("#comlist").css({"width":(body_width-520)+"px","height":"34px","overflow":"auto"}); } //打开回收站 function recycleBin(type){ - $.post('/files/get_recycle_bin','',function(data){ - // console.log(rdata); - var rdata = data['data']; - var body = '' - switch(type){ - case 1: - for(var i=0;i 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 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 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 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 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 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; - } - - - var tablehtml = '
\ -
\ - 文件回收站\ -
\ - \ - \ -
\ -
\ - 注意:关闭回收站,删除的文件无法恢复!\ - \ -
\ -
\ -
\ -

全部

\ -

文件夹

\ -

文件

\ -

图片

\ -

文档

\ -
\ -
\ -
\ - \ - \ - \ - \ - \ - \ - \ - \ - '+body+'\ -
文件名原位置大小删除时间操作
'; - if(type == 'open'){ - layer.open({ - type: 1, - shift: 5, - closeBtn: 1, - area: ['80%','606px'], - title: lan.files.recycle_bin_title, - content: tablehtml - }); - - if(window.location.href.indexOf("database") != -1){ - recycleBin(6); - $(".re-con-menu p:last-child").addClass("on").siblings().removeClass("on"); - }else{ - recycleBin(1); - } - } - $(".re-con-menu p").click(function(){ - $(this).addClass("on").siblings().removeClass("on"); - }) - },'json'); + $.post('/files/get_recycle_bin','',function(data){ + // console.log(rdata); + var rdata = data['data']; + var body = '' + switch(type){ + case 1: + for(var i=0;i 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 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 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 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 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 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; + } + + + var tablehtml = '
\ +
\ + 文件回收站\ +
\ + \ + \ +
\ +
\ + 注意:关闭回收站,删除的文件无法恢复!\ + \ +
\ +
\ +
\ +

全部

\ +

文件夹

\ +

文件

\ +

图片

\ +

文档

\ +
\ +
\ +
\ + \ + \ + \ + \ + \ + \ + \ + \ + '+body+'\ +
文件名原位置大小删除时间操作
'; + if(type == 'open'){ + layer.open({ + type: 1, + shift: 5, + closeBtn: 1, + area: ['80%','606px'], + title: lan.files.recycle_bin_title, + content: tablehtml + }); + + if(window.location.href.indexOf("database") != -1){ + recycleBin(6); + $(".re-con-menu p:last-child").addClass("on").siblings().removeClass("on"); + }else{ + recycleBin(1); + } + } + $(".re-con-menu p").click(function(){ + $(this).addClass("on").siblings().removeClass("on"); + }) + },'json'); } //去扩展名不处理 function getFileName(name){ - var text = name.split("/"); - var n = text.length-1; - text = text[n]; - return text; + 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正在删除,请稍候...",{icon:16,time:0,shade: [0.3, '#000']}); - setTimeout(function(){ - getSpeed('.myspeed'); - },1000); - $.post('/files/close_recycle_bin', '', function(rdata){ - layer.close(loadT); - layer.msg(rdata.msg,{icon:rdata.status?1:5}); - $("#RecycleBody").html(''); - },'json'); - }); + layer.confirm('清空回收站操作会永久删除回收站中的文件,继续吗?',{title:'清空回收站',closeBtn:2,icon:3},function(){ + var loadT = layer.msg("
正在删除,请稍候...
",{icon:16,time:0,shade: [0.3, '#000']}); + setTimeout(function(){ + getSpeed('.myspeed'); + },1000); + $.post('/files/close_recycle_bin', '', function(rdata){ + layer.close(loadT); + layer.msg(rdata.msg,{icon:rdata.status?1:5}); + $("#RecycleBody").html(''); + },'json'); + }); } //回收站开关 function setRecycleBin(db){ - var loadT = layer.msg('正在处理,请稍候...',{icon:16,time:0,shade: [0.3, '#000']}); - var data = {} - if(db == 1){ - data = {db:db}; - } - $.post('/files/recycle_bin',data,function(rdata){ - layer.close(loadT); - layer.msg(rdata.msg,{icon:rdata.status?1:5}); - },'json'); + var loadT = layer.msg('正在处理,请稍候...',{icon:16,time:0,shade: [0.3, '#000']}); + var data = {} + if(db == 1){ + data = {db:db}; + } + $.post('/files/recycle_bin',data,function(rdata){ + layer.close(loadT); + layer.msg(rdata.msg,{icon:rdata.status?1:5}); + },'json'); } function openFilename(obj){ - var path = $(obj).attr('data-path'); - var ext = getSuffixName(path); - - // console.log(path,ext); - if (inArray(ext,['html','htm','php','txt','md','js','css','scss','json','c','h','pl','py','java','log','conf','sh','json','ini'])){ - onlineEditFile(0, path); - } - - if (inArray(ext,['png','jpeg','jpg','gif','webp','bmp','ico'])){ - getImage(path); - } - - if (inArray(ext,['svg'])){ - var url = '/files/download?filename='+path; - layer.open({ - type:1, - closeBtn: 1, - title:"SVG预览", - area: ['600px','500px'], - maxmin:true, - shadeClose: true, - content: '' - }); - } + var path = $(obj).attr('data-path'); + var ext = getSuffixName(path); + + // console.log(path,ext); + if (inArray(ext,['html','htm','php','txt','md','js','css','scss','json','c','h','pl','py','java','log','conf','sh','json','ini'])){ + onlineEditFile(0, path); + } + + if (inArray(ext,['png','jpeg','jpg','gif','webp','bmp','ico'])){ + getImage(path); + } + + if (inArray(ext,['svg'])){ + var url = '/files/download?filename='+path; + layer.open({ + type:1, + closeBtn: 1, + title:"SVG预览", + area: ['600px','500px'], + maxmin:true, + shadeClose: true, + content: '' + }); + } } function searchFile(p){ - getFiles(p); + getFiles(p); } //处理排序 function listFileOrder(skey, obj){ - var or = getCookie('file_order'); - var orderType = 'desc'; - if(or){ - var or_arr = or.split('|'); - if(or.split('|')[1] == 'desc'){ - orderType = 'asc'; - } else if (or_arr[1] == 'asc'){ - orderType = 'none'; - } else { - orderType = 'desc'; - } - } - setCookie('file_order',skey + '|' + orderType); - getFiles(1); - // console.log(obj,orderType); - // if(orderType == 'desc'){ - // $(obj).find(".glyphicon-triangle-top").remove(); - // $(obj).append(""); - // } else { - // $(obj).find(".glyphicon-triangle-bottom").remove(); - // $(obj).append(""); - // } + var or = getCookie('file_order'); + var orderType = 'desc'; + if(or){ + var or_arr = or.split('|'); + if(or.split('|')[1] == 'desc'){ + orderType = 'asc'; + } else if (or_arr[1] == 'asc'){ + orderType = 'none'; + } else { + orderType = 'desc'; + } + } + setCookie('file_order',skey + '|' + orderType); + getFiles(1); + // console.log(obj,orderType); + // if(orderType == 'desc'){ + // $(obj).find(".glyphicon-triangle-top").remove(); + // $(obj).append(""); + // } else { + // $(obj).find(".glyphicon-triangle-bottom").remove(); + // $(obj).append(""); + // } } function makeFilePage(showRow, page = ''){ - var rows = ['10','50','100','200','500','1000','2000']; - var rowOption = ''; - for(var i=0;i'+rows[i]+''; - } - - //分页 - $("#filePage").html(page); - $("#filePage div").append("每页"); - $("#filePage .Pcount").css("left","16px"); + var rows = ['10','50','100','200','500','1000','2000']; + var rowOption = ''; + for(var i=0;i'+rows[i]+''; + } + + //分页 + $("#filePage").html(page); + $("#filePage div").append("每页"); + $("#filePage .Pcount").css("left","16px"); } //取数据 function getFiles(Path) { - if(isNaN(Path)){ - var p = 1; - } else { - var p = Path; - Path = getCookie('open_dir_path'); - } - - var post = {}; - post['path'] = Path; - post['p'] = p; - - var file_row = $.cookie('file_row'); - if(!file_row) { - file_row = '100'; - } - post['row'] = file_row; - - var body = ''; - var totalSize = 0; - - var search = ''; - var search_file = $("#search_file").val(); - - if(search_file.length > 0){ - post['search'] = search_file; - } - - var search_all = ''; - var all = $('#search_all').hasClass('active'); - if(all){ - post['all'] = 'yes'; - } - - var file_order = $.cookie('file_order'); - if (file_order){ - post['order'] = file_order.replace('|',' '); - } - - - var loadT = layer.load(); - $.post('/files/get_dir', post, function(rdata) { - layer.close(loadT); - - //构建分页 - makeFilePage(file_row,rdata.page); - - if(rdata.dir == null) { - rdata.dir = []; - } - - for (var i = 0; i < rdata.dir.length; i++) { - var fmp = rdata.dir[i].split(";"); - var cnametext =fmp[0] + fmp[5]; - - fmp[0] = fmp[0].replace(/'/, "\\'"); - if(cnametext.length>20){ - cnametext = cnametext.substring(0,20) + '...'; - } - - if(isChineseChar(cnametext)){ - if(cnametext.length>10){ - cnametext = cnametext.substring(0,10) + '...'; - } - } - - var timetext ='--'; - if(getCookie('rank') == 'a'){ - //列表展示 - $("#set_list").addClass("active"); - $("#set_icon").removeClass("active"); - body += "\ - \ - \ - " + cnametext + "\ - "+toSize(fmp[1])+"\ - "+getLocalTime(fmp[2])+"\ - "+fmp[3]+"\ - "+fmp[4]+"\ - \ - 复制 | \ - 剪切 | \ - 重命名 | \ - 权限 | \ - 压缩 | \ - 删除\ - \ - "; - } else { - //图标展示 - $("#set_icon").addClass("active"); - $("#set_list").removeClass("active"); - body += ""; - } - } - - for (var i = 0; i < rdata.files.length; i++) { - if(rdata.files[i] == null) continue; - var fmp = rdata.files[i].split(";"); - var bodyZip = ''; - var download = ''; - var cnametext =fmp[0] + fmp[5]; - fmp[0] = fmp[0].replace(/'/,"\\'"); - - if(isChineseChar(cnametext)){ - if(cnametext.length>16){ - cnametext = cnametext.substring(0,16) + '...'; - } - } else{ - if( cnametext.length > 48 ){ - cnametext = cnametext.substring(0,48) + '...'; - } - } - - var displayCompress = 1; - if(isCompressFile(fmp[0])){ - bodyZip = "解压 | "; - } - - if(isText(fmp[0])){ - bodyZip = "编辑 | "; - } - - if(isImage(fmp[0])){ - download = "预览 | "; - } else { - download = "下载 | "; - } - - totalSize += parseInt(fmp[1]); - if(getCookie("rank")=="a"){ - body += "\ - \ - " + cnametext + "\ - " + (toSize(fmp[1])) + "\ - " + ((fmp[2].length > 11)?fmp[2]:getLocalTime(fmp[2])) + "\ - "+fmp[3]+"\ - "+fmp[4]+"\ - \ - 复制 | \ - 剪切 | \ - 重命名 | \ - 权限 | \ - 压缩 | " - + bodyZip - + download - + "删除\ - \ - "; - } - else{ - body += ""; - } - } - var dirInfo = '(共{1}个目录与{2}个文件,大小:'.replace('{1}',rdata.dir.length+'').replace('{2}',rdata.files.length+'')+'' - + (toSize(totalSize))+'获取)'; - $("#dir_info").html(dirInfo); - if( getCookie('rank') == 'a' ){ - - // console.log(post['order']); - var size_icon = ''; - if (post['order'] == 'size desc'){ - size_icon = ''; - } else if (post['order'] == 'size asc'){ - size_icon = ''; - } else { - size_icon = ''; - } - - var mtime_icon = ''; - if (post['order'] == 'mtime desc'){ - mtime_icon = ''; - } else if (post['order'] == 'mtime asc'){ - mtime_icon = ''; - } else { - mtime_icon = ''; - } - - var fname_icon = ''; - if (post['order'] == 'fname desc'){ - fname_icon = ''; - } else if (post['order'] == 'fname asc'){ - fname_icon = ''; - } else { - fname_icon = ''; - } - - var tablehtml = '\ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - '+body+'\ -
文件名'+fname_icon+'大小'+size_icon+'修改时间'+mtime_icon+'权限所有者操作
'; - $("#fileCon").removeClass("fileList").html(tablehtml); - $("#tipTools").width($("#fileCon").width()); - } else { - $("#fileCon").addClass("fileList").html(body); - $("#tipTools").width($("#fileCon").width()); - } - $("#DirPathPlace input").val(rdata.path); - var BarTools = '
\ - \ - \ -
'; - if (rdata.path != '/') { - BarTools += ' '; - } - setCookie('open_dir_path',rdata.path); - BarTools += ' \ - '; - var copyName = getCookie('copyFileName'); - var cutName = getCookie('cutFileName'); - var isPaste = (copyName == 'null') ? cutName : copyName; - // console.log('isPaste:',isPaste); - //--- - if (isPaste != 'null' && isPaste != undefined) { - BarTools += ' '; - } - - $("#Batch").html(''); - var batchTools = ''; - var isBatch = getCookie('BatchSelected'); - if (isBatch == 1 || isBatch == '1') { - batchTools += ' '; - } - $("#Batch").html(batchTools); - - $("#setBox").prop("checked", false); - - $("#BarTools").html(BarTools); - - $("input[name=id]").click(function(){ - if($(this).prop("checked")) { - $(this).prop("checked", true); - $(this).parents("tr").addClass("ui-selected"); - } - else{ - $(this).prop("checked", false); - $(this).parents("tr").removeClass("ui-selected"); - } - showSeclect(); - }); - - $("#setBox").click(function() { - if ($(this).prop("checked")) { - $("input[name=id]").prop("checked", true); - $("#filesBody > tr").addClass("ui-selected"); - - } else { - $("input[name=id]").prop("checked", false); - $("#filesBody > tr").removeClass("ui-selected"); - } - showSeclect(); - }); - //阻止冒泡 - $("#filesBody .btlink").click(function(e){ - e.stopPropagation(); - }); - $("input[name=id]").dblclick(function(e){ - e.stopPropagation(); - }); - - - //禁用右键 - $("#fileCon").bind("contextmenu",function(e){ - return false; - }); - bindselect(); - - // //绑定右键 - $("#fileCon").mousedown(function(e){ - var count = totalFile(); - if(e.which == 3) { - if(count>1){ - rightMenuClickAll(e); - } else { - return; - } - } - }); - - $(".folderBox,.folderBoxTr").mousedown(function(e){ - // console.log(e); - var count = totalFile(); - if(e.which == 3) { - if(count <= 1){ - var a = $(this); - var option = rightMenuClick(a.attr("filetype"),a.attr("data-path"),a.find("input").val()); - a.contextify(option); - } else{ - rightMenuClickAll(e); - } - } - }); - - //每页行数 - $(".showRow").change(function(){ - setCookie('file_row',$(this).val()); - getFiles(p); - }); - pathPlaceBtn(rdata.path); - },'json'); - // setTimeout(function(){getCookie('open_dir_path');},200); + if(isNaN(Path)){ + var p = 1; + } else { + var p = Path; + Path = getCookie('open_dir_path'); + } + + var post = {}; + post['path'] = Path; + post['p'] = p; + + var file_row = $.cookie('file_row'); + if(!file_row) { + file_row = '100'; + } + post['row'] = file_row; + + var body = ''; + var totalSize = 0; + + var search = ''; + var search_file = $("#search_file").val(); + + if(search_file.length > 0){ + post['search'] = search_file; + } + + var search_all = ''; + var all = $('#search_all').hasClass('active'); + if(all){ + post['all'] = 'yes'; + } + + var file_order = $.cookie('file_order'); + if (file_order){ + post['order'] = file_order.replace('|',' '); + } + + + var loadT = layer.load(); + $.post('/files/get_dir', post, function(rdata) { + layer.close(loadT); + + //构建分页 + makeFilePage(file_row,rdata.page); + + if(rdata.dir == null) { + rdata.dir = []; + } + + for (var i = 0; i < rdata.dir.length; i++) { + var fmp = rdata.dir[i].split(";"); + var cnametext =fmp[0] + fmp[5]; + + fmp[0] = fmp[0].replace(/'/, "\\'"); + if(cnametext.length>20){ + cnametext = cnametext.substring(0,20) + '...'; + } + + if(isChineseChar(cnametext)){ + if(cnametext.length>10){ + cnametext = cnametext.substring(0,10) + '...'; + } + } + + var timetext ='--'; + if(getCookie('rank') == 'a'){ + //列表展示 + $("#set_list").addClass("active"); + $("#set_icon").removeClass("active"); + body += "\ + \ + \ + " + cnametext + "\ + "+toSize(fmp[1])+"\ + "+getLocalTime(fmp[2])+"\ + "+fmp[3]+"\ + "+fmp[4]+"\ + \ + 复制 | \ + 剪切 | \ + 重命名 | \ + 权限 | \ + 压缩 | \ + 删除\ + \ + "; + } else { + //图标展示 + $("#set_icon").addClass("active"); + $("#set_list").removeClass("active"); + body += ""; + } + } + + for (var i = 0; i < rdata.files.length; i++) { + if(rdata.files[i] == null) continue; + var fmp = rdata.files[i].split(";"); + var bodyZip = ''; + var download = ''; + var cnametext =fmp[0] + fmp[5]; + fmp[0] = fmp[0].replace(/'/,"\\'"); + + if(isChineseChar(cnametext)){ + if(cnametext.length>16){ + cnametext = cnametext.substring(0,16) + '...'; + } + } else{ + if( cnametext.length > 48 ){ + cnametext = cnametext.substring(0,48) + '...'; + } + } + + var displayCompress = 1; + if(isCompressFile(fmp[0])){ + bodyZip = "解压 | "; + } + + if(isText(fmp[0])){ + bodyZip = "编辑 | "; + } + + if(isImage(fmp[0])){ + download = "预览 | "; + } else { + download = "下载 | "; + } + + totalSize += parseInt(fmp[1]); + if(getCookie("rank")=="a"){ + body += "\ + \ + " + cnametext + "\ + " + (toSize(fmp[1])) + "\ + " + ((fmp[2].length > 11)?fmp[2]:getLocalTime(fmp[2])) + "\ + "+fmp[3]+"\ + "+fmp[4]+"\ + \ + 复制 | \ + 剪切 | \ + 重命名 | \ + 权限 | \ + 压缩 | " + + bodyZip + + download + + "删除\ + \ + "; + } + else{ + body += ""; + } + } + var dirInfo = '(共{1}个目录与{2}个文件,大小:'.replace('{1}',rdata.dir.length+'').replace('{2}',rdata.files.length+'')+'' + + (toSize(totalSize))+'获取)'; + $("#dir_info").html(dirInfo); + if( getCookie('rank') == 'a' ){ + + // console.log(post['order']); + var size_icon = ''; + if (post['order'] == 'size desc'){ + size_icon = ''; + } else if (post['order'] == 'size asc'){ + size_icon = ''; + } else { + size_icon = ''; + } + + var mtime_icon = ''; + if (post['order'] == 'mtime desc'){ + mtime_icon = ''; + } else if (post['order'] == 'mtime asc'){ + mtime_icon = ''; + } else { + mtime_icon = ''; + } + + var fname_icon = ''; + if (post['order'] == 'fname desc'){ + fname_icon = ''; + } else if (post['order'] == 'fname asc'){ + fname_icon = ''; + } else { + fname_icon = ''; + } + + var tablehtml = '\ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + '+body+'\ +
文件名'+fname_icon+'大小'+size_icon+'修改时间'+mtime_icon+'权限所有者操作
'; + $("#fileCon").removeClass("fileList").html(tablehtml); + $("#tipTools").width($("#fileCon").width()); + } else { + $("#fileCon").addClass("fileList").html(body); + $("#tipTools").width($("#fileCon").width()); + } + $("#DirPathPlace input").val(rdata.path); + var BarTools = '
\ + \ + \ +
'; + if (rdata.path != '/') { + BarTools += ' '; + } + setCookie('open_dir_path',rdata.path); + BarTools += ' \ + '; + var copyName = getCookie('copyFileName'); + var cutName = getCookie('cutFileName'); + var isPaste = (copyName == 'null') ? cutName : copyName; + // console.log('isPaste:',isPaste); + //--- + if (isPaste != 'null' && isPaste != undefined) { + BarTools += ' '; + } + + $("#Batch").html(''); + var batchTools = ''; + var isBatch = getCookie('BatchSelected'); + if (isBatch == 1 || isBatch == '1') { + batchTools += ' '; + } + $("#Batch").html(batchTools); + + $("#setBox").prop("checked", false); + + $("#BarTools").html(BarTools); + + $("input[name=id]").click(function(){ + if($(this).prop("checked")) { + $(this).prop("checked", true); + $(this).parents("tr").addClass("ui-selected"); + } + else{ + $(this).prop("checked", false); + $(this).parents("tr").removeClass("ui-selected"); + } + showSeclect(); + }); + + $("#setBox").click(function() { + if ($(this).prop("checked")) { + $("input[name=id]").prop("checked", true); + $("#filesBody > tr").addClass("ui-selected"); + + } else { + $("input[name=id]").prop("checked", false); + $("#filesBody > tr").removeClass("ui-selected"); + } + showSeclect(); + }); + //阻止冒泡 + $("#filesBody .btlink").click(function(e){ + e.stopPropagation(); + }); + $("input[name=id]").dblclick(function(e){ + e.stopPropagation(); + }); + + + //禁用右键 + $("#fileCon").bind("contextmenu",function(e){ + return false; + }); + bindselect(); + + // //绑定右键 + $("#fileCon").mousedown(function(e){ + var count = totalFile(); + if(e.which == 3) { + if(count>1){ + rightMenuClickAll(e); + } else { + return; + } + } + }); + + $(".folderBox,.folderBoxTr").mousedown(function(e){ + // console.log(e); + var count = totalFile(); + if(e.which == 3) { + if(count <= 1){ + var a = $(this); + var option = rightMenuClick(a.attr("filetype"),a.attr("data-path"),a.find("input").val()); + a.contextify(option); + } else{ + rightMenuClickAll(e); + } + } + }); + + //每页行数 + $(".showRow").change(function(){ + setCookie('file_row',$(this).val()); + getFiles(p); + }); + pathPlaceBtn(rdata.path); + },'json'); + // setTimeout(function(){getCookie('open_dir_path');},200); } //统计选择数量 function totalFile(){ - var el = $("input[name='id']"); - var len = el.length; - var count = 0; - for(var i=0;i 1){ - batchTools = '\ - \ - \ - \ - '; - }else{ - //setCookie('BatchSelected', null); - } - $("#Batch").html(batchTools); + var count = totalFile(); + var batchTools = ''; + if(count > 1){ + batchTools = '\ + \ + \ + \ + '; + }else{ + //setCookie('BatchSelected', null); + } + $("#Batch").html(batchTools); } //滚动条事件 $(window).scroll(function () { - if($(window).scrollTop() > 16){ - $("#tipTools").css({"position":"fixed","top":"0","left":"195px","box-shadow":"0 1px 10px 3px #ccc"}); - }else{ - $("#tipTools").css({"position":"absolute","top":"0","left":"0","box-shadow":"none"}); - } + if($(window).scrollTop() > 16){ + $("#tipTools").css({"position":"fixed","top":"0","left":"195px","box-shadow":"0 1px 10px 3px #ccc"}); + }else{ + $("#tipTools").css({"position":"absolute","top":"0","left":"0","box-shadow":"none"}); + } }); $("#tipTools").width($(".file-box").width()); $("#PathPlaceBtn").width($(".file-box").width()-700); $("#DirPathPlace input").width($(".file-box").width()-700); if($(window).width()<1160){ - $("#PathPlaceBtn").width(290); + $("#PathPlaceBtn").width(290); } window.onresize = function(){ - $("#tipTools").width($(".file-box").width()-30); - $("#PathPlaceBtn").width($(".file-box").width()-700); - $("#DirPathPlace input").width($(".file-box").width()-700); - if($(window).width()<1160){ - $("#PathPlaceBtn,#DirPathPlace input").width(290); - } - pathLeft(); - isDiskWidth(); + $("#tipTools").width($(".file-box").width()-30); + $("#PathPlaceBtn").width($(".file-box").width()-700); + $("#DirPathPlace input").width($(".file-box").width()-700); + if($(window).width()<1160){ + $("#PathPlaceBtn,#DirPathPlace input").width(290); + } + pathLeft(); + isDiskWidth(); } //批量操作 function batch(type,access){ - var path = $("#DirPathPlace input").val(); - var el = document.getElementsByTagName('input'); - var len = el.length; - var data='path='+path+'&type='+type; - var name = 'data'; - var datas = []; - - var oldType = getCookie('BatchPaste'); - - for(var i=0;i正在处理,请稍候...",{icon:16,time:0,shade: [0.3, '#000']}); - setTimeout(function(){getSpeed('.myspeed');},1000); - // console.log(data); - $.post('/files/set_batch_data',data,function(rdata){ - layer.close(myloadT); - getFiles(path); - layer.msg(rdata.msg,{icon:1}); - },'json'); + var path = $("#DirPathPlace input").val(); + var el = document.getElementsByTagName('input'); + var len = el.length; + var data='path='+path+'&type='+type; + var name = 'data'; + var datas = []; + + var oldType = getCookie('BatchPaste'); + + for(var i=0;i正在处理,请稍候...",{icon:16,time:0,shade: [0.3, '#000']}); + setTimeout(function(){getSpeed('.myspeed');},1000); + // console.log(data); + $.post('/files/set_batch_data',data,function(rdata){ + layer.close(myloadT); + getFiles(path); + layer.msg(rdata.msg,{icon:1}); + },'json'); } //批量粘贴 function batchPaste(){ - var path = $("#DirPathPlace input").val(); - var type = getCookie('BatchPaste'); - var data = 'type='+type+'&path='+path; - - $.post('/files/check_exists_files',{dfile:path},function(rdata){ - var result = rdata['data']; - if(result.length > 0){ - var tbody = ''; - for(var i=0;i'+toSize(result[i].size)+''+getLocalTime(result[i].mtime)+''; - } - var mbody = '
\ - '+tbody+'\ -
文件名大小最后修改时间
'; - safeMessage('即将覆盖以下文件',mbody,function(){ - batchPasteTo(data,path); - }); - $(".layui-layer-page").css("width","500px"); - }else{ - batchPasteTo(data,path); - } - },'json'); + var path = $("#DirPathPlace input").val(); + var type = getCookie('BatchPaste'); + var data = 'type='+type+'&path='+path; + + $.post('/files/check_exists_files',{dfile:path},function(rdata){ + var result = rdata['data']; + if(result.length > 0){ + var tbody = ''; + for(var i=0;i'+toSize(result[i].size)+''+getLocalTime(result[i].mtime)+''; + } + var mbody = '
\ + '+tbody+'\ +
文件名大小最后修改时间
'; + safeMessage('即将覆盖以下文件',mbody,function(){ + batchPasteTo(data,path); + }); + $(".layui-layer-page").css("width","500px"); + }else{ + batchPasteTo(data,path); + } + },'json'); } - + function batchPasteTo(data,path){ - myloadT = layer.msg("
正在处理,请稍候...
",{icon:16,time:0,shade: [0.3, '#000']}); - setTimeout(function(){getSpeed('.myspeed');},1000); - $.post('/files/batch_paste',data,function(rdata){ - layer.close(myloadT); - setCookie('BatchSelected', null); - getFiles(path); - layer.msg(rdata.msg,{icon:1}); - },'json'); + myloadT = layer.msg("
正在处理,请稍候...
",{icon:16,time:0,shade: [0.3, '#000']}); + setTimeout(function(){getSpeed('.myspeed');},1000); + $.post('/files/batch_paste',data,function(rdata){ + layer.close(myloadT); + setCookie('BatchSelected', null); + getFiles(path); + layer.msg(rdata.msg,{icon:1}); + },'json'); } function getSuffixName(fileName){ - var extArr = fileName.split("."); - var exts = ['folder-unempty','sql','c','cpp','cs','flv','css','js', - 'htm','html','java','log','mht','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','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','scss','svg','pl','py','php','md','json','sh','conf']; - var extLastName = extArr[extArr.length - 1]; - for(var i=0; i tr").hover(function(){ - $(this).addClass("hover"); - },function(){ - $(this).removeClass("hover"); - }).click(function(){ - $(this).addClass("on").siblings().removeClass("on"); - }); + $("#filesBody > tr").hover(function(){ + $(this).addClass("hover"); + },function(){ + $(this).removeClass("hover"); + }).click(function(){ + $(this).addClass("on").siblings().removeClass("on"); + }); } //取磁盘 function getDisk() { - var LBody = ''; - - $.get('/system/disk_info', function(rdata) { - var rdata = rdata.data; - for (var i = 0; i < rdata.length; i++) { - LBody += "\ -  " + (rdata[i].path=='/'?lan.files.path_root:rdata[i].path) + "(" + rdata[i].size[2] + ")"; - } - var trash = '\ -  回收站'; - $("#comlist").html(LBody+trash); - isDiskWidth(); - },'json'); + var LBody = ''; + + $.get('/system/disk_info', function(rdata) { + var rdata = rdata.data; + for (var i = 0; i < rdata.length; i++) { + LBody += "\ +  " + (rdata[i].path=='/'?lan.files.path_root:rdata[i].path) + "(" + rdata[i].size[2] + ")"; + } + var trash = '\ +  回收站'; + $("#comlist").html(LBody+trash); + isDiskWidth(); + },'json'); } //返回上一级 function backDir() { - var str = $("#DirPathPlace input").val().replace('//','/'); - if(str.substr(str.length-1,1) == '/'){ - str = str.substr(0,str.length-1); - } - var Path = str.split("/"); - var back = '/'; - if (Path.length > 2) { - var count = Path.length - 1; - for (var i = 0; i < count; i++) { - back += Path[i] + '/'; - } - if(back.substr(back.length-1,1) == '/'){ - back = back.substr(0,back.length-1); - } - getFiles(back); - } else { - back += Path[0]; - getFiles(back); - } - setTimeout('pathPlaceBtn(getCookie("open_dir_path"));',200); + var str = $("#DirPathPlace input").val().replace('//','/'); + if(str.substr(str.length-1,1) == '/'){ + str = str.substr(0,str.length-1); + } + var Path = str.split("/"); + var back = '/'; + if (Path.length > 2) { + var count = Path.length - 1; + for (var i = 0; i < count; i++) { + back += Path[i] + '/'; + } + if(back.substr(back.length-1,1) == '/'){ + back = back.substr(0,back.length-1); + } + getFiles(back); + } else { + back += Path[0]; + getFiles(back); + } + setTimeout('pathPlaceBtn(getCookie("open_dir_path"));',200); } //新建文件 function createFile(type, path) { - if (type == 1) { - var fileName = $("#newFileName").val(); - layer.msg(lan.public.the, { - icon: 16, - time: 10000 - }); - $.post('/files/create_file', 'path=' + encodeURIComponent(path + '/' + fileName), function(rdata) { - layer.closeAll(); - layer.msg(rdata.msg, { - icon: rdata.status ? 1 : 2 - }); - if(rdata.status){ - getFiles($("#DirPathPlace input").val()); - onlineEditFile(0,path + '/' + fileName); - } - },'json'); - return; - } - layer.open({ - type: 1, - shift: 5, - closeBtn: 1, - area: '320px', - title: '新建空白文件', - content: '
\ -
\ - \ -
\ -
\ - \ - \ -
\ -
', - success:function(){ - $("#newFileName").focus().keyup(function(e){ - if(e.keyCode == 13) $("#createFileBtn").click(); - }); - } - }); - + if (type == 1) { + var fileName = $("#newFileName").val(); + layer.msg(lan.public.the, { + icon: 16, + time: 10000 + }); + $.post('/files/create_file', 'path=' + encodeURIComponent(path + '/' + fileName), function(rdata) { + layer.closeAll(); + layer.msg(rdata.msg, { + icon: rdata.status ? 1 : 2 + }); + if(rdata.status){ + getFiles($("#DirPathPlace input").val()); + onlineEditFile(0,path + '/' + fileName); + } + },'json'); + return; + } + layer.open({ + type: 1, + shift: 5, + closeBtn: 1, + area: '320px', + title: '新建空白文件', + content: '
\ +
\ + \ +
\ +
\ + \ + \ +
\ +
', + success:function(){ + $("#newFileName").focus().keyup(function(e){ + if(e.keyCode == 13) $("#createFileBtn").click(); + }); + } + }); + } //新建目录 function createDir(type, path) { - if (type == 1) { - var dirName = $("#newDirName").val(); - layer.msg('正在处理,请稍候...', { - icon: 16, - time: 10000 - }); - $.post('/files/create_dir', 'path=' + encodeURIComponent(path + '/' + dirName), function(rdata) { - layer.closeAll(); - layer.msg(rdata.msg, { - icon: rdata.status ? 1 : 2 - }); - getFiles($("#DirPathPlace input").val()); - },'json'); - return; - } - layer.open({ - type: 1, - shift: 5, - closeBtn: 1, - area: '320px', - title: '新建目录', - content: '
\ -
\ - \ -
\ -
\ - \ - \ -
\ -
', - success:function(){ - $("#newDirName").focus().keyup(function(e){ - if(e.keyCode == 13) { - $("#createDirBtn").click(); - } - }); - } - }); - + if (type == 1) { + var dirName = $("#newDirName").val(); + layer.msg('正在处理,请稍候...', { + icon: 16, + time: 10000 + }); + $.post('/files/create_dir', 'path=' + encodeURIComponent(path + '/' + dirName), function(rdata) { + layer.closeAll(); + layer.msg(rdata.msg, { + icon: rdata.status ? 1 : 2 + }); + getFiles($("#DirPathPlace input").val()); + },'json'); + return; + } + layer.open({ + type: 1, + shift: 5, + closeBtn: 1, + area: '320px', + title: '新建目录', + content: '
\ +
\ + \ +
\ +
\ + \ + \ +
\ +
', + success:function(){ + $("#newDirName").focus().keyup(function(e){ + if(e.keyCode == 13) { + $("#createDirBtn").click(); + } + }); + } + }); + } //删除文件 function deleteFile(fileName){ - layer.confirm(lan.get('recycle_bin_confirm',[fileName]),{title:'删除文件',closeBtn:2,icon:3},function(){ - layer.msg('正在处理,请稍候...',{icon:16,time:0,shade: [0.3, '#000']}); - $.post('/files/delete', 'path=' + encodeURIComponent(fileName), function(rdata) { - layer.closeAll(); - layer.msg(rdata.msg, { - icon: rdata.status ? 1 : 2, - }); - getFiles($("#DirPathPlace input").val()); - },'json'); - }); + layer.confirm(lan.get('recycle_bin_confirm',[fileName]),{title:'删除文件',closeBtn:2,icon:3},function(){ + layer.msg('正在处理,请稍候...',{icon:16,time:0,shade: [0.3, '#000']}); + $.post('/files/delete', 'path=' + encodeURIComponent(fileName), function(rdata) { + layer.closeAll(); + layer.msg(rdata.msg, { + icon: rdata.status ? 1 : 2, + }); + getFiles($("#DirPathPlace input").val()); + },'json'); + }); } //删除目录 function deleteDir(dirName){ - layer.confirm(lan.get('recycle_bin_confirm_dir',[dirName]),{title:'删除目录',closeBtn:2,icon:3},function(){ - layer.msg('正在处理,请稍候...',{icon:16,time:0,shade: [0.3, '#000']}); - $.post('/files/delete_dir', 'path=' + encodeURIComponent(dirName), function(rdata) { - layer.closeAll(); - layer.msg(rdata.msg, { - icon: rdata.status ? 1 : 2 - }); - getFiles($("#DirPathPlace input").val()); - },'json'); - }); + layer.confirm(lan.get('recycle_bin_confirm_dir',[dirName]),{title:'删除目录',closeBtn:2,icon:3},function(){ + layer.msg('正在处理,请稍候...',{icon:16,time:0,shade: [0.3, '#000']}); + $.post('/files/delete_dir', 'path=' + encodeURIComponent(dirName), function(rdata) { + layer.closeAll(); + layer.msg(rdata.msg, { + icon: rdata.status ? 1 : 2 + }); + getFiles($("#DirPathPlace input").val()); + },'json'); + }); } //批量删除文件 function allDeleteFileSub(data,path){ - layer.confirm('您确实要把这些文件放入回收站吗?',{title:'批量删除文件',closeBtn:2,icon:3},function(){ - layer.msg("
正在处理,请稍候...
",{icon:16,time:0,shade: [0.3, '#000']}); - setTimeout(function(){getSpeed('.myspeed');},1000); - $.post('/files/set_batch_data',data,function(rdata){ - layer.closeAll(); - getFiles(path); - layer.msg(rdata.msg,{icon:1}); - },'json'); - }); + layer.confirm('您确实要把这些文件放入回收站吗?',{title:'批量删除文件',closeBtn:2,icon:3},function(){ + layer.msg("
正在处理,请稍候...
",{icon:16,time:0,shade: [0.3, '#000']}); + setTimeout(function(){getSpeed('.myspeed');},1000); + $.post('/files/set_batch_data',data,function(rdata){ + layer.closeAll(); + getFiles(path); + layer.msg(rdata.msg,{icon:1}); + },'json'); + }); } //重载文件列表 function reloadFiles(){ - setInterval(function(){ - var path = $("#DirPathPlace input").val(); - getFiles(path); - },3000); + setInterval(function(){ + var path = $("#DirPathPlace input").val(); + getFiles(path); + },3000); } - + //下载文件 function downloadFile(action){ - - if(action == 1){ - var fUrl = $("#mUrl").val(); - fUrl = encodeURIComponent(fUrl); - - var fpath = $("#dpath").val(); - fname = encodeURIComponent($("#dfilename").val()); - - if (fUrl == "" ){ - layer.msg("URL地址不能为空!",{icon:2}); - return; - } - - layer.closeAll(); - layer.msg(lan.files.down_task,{time:0,icon:16,shade: [0.3, '#000']}); - - $.post('/files/download_file','path='+fpath+'&url='+fUrl+'&filename='+fname,function(rdata){ - layer.closeAll(); - getFiles(fpath); - getTaskCount(); - layer.msg(rdata.msg,{icon:rdata.status?1:2}); - },'json'); - return; - } - - var path = $("#DirPathPlace input").val(); - layer.open({ - type: 1, - shift: 5, - closeBtn: 1, - area: '500px', - btn:["确定","关闭"], - title: lan.files.down_title, - content: '
\ -
\ - URL地址:\ - \ -
\ -
\ - 下载到:\ - \ -
\ -
\ - 文件名:\ - \ -
\ -
', - success:function(){ - $("#mUrl").keyup(function(){ - durl = $(this).val(); - tmp = durl.split('/'); - $("#dfilename").val(tmp[tmp.length-1]); - }); - }, - yes:function(){ - downloadFile(1); - } - }); + + if(action == 1){ + var fUrl = $("#mUrl").val(); + fUrl = encodeURIComponent(fUrl); + + var fpath = $("#dpath").val(); + fname = encodeURIComponent($("#dfilename").val()); + + if (fUrl == "" ){ + layer.msg("URL地址不能为空!",{icon:2}); + return; + } + + layer.closeAll(); + layer.msg(lan.files.down_task,{time:0,icon:16,shade: [0.3, '#000']}); + + $.post('/files/download_file','path='+fpath+'&url='+fUrl+'&filename='+fname,function(rdata){ + layer.closeAll(); + getFiles(fpath); + getTaskCount(); + layer.msg(rdata.msg,{icon:rdata.status?1:2}); + },'json'); + return; + } + + var path = $("#DirPathPlace input").val(); + layer.open({ + type: 1, + shift: 5, + closeBtn: 1, + area: '500px', + btn:["确定","关闭"], + title: lan.files.down_title, + content: '
\ +
\ + URL地址:\ + \ +
\ +
\ + 下载到:\ + \ +
\ +
\ + 文件名:\ + \ +
\ +
', + success:function(){ + $("#mUrl").keyup(function(){ + durl = $(this).val(); + tmp = durl.split('/'); + $("#dfilename").val(tmp[tmp.length-1]); + }); + }, + yes:function(){ + downloadFile(1); + } + }); } //重命名 function reName(type, fileName) { - if (type == 1) { - var path = $("#DirPathPlace input").val(); - var newFileName = encodeURIComponent(path + '/' + $("#newFileName").val()); - var oldFileName = encodeURIComponent(path + '/' + fileName); - layer.msg(lan.public.the, { - icon: 16, - time: 10000 - }); - $.post('/files/mv_file', 'sfile=' + oldFileName + '&dfile=' + newFileName, function(rdata) { - layer.closeAll(); - layer.msg(rdata.msg, { - icon: rdata.status ? 1 : 2 - }); - getFiles(path); - },'json'); - return; - } - layer.open({ - type: 1, - shift: 5, - closeBtn: 1, - area: '320px', - title: '重命名', - btn:["确定","取消"], - content: '
\ -
\ - \ -
\ -
', - success:function(){ - $("#newFileName").focus().keyup(function(e){ - if(e.keyCode == 13) $(".layui-layer-btn0").click(); - }); - }, - yes:function(){ - reName(1,fileName.replace(/'/,"\\'")); - } - }); - + if (type == 1) { + var path = $("#DirPathPlace input").val(); + var newFileName = encodeURIComponent(path + '/' + $("#newFileName").val()); + var oldFileName = encodeURIComponent(path + '/' + fileName); + layer.msg(lan.public.the, { + icon: 16, + time: 10000 + }); + $.post('/files/mv_file', 'sfile=' + oldFileName + '&dfile=' + newFileName, function(rdata) { + layer.closeAll(); + layer.msg(rdata.msg, { + icon: rdata.status ? 1 : 2 + }); + getFiles(path); + },'json'); + return; + } + layer.open({ + type: 1, + shift: 5, + closeBtn: 1, + area: '320px', + title: '重命名', + btn:["确定","取消"], + content: '
\ +
\ + \ +
\ +
', + success:function(){ + $("#newFileName").focus().keyup(function(e){ + if(e.keyCode == 13) $(".layui-layer-btn0").click(); + }); + }, + yes:function(){ + reName(1,fileName.replace(/'/,"\\'")); + } + }); + } //剪切 function cutFile(fileName) { - var path = $("#DirPathPlace input").val(); - setCookie('cutFileName', fileName); - setCookie('copyFileName', null); - layer.msg('已剪切', { - icon: 1, - time: 1000, - }); - setTimeout(function(){ - getFiles(path); - },1000); + var path = $("#DirPathPlace input").val(); + setCookie('cutFileName', fileName); + setCookie('copyFileName', null); + layer.msg('已剪切', { + icon: 1, + time: 1000, + }); + setTimeout(function(){ + getFiles(path); + },1000); } //复制 function copyFile(fileName) { - var path = $("#DirPathPlace input").val(); - setCookie('copyFileName', fileName); - setCookie('cutFileName', null); - layer.msg('已复制', { - icon: 1, - time: 1000, - }); - - setTimeout(function(){ - getFiles(path); - },1000); + var path = $("#DirPathPlace input").val(); + setCookie('copyFileName', fileName); + setCookie('cutFileName', null); + layer.msg('已复制', { + icon: 1, + time: 1000, + }); + + setTimeout(function(){ + getFiles(path); + },1000); } //粘贴 function pasteFile(fileName) { - var path = $("#DirPathPlace input").val(); - var copyName = getCookie('copyFileName'); - var cutName = getCookie('cutFileName'); - var filename = copyName; - if(cutName != 'null' && cutName != undefined) filename=cutName; - filename = filename.split('/').pop(); - $.post('/files/check_exists_files',{dfile: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+'\ -
文件名大小最后修改时间
'; - safeMessage('即将覆盖以下文件',mbody,function(){ - pasteTo(path,copyName,cutName,fileName); - }); - } else { - pasteTo(path,copyName,cutName,fileName); - } - },'json'); + var path = $("#DirPathPlace input").val(); + var copyName = getCookie('copyFileName'); + var cutName = getCookie('cutFileName'); + var filename = copyName; + if(cutName != 'null' && cutName != undefined) filename=cutName; + filename = filename.split('/').pop(); + $.post('/files/check_exists_files',{dfile: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+'\ +
文件名大小最后修改时间
'; + safeMessage('即将覆盖以下文件',mbody,function(){ + pasteTo(path,copyName,cutName,fileName); + }); + } else { + pasteTo(path,copyName,cutName,fileName); + } + },'json'); } function pasteTo(path,copyName,cutName,fileName){ - if (copyName != 'null' && copyName != undefined) { - layer.msg(lan.files.copy_the, { - icon: 16, - time: 0,shade: [0.3, '#000'] - }); - - //同目录下 - if (copyName == path +'/'+ fileName){ - fileName = '__copy__'+ fileName; - } - - $.post('/files/copy_file', 'sfile=' + encodeURIComponent(copyName) + '&dfile=' + encodeURIComponent(path +'/'+ fileName), function(rdata) { - layer.closeAll(); - layer.msg(rdata.msg, { - icon: rdata.status ? 1 : 2 - }); - getFiles(path); - },'json'); - setCookie('copyFileName', null); - setCookie('cutFileName', null); - return; - } - - if (cutName != 'null' && cutName != undefined) { - layer.msg(lan.files.mv_the, { - icon: 16, - time: 0,shade: [0.3, '#000'] - }); - $.post('/files/mv_file', 'sfile=' + encodeURIComponent(cutName) + '&dfile=' + encodeURIComponent(path + '/'+fileName), function(rdata) { - layer.closeAll(); - layer.msg(rdata.msg, {icon: rdata.status ? 1 : 2}); - getFiles(path); - },'json'); - setCookie('copyFileName', null); - setCookie('cutFileName', null); - } + if (copyName != 'null' && copyName != undefined) { + layer.msg(lan.files.copy_the, { + icon: 16, + time: 0,shade: [0.3, '#000'] + }); + + //同目录下 + if (copyName == path +'/'+ fileName){ + fileName = '__copy__'+ fileName; + } + + $.post('/files/copy_file', 'sfile=' + encodeURIComponent(copyName) + '&dfile=' + encodeURIComponent(path +'/'+ fileName), function(rdata) { + layer.closeAll(); + layer.msg(rdata.msg, { + icon: rdata.status ? 1 : 2 + }); + getFiles(path); + },'json'); + setCookie('copyFileName', null); + setCookie('cutFileName', null); + return; + } + + if (cutName != 'null' && cutName != undefined) { + layer.msg(lan.files.mv_the, { + icon: 16, + time: 0,shade: [0.3, '#000'] + }); + $.post('/files/mv_file', 'sfile=' + encodeURIComponent(cutName) + '&dfile=' + encodeURIComponent(path + '/'+fileName), function(rdata) { + layer.closeAll(); + layer.msg(rdata.msg, {icon: rdata.status ? 1 : 2}); + getFiles(path); + },'json'); + setCookie('copyFileName', null); + setCookie('cutFileName', null); + } } //压缩目录 function zip(dirName,submits) { - var path = $("#DirPathPlace input").val(); - if(submits != undefined){ - if(dirName.indexOf(',') == -1){ - tmp = $("#sfile").val().split('/'); - sfile = encodeURIComponent(tmp[tmp.length-1]); - }else{ - sfile = encodeURIComponent(dirName); - } - - dfile = encodeURIComponent($("#dfile").val()); - layer.closeAll(); - layer.msg(lan.files.zip_the, {icon: 16,time: 0,shade: [0.3, '#000']}); - $.post('/files/zip', 'sfile=' + sfile + '&dfile=' + dfile + '&type=tar&path='+encodeURIComponent(path), function(rdata) { - layer.closeAll(); - if(rdata == null || rdata == undefined){ - layer.msg(lan.files.zip_ok,{icon:1}); - getFiles(path) - reloadFiles(); - return; - } - layer.msg(rdata.msg, {icon: rdata.status ? 1 : 2}); - if(rdata.status) getFiles(path); - },'json'); - return - } - - param = dirName; - if(dirName.indexOf(',') != -1){ - tmp = path.split('/'); - dirName = path + '/' + tmp[tmp.length-1]; - } - - layer.open({ - type: 1, - shift: 5, - closeBtn: 1, - area: '650px', - title: lan.files.zip_title, - content: '
' - +'
' - +'' - +''+lan.files.zip_to+'\ - \ - ' - +'
' - +'
' - +'' - +'' - +'
' - +'
', - success:function(){ - $("#dfile").change(function(){ - var dfile = $(this).val() - tmp = dfile.split('.'); - if(tmp[tmp.length-1] != 'gz'){ - var path = $("#DirPathPlace input").val(); - tmp = path.split('/'); - dfile += '/' + tmp[tmp.length-1] + '.tar.gz' - $(this).val(dfile.replace(/\/\//g,'/')) - } - }); - } - }); - + var path = $("#DirPathPlace input").val(); + if(submits != undefined){ + if(dirName.indexOf(',') == -1){ + tmp = $("#sfile").val().split('/'); + sfile = encodeURIComponent(tmp[tmp.length-1]); + }else{ + sfile = encodeURIComponent(dirName); + } + + dfile = encodeURIComponent($("#dfile").val()); + layer.closeAll(); + layer.msg(lan.files.zip_the, {icon: 16,time: 0,shade: [0.3, '#000']}); + $.post('/files/zip', 'sfile=' + sfile + '&dfile=' + dfile + '&type=tar&path='+encodeURIComponent(path), function(rdata) { + layer.closeAll(); + if(rdata == null || rdata == undefined){ + layer.msg(lan.files.zip_ok,{icon:1}); + getFiles(path) + reloadFiles(); + return; + } + layer.msg(rdata.msg, {icon: rdata.status ? 1 : 2}); + if(rdata.status) getFiles(path); + },'json'); + return + } + + param = dirName; + if(dirName.indexOf(',') != -1){ + tmp = path.split('/'); + dirName = path + '/' + tmp[tmp.length-1]; + } + + layer.open({ + type: 1, + shift: 5, + closeBtn: 1, + area: '650px', + title: lan.files.zip_title, + content: '
' + +'
' + +'' + +''+lan.files.zip_to+'\ + \ + ' + +'
' + +'
' + +'' + +'' + +'
' + +'
', + success:function(){ + $("#dfile").change(function(){ + var dfile = $(this).val() + tmp = dfile.split('.'); + if(tmp[tmp.length-1] != 'gz'){ + var path = $("#DirPathPlace input").val(); + tmp = path.split('/'); + dfile += '/' + tmp[tmp.length-1] + '.tar.gz' + $(this).val(dfile.replace(/\/\//g,'/')) + } + }); + } + }); + } - + //解压目录 function unZip(fileName, type) { - var path = $("#DirPathPlace input").val(); - if(type.length ==3){ - var sfile = encodeURIComponent($("#sfile").val()); - var dfile = encodeURIComponent($("#dfile").val()); - var coding = $("select[name='coding']").val(); - var tip = layer.msg(lan.files.unzip_the, {icon: 16,time: 0,shade: [0.3, '#000']}); - $.post('/files/unzip', 'sfile=' + sfile + '&dfile=' + dfile +'&type=' + type + '&path='+encodeURIComponent(path), function(rdata) { - layer.close(tip); - showMsg(rdata.msg, function(){ - getFiles(path); - },{icon: rdata.status ? 1 : 2},2000); - },'json'); - return; - } - - type = (type == 1) ? 'tar':'zip'; - var umpass = ''; - if(type == 'zip'){ - umpass = '
\ - '+lan.files.zip_pass_title+'\ - \ -
'; - } - layer.open({ - type: 1, - shift: 5, - closeBtn: 1, - area: '490px', - title: '解压文件', - content: '
' - +'
' - +''+lan.files.unzip_name+'
' - +'
'+lan.files.unzip_to+'
' - + umpass +'
'+lan.files.unzip_coding+'' - +'
' - +'
' - +'' - +'' - +'
' - +'
' - }); + var path = $("#DirPathPlace input").val(); + if(type.length ==3){ + var sfile = encodeURIComponent($("#sfile").val()); + var dfile = encodeURIComponent($("#dfile").val()); + var coding = $("select[name='coding']").val(); + var tip = layer.msg(lan.files.unzip_the, {icon: 16,time: 0,shade: [0.3, '#000']}); + $.post('/files/unzip', 'sfile=' + sfile + '&dfile=' + dfile +'&type=' + type + '&path='+encodeURIComponent(path), function(rdata) { + layer.close(tip); + showMsg(rdata.msg, function(){ + getFiles(path); + },{icon: rdata.status ? 1 : 2},2000); + },'json'); + return; + } + + type = (type == 1) ? 'tar':'zip'; + var umpass = ''; + if(type == 'zip'){ + umpass = '
\ + '+lan.files.zip_pass_title+'\ + \ +
'; + } + layer.open({ + type: 1, + shift: 5, + closeBtn: 1, + area: '490px', + title: '解压文件', + content: '
' + +'
' + +''+lan.files.unzip_name+'
' + +'
'+lan.files.unzip_to+'
' + + umpass +'
'+lan.files.unzip_coding+'' + +'
' + +'
' + +'' + +'' + +'
' + +'
' + }); } function isCompressFile(fileName){ - var ext = fileName.split('.'); - var extName = ext[ext.length-1].toLowerCase(); - var support = ['zip','gz','tgz','rar']; - for (x in support) { - if (support[x]==extName){ - return true; - } - } - return false; + var ext = fileName.split('.'); + var extName = ext[ext.length-1].toLowerCase(); + var support = ['zip','gz','tgz','rar']; + for (x in support) { + if (support[x]==extName){ + return true; + } + } + return false; } function unCompressFile(fileName, type = 0){ - // 解压文件 - var path = $("#DirPathPlace input").val(); - if(type == 3){ - var sfile = encodeURIComponent($("#sfile").val()); - var dfile = encodeURIComponent($("#dfile").val()); - var coding = $("select[name='coding']").val(); - var tip = layer.msg('正在解压,请稍候...', {icon: 16,time: 0,shade: [0.3, '#000']}); - $.post('/files/uncompress', 'sfile=' + sfile + '&dfile=' + dfile +'&type=' + type + '&path='+encodeURIComponent(path), function(rdata) { - layer.close(tip); - showMsg(rdata.msg, function(){ - layer.closeAll(); - getFiles(path); - },{icon: rdata.status ? 1 : 2},2000); - },'json'); - return; - } - - // var umpass = '
\ - // 解压密码\ - // \ - //
'; - layer.open({ - type: 1, - shift: 5, - closeBtn: 1, - area: '490px', - title: '解压文件', - content: '
\ -
\ - 文件名\ - \ -
\ -
\ - 解压到\ - \ -
\ -
\ - 编码\ - \ -
\ -
\ - \ - \ -
\ -
' - }); + // 解压文件 + var path = $("#DirPathPlace input").val(); + if(type == 3){ + var sfile = encodeURIComponent($("#sfile").val()); + var dfile = encodeURIComponent($("#dfile").val()); + var coding = $("select[name='coding']").val(); + var tip = layer.msg('正在解压,请稍候...', {icon: 16,time: 0,shade: [0.3, '#000']}); + $.post('/files/uncompress', 'sfile=' + sfile + '&dfile=' + dfile +'&type=' + type + '&path='+encodeURIComponent(path), function(rdata) { + layer.close(tip); + showMsg(rdata.msg, function(){ + layer.closeAll(); + getFiles(path); + },{icon: rdata.status ? 1 : 2},2000); + },'json'); + return; + } + + // var umpass = '
\ + // 解压密码\ + // \ + //
'; + layer.open({ + type: 1, + shift: 5, + closeBtn: 1, + area: '490px', + title: '解压文件', + content: '
\ +
\ + 文件名\ + \ +
\ +
\ + 解压到\ + \ +
\ +
\ + 编码\ + \ +
\ +
\ + \ + \ +
\ +
' + }); } //是否压缩文件 function isZip(fileName){ - var ext = fileName.split('.'); - var extName = ext[ext.length-1].toLowerCase(); - if( extName == 'zip') return 0; - if( extName == 'gz' || extName == 'tgz') return 1; - return -1; + var ext = fileName.split('.'); + var extName = ext[ext.length-1].toLowerCase(); + if( extName == 'zip') return 0; + if( extName == 'gz' || extName == 'tgz') return 1; + return -1; } //是否文本文件 function isText(fileName){ - var exts = ['rar','zip','tar.gz','gz','iso','xsl','doc','xdoc','jpeg', - 'jpg','png','gif','bmp','tiff','exe','so','7z','bz']; - return isExts(fileName,exts)?false:true; + var exts = ['rar','zip','tar.gz','gz','iso','xsl','doc','xdoc','jpeg', + 'jpg','png','gif','bmp','tiff','exe','so','7z','bz']; + return isExts(fileName,exts)?false:true; } //是否图片文件 function isImage(fileName){ - var exts = ['jpg','jpeg','png','bmp','gif','tiff','ico']; - return isExts(fileName,exts); + var exts = ['jpg','jpeg','png','bmp','gif','tiff','ico']; + return isExts(fileName,exts); } //是否为指定扩展名 function isExts(fileName,exts){ - var ext = fileName.split('.'); - if(ext.length < 2) return false; - var extName = ext[ext.length-1].toLowerCase(); - for(var i=0;i' - }); + var imgUrl = '/files/download?filename='+fileName; + layer.open({ + type:1, + offset: '150px', + closeBtn: 1, + title:"图片预览", + area: '400px', + shadeClose: true, + content: '
' + }); } //获取文件数据 function getFileBytes(fileName, fileSize){ - window.open('/files/download?filename='+encodeURIComponent(fileName)); + window.open('/files/download?filename='+encodeURIComponent(fileName)); } //上传文件 function uploadFiles(){ - var path = $("#DirPathPlace input").val()+"/"; - layer.open({ - type:1, - closeBtn: 1, - title:lan.files.up_title, - area: ['500px','300px'], - shadeClose:false, - content:'
\ - \ - \ - \ - \ - \ - \ - 文件编码:\ - \ - \ - \ -
    \ -
    ' - }); - uploadStart(); + var path = $("#DirPathPlace input").val()+"/"; + layer.open({ + type:1, + closeBtn: 1, + title:lan.files.up_title, + area: ['500px','300px'], + shadeClose:false, + content:'
    \ + \ + \ + \ + \ + \ + \ + 文件编码:\ + \ + \ + \ +
      \ +
      ' + }); + uploadStart(); } //设置权限 function setChmod(action,fileName){ - if(action == 1){ - var chmod = $("#access").val(); - var chown = $("#chown").val(); - var data = 'filename='+ encodeURIComponent(fileName)+'&user='+chown+'&access='+chmod; - var loadT = layer.msg('正在设置...',{icon:16,time:0,shade: [0.3, '#000']}); - $.post('/files/set_file_access',data,function(rdata){ - layer.close(loadT); - if(rdata.status) layer.closeAll(); - layer.msg(rdata.msg,{icon:rdata.status?1:2}); - var path = $("#DirPathPlace input").val(); - getFiles(path) - },'json'); - return; - } - - var toExec = fileName == lan.files.all?'batch(3,1)':'setChmod(1,\''+fileName+'\')'; - $.post('/files/file_access','filename='+encodeURIComponent(fileName),function(rdata){ - // console.log(rdata); - var sys_users = rdata.sys_users; - var own_html = ''; - var is_find_own_option = false; - for (var i = 0; i < sys_users.length; i++) { - var own = sys_users[i]; - if (rdata.chown==own){ - is_find_own_option = true; - own_html += ''; - } else { - own_html += ''; - } - } - if (!is_find_own_option){ - own_html += ''; - } - - layer.open({ - type:1, - closeBtn: 1, - title: '设置权限['+fileName+']', - area: '400px', - shadeClose:false, - content:'
      \ -
      \ - 所有者\ -

      读取

      \ -

      写入

      \ -

      执行

      \ -
      \ -
      \ - 用户组\ -

      读取

      \ -

      写入

      \ -

      执行

      \ -
      \ -
      \ - 公共\ -

      读取

      \ -

      写入

      \ -

      执行

      \ -
      \ -
      权限,\ - 所有者\ -
      \ -
      \ - \ - \ -
      \ -
      ' - }); - - onAccess(); - $("#access").keyup(function(){ - onAccess(); - }); - - $("input[type=checkbox]").change(function(){ - var idName = ['owner','group','public']; - var onacc = ''; - for(var n=0;n'+own+''; + } else { + own_html += ''; + } + } + if (!is_find_own_option){ + own_html += ''; + } + + layer.open({ + type:1, + closeBtn: 1, + title: '设置权限['+fileName+']', + area: '400px', + shadeClose:false, + content:'
      \ +
      \ + 所有者\ +

      读取

      \ +

      写入

      \ +

      执行

      \ +
      \ +
      \ + 用户组\ +

      读取

      \ +

      写入

      \ +

      执行

      \ +
      \ +
      \ + 公共\ +

      读取

      \ +

      写入

      \ +

      执行

      \ +
      \ +
      权限,\ + 所有者\ +
      \ +
      \ + \ + \ +
      \ +
      ' + }); + + onAccess(); + $("#access").keyup(function(){ + onAccess(); + }); + + $("input[type=checkbox]").change(function(){ + var idName = ['owner','group','public']; + var onacc = ''; + for(var n=0;n 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; - } - } + var access = $("#access").val(); + var idName = ['owner','group','public']; + for(var n=0;n 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; + } + } } //右键菜单 function rightMenuClick(type,path,name){ - // console.log(type,path,name); - var displayZip = isZip(type); - var options = {items:[ - {text: "复制", onclick: function() {copyFile(path)}}, - {text: "剪切", onclick: function() {cutFile(path)}}, - {text: "重命名", onclick: function() {reName(0,name)}}, - {text: lan.files.file_menu_auth, onclick: function() {setChmod(0,path)}}, - {text: lan.files.file_menu_zip, onclick: function() {zip(path)}}, - ]}; - if(type == "dir"){ - options.items.push({text: lan.files.file_menu_del, onclick: function() { - deleteDir(path)} - }); - } - else if(isText(type)){ - options.items.push({text: lan.files.file_menu_edit, onclick: function() { - onlineEditFile(0,path); - }},{text: lan.files.file_menu_down, onclick: function() { - getFileBytes(path); - }},{ text: lan.files.file_menu_del, onclick: function() { - deleteFile(path); - }}); - } - else if(displayZip != -1){ - options.items.push({text: lan.files.file_menu_unzip, onclick: function() { - unZip(path,displayZip); - }},{text: lan.files.file_menu_down, onclick: function() { - getFileBytes(path); - }},{text: lan.files.file_menu_del, onclick: function() { - deleteFile(path); - }}); - } - else if(isImage(type)){ - options.items.push({text: lan.files.file_menu_img, onclick: function() { - getImage(path); - }},{text: lan.files.file_menu_down, onclick: function() { - getFileBytes(path); - }},{text: lan.files.file_menu_del, onclick: function() { - deleteFile(path); - }}); - } - else{ - options.items.push({text: lan.files.file_menu_down, onclick: function() { - getFileBytes(path); - }},{text: lan.files.file_menu_del, onclick: function() { - deleteFile(path); - }}); - } - return options; + // console.log(type,path,name); + var displayZip = isZip(type); + var options = {items:[ + {text: "复制", onclick: function() {copyFile(path)}}, + {text: "剪切", onclick: function() {cutFile(path)}}, + {text: "重命名", onclick: function() {reName(0,name)}}, + {text: lan.files.file_menu_auth, onclick: function() {setChmod(0,path)}}, + {text: lan.files.file_menu_zip, onclick: function() {zip(path)}}, + ]}; + if(type == "dir"){ + options.items.push({text: lan.files.file_menu_del, onclick: function() { + deleteDir(path)} + }); + } + else if(isText(type)){ + options.items.push({text: lan.files.file_menu_edit, onclick: function() { + onlineEditFile(0,path); + }},{text: lan.files.file_menu_down, onclick: function() { + getFileBytes(path); + }},{ text: lan.files.file_menu_del, onclick: function() { + deleteFile(path); + }}); + } + else if(displayZip != -1){ + options.items.push({text: lan.files.file_menu_unzip, onclick: function() { + unZip(path,displayZip); + }},{text: lan.files.file_menu_down, onclick: function() { + getFileBytes(path); + }},{text: lan.files.file_menu_del, onclick: function() { + deleteFile(path); + }}); + } + else if(isImage(type)){ + options.items.push({text: lan.files.file_menu_img, onclick: function() { + getImage(path); + }},{text: lan.files.file_menu_down, onclick: function() { + getFileBytes(path); + }},{text: lan.files.file_menu_del, onclick: function() { + deleteFile(path); + }}); + } + else{ + options.items.push({text: lan.files.file_menu_down, onclick: function() { + getFileBytes(path); + }},{text: lan.files.file_menu_del, onclick: function() { + deleteFile(path); + }}); + } + return options; } //右键批量操作 function rightMenuClickAll(e){ - var menu = $("#rmenu"); - var windowWidth = $(window).width(), - windowHeight = $(window).height(), - menuWidth = menu.outerWidth(), - menuHeight = menu.outerHeight(), - x = (menuWidth + e.clientX < windowWidth) ? e.clientX : windowWidth - menuWidth, - y = (menuHeight + e.clientY < windowHeight) ? e.clientY : windowHeight - menuHeight; - - menu.css('top', y) - .css('left', x) - .css('position', 'fixed') - .css("z-index","1") - .show(); + var menu = $("#rmenu"); + var windowWidth = $(window).width(), + windowHeight = $(window).height(), + menuWidth = menu.outerWidth(), + menuHeight = menu.outerHeight(), + x = (menuWidth + e.clientX < windowWidth) ? e.clientX : windowWidth - menuWidth, + y = (menuHeight + e.clientY < windowHeight) ? e.clientY : windowHeight - menuHeight; + + menu.css('top', y) + .css('left', x) + .css('position', 'fixed') + .css("z-index","1") + .show(); } //取目录大小 function getPathSize(){ - var path = encodeURIComponent($("#DirPathPlace input").val()); - layer.msg("正在计算,请稍候...",{icon:16,time:0,shade: [0.3, '#000']}) - $.post("/files/get_dir_size","path="+path,function(rdata){ - layer.closeAll(); - $("#pathSize").text(rdata.msg); - },'json'); + var path = encodeURIComponent($("#DirPathPlace input").val()); + layer.msg("正在计算,请稍候...",{icon:16,time:0,shade: [0.3, '#000']}) + $.post("/files/get_dir_size","path="+path,function(rdata){ + layer.closeAll(); + $("#pathSize").text(rdata.msg); + },'json'); } $("body").not(".def-log").click(function(){ - $("#rmenu").hide() + $("#rmenu").hide() }); //指定路径 $("#DirPathPlace input").keyup(function(e){ - if(e.keyCode == 13) { - var fpath = $(this).val(); - fpath = filterPath(fpath); - getFiles(fpath); - } + if(e.keyCode == 13) { + var fpath = $(this).val(); + fpath = filterPath(fpath); + getFiles(fpath); + } }); function pathPlaceBtn(path){ - var html = ''; - var title = ''; - if(path == '/'){ - html = '
    • '+lan.files.path_root+'
    • '; - } else { - var dst_path = path.split("/"); - for(var i = 0; i'+dst_path[i]+''; - } - } - - html = '
        '+html+'
      '; - $("#PathPlaceBtn").html(html); - $("#PathPlaceBtn ul li a").click(function(e){ - var go_path = $(this).attr("title"); - if(go_path.length>1){ - if(go_path.substr(go_path.length-1,go_path.length) =='/'){ - go_path = go_path.substr(0,go_path.length-1); - } - } - getFiles(go_path); - e.stopPropagation(); - }); - pathLeft(); + var html = ''; + var title = ''; + if(path == '/'){ + html = '
    • '+lan.files.path_root+'
    • '; + } else { + var dst_path = path.split("/"); + for(var i = 0; i'+dst_path[i]+''; + } + } + + html = '
        '+html+'
      '; + $("#PathPlaceBtn").html(html); + $("#PathPlaceBtn ul li a").click(function(e){ + var go_path = $(this).attr("title"); + if(go_path.length>1){ + if(go_path.substr(go_path.length-1,go_path.length) =='/'){ + go_path = go_path.substr(0,go_path.length-1); + } + } + getFiles(go_path); + e.stopPropagation(); + }); + pathLeft(); } //计算当前目录偏移 function pathLeft(){ - var UlWidth = $("#PathPlaceBtn ul").width(); - var SpanPathWidth = $("#PathPlaceBtn").width() - 50; - var Ml = UlWidth - SpanPathWidth; - if(UlWidth > SpanPathWidth ){ - $("#PathPlaceBtn ul").css("left",-Ml); - } - else{ - $("#PathPlaceBtn ul").css("left",0); - } + var UlWidth = $("#PathPlaceBtn ul").width(); + var SpanPathWidth = $("#PathPlaceBtn").width() - 50; + var Ml = UlWidth - SpanPathWidth; + if(UlWidth > SpanPathWidth ){ + $("#PathPlaceBtn ul").css("left",-Ml); + } + else{ + $("#PathPlaceBtn ul").css("left",0); + } } //路径快捷点击 $("#PathPlaceBtn").on("click", function(e){ - if($("#DirPathPlace").is(":hidden")){ - $("#DirPathPlace").css("display","inline"); - $("#DirPathPlace input").focus(); - $(this).hide(); - }else{ - $("#DirPathPlace").hide(); - $(this).css("display","inline"); - } - $(document).one("click", function(){ - $("#DirPathPlace").hide(); - $("#PathPlaceBtn").css("display","inline"); - }); - e.stopPropagation(); + if($("#DirPathPlace").is(":hidden")){ + $("#DirPathPlace").css("display","inline"); + $("#DirPathPlace input").focus(); + $(this).hide(); + }else{ + $("#DirPathPlace").hide(); + $(this).css("display","inline"); + } + $(document).one("click", function(){ + $("#DirPathPlace").hide(); + $("#PathPlaceBtn").css("display","inline"); + }); + e.stopPropagation(); }); $("#DirPathPlace").on("click", function(e){ - e.stopPropagation(); + e.stopPropagation(); });