<%@ Page Language="C#" MasterPageFile="Main.Master" AutoEventWireup="true" CodeFile="fileManage.aspx.cs" Inherits="eFrameWork.Manage.fileManage" %>
<%@ Import Namespace="EKETEAM.FrameWork" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div class="nav">您当前位置：<a href="Default.aspx">首页</a>&nbsp;->&nbsp;<asp:Literal id="litNav" runat="server" /></div>
<%if (eRegisterInfo.Base == 0 && eRegisterInfo.Loaded)
  { %>
    <div style="margin:6px;line-height:25px;font-size:13px;">
<div class="tips" style="margin-bottom:6px;"><b>未授权提示</b><br><a href="http://frame.eketeam.com/getSerialNumber.aspx" style="color:#ff0000;" target="_blank">申请临时授权</a>,享更多功能。</div>
   </div>
 <%} %>
 <style>
  html, body {
    margin:0px;padding:0px;font-size:13px;
    }
</style>
 <link href="../Plugins/eTree/default/style.css" rel="stylesheet" type="text/css" />
 <link href="../Plugins/fileManage/style.css" rel="stylesheet" type="text/css" />
<script>
var path = "<%=path%>";
</script>
<script src="../Plugins/fileManage/auto-line-number.js"></script>
<script src="../Plugins/fileManage/fileManage.js"></script>
<script src="../Scripts/clipboard.min.js?beacon=7"></script>
<script>
var menu_a=null;
var menu_type=0;
var menu_name = "";
function _down()
{
    var url = "?" + (typeof (ModelID) == "string" && ModelID.length > 0 ? "ModelID=" + ModelID + "&" : "") + "act=download" + (path.length > 0 ? "&path=" + path : "") + "&name=" + encodeURIComponent(menu_name);
    //alert(url);
    window.open(url);
};
function contextmenu(evt,obj,type,name)
{
    //type 1文件夹，2文件
    if (evt.button != 2) { return; }
    var ext = $(obj).attr("ext");

    if (".bak".indexOf(ext) == -1 || ext.length == 0) {
        $(".etreeMenu a:contains('备份')").show();
    }
    else {
        $(".etreeMenu a:contains('备份')").hide();
    }
    if (".html.htm.css.js.txt".indexOf(ext) > -1 && ext.length>2)
    {
        $(".etreeMenu a:contains('编辑')").show();
    }
    else
    {
        $(".etreeMenu a:contains('编辑')").hide();
    }
    if (type == 2)
    {
        //$(".etreeMenu a:contains('下载')").attr("href","?modelid=" + ModelID + "&act=download" + (path.length>0 ? "&path=" + path : "") + "&name=" + name);
        $(".etreeMenu a:contains('下载')").show();
    }
    else {
        $(".etreeMenu a:contains('下载')").hide();
    }
    if (".zip".indexOf(ext) == -1 || ext.length==0) {
        $(".etreeMenu a:contains('压缩')").show();
    }
    else {
        $(".etreeMenu a:contains('压缩')").hide();
    }
    if (".zip".indexOf(ext) > -1 && ext.length > 2) {
        $(".etreeMenu a:contains('解压')").show();
    }
    else {
        $(".etreeMenu a:contains('解压')").hide();
    }
	menu_type=type;
	menu_a=obj;
	menu_name=name;
	var oRect = obj.getBoundingClientRect();	
	var top = eScroll().top + oRect.top + obj.offsetHeight;
	var left = eScroll().left + oRect.right - obj.offsetWidth;	
	top= eScroll().top + evt.clientY;
	left= eScroll().left + evt.clientX;
	var menu=getobj("etreeMenu");
	menu.style.top=top + "px";
	menu.style.left=left + "px";
	show_etreeMenu();	
};

function bodyck(e)
{
	hide_etreeMenu();
};
function bodykd(e)
{
	e=window.event||e; 
	if(e.keyCode==27){hide_etreeMenu();}
};
function show_etreeMenu()
{
	var menu=getobj("etreeMenu");
	menu.style.display="";
	if(document.body.addEventListener){document.body.addEventListener("keydown",bodykd, false);}else{document.body.attachEvent("onkeydown",bodykd);}
	if(document.body.addEventListener){document.body.addEventListener("click",bodyck, false);}else{document.body.attachEvent("onclick",bodyck);}
};
function hide_etreeMenu()
{
	var menu=getobj("etreeMenu");
	menu.style.display="none";
	if (document.body.addEventListener){document.body.removeEventListener('keydown', bodykd, false);}else{document.body.detachEvent("onkeydown",bodykd);}
	if (document.body.addEventListener){document.body.removeEventListener('click', bodyck, false);}else{document.body.detachEvent("onclick",bodyck);}
};
$(document).ready(function()
{
	//document.body.oncontextmenu=function(){return false;};	
});


function _rename()
{
    //ReName(menu_name,menu_type);
    layer.prompt({ title: '输入文件' + (menu_type == 1 ? '夹' : '') + '名称', formType: 3, value: menu_name }, function (value, index) {
        var url = "?" + (typeof (ModelID) == "string" && ModelID.length > 0 ? "ModelID=" + ModelID + "&" : "") + "act=rename" + (path.length > 0 ? "&path=" + path : "") + "&type=" + menu_type + "&oldname=" + menu_name + "&newname=" + value;
        layer.close(index);
        document.location.href = url;
    });
};
function _back()
{
	var url="?" + (typeof(ModelID)=="string" && ModelID.length > 0 ? "ModelID=" + ModelID + "&" : "" ) + "act=bak&type=" + menu_type + (path.length>0 ? "&path=" + path : "") + "&name=" + encodeURIComponent(menu_name);
	document.location.assign(url);
};
function _del()
{
	//var _back=confirm('您确定要删除该文件' + (menu_type==1 ? '夹' : '') + '吗？'); if(!_back){return;};
	var url="?" + (typeof(ModelID)=="string" && ModelID.length > 0 ? "ModelID=" + ModelID + "&" : "" ) + "act=del&type=" + menu_type + (path.length>0 ? "&path=" + path : "") + "&name=" + encodeURIComponent(menu_name);
    //document.location.assign(url);
	layer.confirm('您确定要删除该文件' + (menu_type == 1 ? '夹' : '') + '吗？', {
	    btn: ['删除', '取消'] //按钮
        , shadeClose: true //点击遮罩关闭层
	}, function () {
	    document.location.assign(url);
	});
};


function _edit()
{
     edit(menu_name);
};
function _zip()
{
    var url = "?" + (typeof (ModelID) == "string" && ModelID.length > 0 ? "ModelID=" + ModelID + "&" : "") + "act=zip&type=" + menu_type + (path.length > 0 ? "&path=" + path : "") + "&name=" + encodeURIComponent(menu_name);
    document.location.assign(url);
};
function _unzip()
{
    var _back = confirm('解压会覆盖现有文件,确定要执行吗?');
    if(!_back){return;};
    var url = "?" + (typeof (ModelID) == "string" && ModelID.length > 0 ? "ModelID=" + ModelID + "&" : "") + "act=unzip&type=" + menu_type + (path.length > 0 ? "&path=" + path : "") + "&name=" + encodeURIComponent(menu_name);
    document.location.assign(url);
};
</script>
<body>
<div id="etreeMenu" class="etreeMenu" style="display:none;z-index:1000;">
<%if (model.Power.Table.Columns.Contains("rename") && model.Power["rename"].ToString().ToLower() == "true")
  { %><a href="javascript:;" onclick="_rename();">重命名</a><%} %>
<%if (model.Power.Table.Columns.Contains("edit") && model.Power["edit"].ToString().ToLower() == "true")
  { %><a href="javascript:;" onclick="_edit();">编辑</a><%} %>
<%if (model.Power.Table.Columns.Contains("backup") && model.Power["backup"].ToString().ToLower() == "true") 
  { %><a href="javascript:;" onclick="_back();">备份</a><%} %>
<%if (model.Power.Table.Columns.Contains("zip") && model.Power["zip"].ToString().ToLower() == "true") 
  { %><a href="javascript:;" onclick="_zip();">压缩</a><%} %>
<%if (model.Power.Table.Columns.Contains("unzip") && model.Power["unzip"].ToString().ToLower() == "true") 
  { %><a href="javascript:;" onclick="_unzip();">解压</a><%} %>
<%if (model.Power.Table.Columns.Contains("download") && model.Power["download"].ToString().ToLower() == "true")
  { %><a href="javascript:;" onclick="_down();" _target="_blank">下载</a><%} %>
<%if (model.Power.Table.Columns.Contains("del") && model.Power["del"].ToString().ToLower() == "true")  
  { %><a href="javascript:;" onclick="_del();">删除</a><%} %>
</div>
<div style="margin:10px;">
<asp:Literal id="litBody" runat="server" />

</div>

<script type="text/javascript">
    var clip = new Clipboard(".copypath");
    clip.on('success', function (e) {
        //layer.open({ content: "复制成功!请打开要赠送好友的聊天窗口粘贴.", skin: "msg", time: 2 });
        layer.msg("地址复制成功!");
    });

    clip.on('error', function (e) {
        //alert("复制失败")
    });
</script>
    </asp:Content>