<%@ Page Language="c#" CodeBehind="share.aspx.cs" AutoEventWireup="True" Inherits="Webdisk.share" %>

<%@ Register Src="~/userleft.ascx" TagPrefix="uc1" TagName="userleft" %>
<%@ Register Src="~/usertop.ascx" TagPrefix="uc1" TagName="usertop" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>共享文件和目录</title>
    <link rel="stylesheet" href="css/bootstrap.min.css">
	<link rel="stylesheet" href="css/atlantis.css">
</head>
<body>
    <div class="wrapper">
        <uc1:usertop runat="server" ID="usertop" />
    <!-- begin::navigation -->
    <uc1:userleft runat="server" ID="userleft" />
    <!-- end::navigation -->
   <div class="main-panel">

        <div class="content">
            <div class="page-inner">

            <div>

                <div class="card">
                    <div class="card-body">
                        <div class="row">&nbsp;&nbsp;&nbsp;&nbsp;<img src="pics/filesys.gif" width="16" height="16" align="absMiddle">&nbsp;&nbsp;&nbsp;&nbsp;<h5><b>目录和文件共享</b></h5>
                            &nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:history.go(-1);"><img src="pics/link_back.gif" border="0" align="absMiddle"></a></div>
                        <form runat="server">

                            <table width="100%" border="0">
                                <tr>
                                    <td>以下是您共享的目录和文件：</td>
                                    <td align="right">
                                        <div class="custom-control custom-checkbox mr-3">
												&nbsp;<input type="checkbox" class="custom-control-input" id="overshare" checked name="overshare" runat="server" onchange="EditOpt();">
												<label class="custom-control-label" for="overshare"><font color="#0000ff">覆盖子目录及文件的共享设置</font></label>
											</div>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2">
                                        <asp:ListBox ID="ListBox6" runat="server" Width="100%" Height="100px" CssClass="form-control"></asp:ListBox>
                                        <asp:Label ID="Label1" runat="server"></asp:Label></td>
                                </tr>
                            </table>
                            <table width="100%" border="0">
                                <tr>
                                    <td width="100%">请指定共享权限：</td>
                                </tr>
                                <tr>
                                    <td>
                                        <fieldset class="form-group">
                                            <div class="row">
                                                <div class="col-sm-10">
                                                    <div class="custom-control custom-radio custom-control-inline">
                                                        <input type="radio" id="click0" name="shareopt" class="custom-control-input" onclick="javascript: document.all.Panel1.style.display = 'none'; document.all.Panel2.style.display = 'none'; document.all.Panel3.style.display = 'none';document.all.Panel5.style.display = 'none';" value="0" checked runat="server">
                                                        <label class="custom-control-label" for="click0">不共享</label>
                                                    </div>
                                                    <div class="custom-control custom-radio custom-control-inline">
                                                        <input type="radio" id="click1" name="shareopt" class="custom-control-input" onclick="javascript: document.all.Panel1.style.display = ''; document.all.Panel2.style.display = 'none'; document.all.Panel3.style.display = ''; document.all.Panel5.style.display = '';" value="1" runat="server">
                                                        <label class="custom-control-label" for="click1">共享给好友</label>
                                                    </div>
                                                    <div class="custom-control custom-radio custom-control-inline">
                                                        <input type="radio" id="click2" name="shareopt" class="custom-control-input" value="2" onclick="javascript: document.all.Panel1.style.display = ''; document.all.Panel2.style.display = 'none'; document.all.Panel3.style.display = '';  document.all.Panel5.style.display = 'none';" runat="server">
                                                        <label class="custom-control-label" for="click2">所有人可见</label>
                                                    </div>
                                                    <div class="custom-control custom-radio custom-control-inline">
                                                        <input type="radio" id="click3" name="shareopt" class="custom-control-input" value="3" onclick="javascript: document.all.Panel1.style.display = 'none'; document.all.Panel2.style.display = ''; document.all.Panel3.style.display = '';document.all.Panel5.style.display = 'none';" runat="server">
                                                        <label class="custom-control-label" for="click3">指定人可见</label>
                                                    </div>
                                                </div>
                                            </div>
                                        </fieldset>

                                    </td>
                                </tr>
                            </table>
                            <table width="100%" border="0" id="Panel3" runat="server" style="display: none">
                                <tr>
                                    <td width="100%" height="14">
                                        <div class="form-group row align-items-center">
                                            &nbsp;&nbsp;&nbsp;&nbsp;共享大类：
												 <div class="col-auto my-1">
                                                     <select id="kind1" onchange="Result();" name="kind1" runat="server" class="form-control">
                                                     </select>
                                                 </div>
                                            共享小类：
												<div class="col-auto my-1">
                                                    <select id="kind2" name="kind2" runat="server" onchange="document.all.hidkind.value=this.value" class="form-control">
                                                        <option value="不指定" selected>不指定</option>
                                                    </select>
                                                </div>
                                        </div>
                                        <input id="hidkind" style="width: 13px; height: 22px" type="hidden" size="1" name="hidkind"
                                            runat="server">
                                    </td>
                                </tr>
                                <tr>
                                    <td width="100%">
                                        <div class="form-group row">
                                            <label for="uploadcode" class="col-sm-3 col-form-label">文件夹查看密码(对文件无效)</label>
                                            <div class="col-sm-7">
                                                <input class="form-control w-50" id="TextBox3" type="text" name="TextBox3" runat="server">
                                            </div>
                                        </div>

                                    </td>
                                </tr>
                            </table>
                            <table width="100%" border="0" id="Panel1" runat="server" style="display: none">
                                <tr>
                                    <td width="49%">
                                        <fieldset class="form-group">
                                            <div class="row">
                                                <legend class="col-form-label col-sm-3 pt-0">指定特殊权限</legend>
                                                <div class="col-sm-7">
                                                    <div class="custom-control custom-checkbox custom-control-inline">
                                                        <input type="checkbox" id="CheckBox3" class="custom-control-input" runat="server">
                                                        <label class="custom-control-label" for="CheckBox3">可添加</label>
                                                    </div>
                                                    <div class="custom-control custom-checkbox custom-control-inline">
                                                        <input type="checkbox" id="CheckBox4" name="customRadioInline2" class="custom-control-input" runat="server">
                                                        <label class="custom-control-label" for="CheckBox4">可修改（覆盖）</label>
                                                    </div>
                                                    <div class="custom-control custom-checkbox custom-control-inline">
                                                        <input type="checkbox" id="CheckBox5" name="customRadioInline2" class="custom-control-input" runat="server">
                                                        <label class="custom-control-label" for="CheckBox5">可删除</label>
                                                    </div>
                                                </div>
                                            </div>
                                        </fieldset>
                                    </td>
                                </tr>
                            </table>
                            <table width="100%" border="0" id="Panel5" runat="server" style="display: none">
                                <tr>
                                    <td width="100%">
                                        <fieldset class="form-group">
                                            <div class="row">
                                                <legend class="col-form-label col-sm-3 pt-0">可以指定共享给某组好友：</legend>
                                                <div class="col-sm-7">
                                                    <%=friendteam %>
                                                </div>
                                            </div>
                    </fieldset>
										</TD>
										</TR>
									</TABLE>
                    <div class="container" id="Panel2" runat="server" style="display: none">
  <div class="row">
    <div class="col-sm">
      以下是有列表权限的用户
        <select id="ListBox1" multiple class="form-control h-50 w-75" runat="server">
                                                </select><br>
                                                 <input id="hidListBox1" type="hidden" runat="server" size="1">
                                                <div class="row">
        <input class="btn btn-outline-light" onclick="javascript: shareuser('search_user.aspx?addtype=1');"
                                                    type="button" value="添加">
                                                &nbsp;&nbsp; 
                                                <input class="btn btn-outline-light" type="button" value="移除" onclick="$('#ListBox1').find('option:selected').remove();">
                                                &nbsp;&nbsp;&nbsp;
                                                <input class="btn btn-outline-light" onclick="javascript: if (document.all.ListBox1.value != '') shareuser('userinfo.aspx?username=' + document.all.ListBox1.value);"
                                                    type="button" value="用户信息"></div>
    </div>
    <div class="col-sm">
     以下是有添加权限的用户
 <select id="ListBox2" multiple class="form-control h-50 w-75" runat="server">
                                                </select><br>
                                                 <input id="hidListBox2" type="hidden" runat="server" size="1">
        <div class="row">
                                                <input class="btn btn-outline-light" onclick="javascript: shareuser('search_user.aspx?addtype=2');"
                                                    type="button" value="添加">&nbsp;&nbsp; 
                                               
                                                <input class="btn btn-outline-light" type="button" value="移除" onclick="$('#ListBox2').find('option:selected').remove();">&nbsp;
												<input class="btn btn-outline-light" onclick="javascript: if (document.all.ListBox2.value != '') shareuser('userinfo.aspx?username=' + document.all.ListBox2.value);"
                                                    type="button" value="用户信息">
    </div></div>
    <div class="col-sm">
      以下是有修改权限的用户
 <select id="ListBox3" multiple class="form-control h-50 w-75" runat="server">
                                                </select>
                                                <br><input id="hidListBox3" type="hidden" runat="server" size="1">
        <div class="row">
                                                
                                                <input class="btn btn-outline-light" id="Button1" onclick="javascript: shareuser('search_user.aspx?addtype=3');"
                                                    type="button" value="添加">
                                                &nbsp;&nbsp; 
                                               
                                                <input class="btn btn-outline-light" type="button" value="移除" onclick="$('#ListBox3').find('option:selected').remove();">
                                                &nbsp;&nbsp;&nbsp;
                                                <input class="btn btn-outline-light" onclick="javascript: if (document.all.ListBox3.value != '') shareuser('userinfo.aspx?username=' + document.all.ListBox3.value);"
                                                    type="button" value="用户信息">
            </div>
    </div>
  </div>

<div class="container">
  <div class="row">
    <div class="col-sm">
      以下是有删除权限的用户
 <select id="ListBox4" multiple class="form-control h-50 w-75" runat="server">
                                                </select>
                                                <br>
                                                 <input id="hidListBox4" type="hidden" runat="server" size="1">
         <div class="row">
                                                <input class="btn btn-outline-light" onclick="javascript: shareuser('search_user.aspx?addtype=4');"
                                                    type="button" value="添加">
                                                &nbsp;&nbsp; 
                                               
                                                <input class="btn btn-outline-light" type="button" value="移除" onclick="$('#ListBox4').find('option:selected').remove();">
                                                &nbsp;
                                                <input class="btn btn-outline-light" onclick="javascript: if (document.all.ListBox4.value != '') shareuser('userinfo.aspx?username=' + document.all.ListBox4.value);"
                                                    type="button" value="用户信息">
    </div> </div>
    <div class="col-sm">
      以下是有下载权限的用户
 <select id="ListBox5" multiple class="form-control h-50 w-75" runat="server">
                                                </select>
                                                <br>
                                                 <input id="hidListBox5" type="hidden" runat="server" size="1">
         <div class="row">
                                                <input class="btn btn-outline-light" onclick="javascript: shareuser('search_user.aspx?addtype=5');"
                                                    type="button" value="添加" name="Button9">
                                                &nbsp;&nbsp; 
                                               
                                                <input class="btn btn-outline-light" type="button" value="移除" onclick="$('#ListBox5').find('option:selected').remove();">
                                                &nbsp;
                                                <input class="btn btn-outline-light" onclick="javascript: if (document.all.ListBox5.value != '') shareuser('userinfo.aspx?username=' + document.all.ListBox5.value);"
                                                    type="button" value="用户信息">
    </div></div>
    <div class="col-sm">
     
    </div>
  </div>
</div>
                        </div>
                    <br>
                    <div align="center" class="row justify-content-center">
                        <input class="btn btn-primary" id="Button3" type="button" value="完成设置" onclick="submitset();" name="Button3" runat="server" onserverclick="Button3_ServerClick">
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <input class="btn btn-light" onclick="javascript: history.go(-1);" type="button" value="返回前页" name="Submit">
                        <input id="Hidden1" type="hidden" name="Hidden1" runat="server" size="1">
                        <input id="type" type="hidden" size="1" name="type" runat="server">
                    </div>
                    </form>
                </div>
         </div> </div> </div>
        <!-- end::main content -->
</body>
</html>
<script src="js/jquery.3.2.1.min.js"></script>
	<script src="js/popper.min.js"></script>
	<script src="js/bootstrap.min.js"></script>
	<!-- jQuery UI -->
	<script src="js/jquery-ui.min.js"></script>
	<script src="js/jquery.ui.touch-punch.min.js"></script>
	<script src="js/sweetalert.min.js"></script>
	<!-- jQuery Scrollbar -->
	<script src="js/jquery.scrollbar.min.js"></script>
	<!-- Atlantis JS -->
    <script src="js/webfont.min.js"></script>
	<script src="js/atlantis.js"></script>
<script src="js/function.js"></script>

<script>
    function getRbGroupValue(rbGroup) {
        for (var i = 0; i < rbGroup.length; i++) {
            if (rbGroup[i].checked) return rbGroup[i].value;
        }
        return false;
    }
    function shareuser(url) {
        window.open(url, '', 'scrollbars=yes,resizable=yes,status=no,toolbar=no,menubar=no,location=no,width=1000,height=500');
    }
    function Result() {
        var kind = document.getElementById("kind1");
        if (kind.value == '不指定') {
            document.all("kind2").length = 0;
            document.all("kind2").options.add(new Option('不指定', '不指定'));
        }
        else {
            $.post(
                "ajax.aspx",
                { action: "GetKind2All", id: kind.value }, get_Result_CallBack, "json"
            )
           // Webdisk.share.GetKind2All(kind.value, get_Result_CallBack);
        }
    }
 
    function get_Result_CallBack(response) {
        if (response != null) {
           
            document.all("kind2").length = 0;
            $.each(response, function (i, item) {
                var name = item.rootkind1;
                var id = item.rootkind3;
                    document.all("kind2").options.add(new Option(name, id));
            });
                if (document.all("kind2").options.length == 0) document.all("kind2").options.add(new Option("不指定", "0"));
                document.all.hidkind.value = document.all.kind2.value;
            }
        return;
    }
    function EditOpt() {
        $.post(
            "ajax.aspx",
            { action: "EditOpt", str: document.all.overshare.checked}
        )
        //Webdisk.share.EditOpt(document.all.overshare.checked);
    }
    if (getRbGroupValue(document.all.shareopt) == "1") {
        javascript: document.all.Panel1.style.display = ''; document.all.Panel2.style.display = 'none'; document.all.Panel3.style.display = ''; document.all.Panel5.style.display = '';
    }
    else if (getRbGroupValue(document.all.shareopt) == "2") {
        javascript: document.all.Panel1.style.display = ''; document.all.Panel2.style.display = 'none'; document.all.Panel3.style.display = ''; document.all.Panel5.style.display = 'none';
    }
    else if (getRbGroupValue(document.all.shareopt) == "3") {
        javascript: document.all.Panel1.style.display = 'none'; document.all.Panel2.style.display = ''; document.all.Panel3.style.display = '';document.all.Panel5.style.display = 'none';
    }
    function setopt() {
        var ss1 = $('#type').val().split(",");
        for (var j = 0; j < ss1.length; j++) {
            if (ss1[j] == "true") {
                if (j == 0) {
                    var ss = $('#Hidden1').val().split(",");
                    for (var i = 1; i < ss.length; i++) {
                        if ($("#ListBox1 option[value='" + ss[i] + "']").length == 0) $("#ListBox1").append("<option value='" + ss[i]+"'>" + ss[i] + "</option>");
                    }
                }
                else if (j == 1) {
                    var ss = $('#Hidden1').val().split(",");
                    for (var i = 1; i < ss.length; i++) {
                        if ($("#ListBox2 option[value='" + ss[i] + "']").length == 0) $("#ListBox2").append("<option value='" + ss[i] +"'>" + ss[i] + "</option>");
                    }
                }
                else if (j == 2) {
                    var ss = $('#Hidden1').val().split(",");
                    for (var i = 1; i < ss.length; i++) {
                        if ($("#ListBox3 option[value='" + ss[i] + "']").length == 0) $("#ListBox3").append("<option value='" + ss[i] +"'>" + ss[i] + "</option>");
                    }
                }
                else if (j == 3) {
                    var ss = $('#Hidden1').val().split(",");
                    for (var i = 1; i < ss.length; i++) {
                        if ($("#ListBox4 option[value='" + ss[i] + "']").length == 0) $("#ListBox4").append("<option value='" + ss[i] +"'>" + ss[i] + "</option>");
                    }
                }
                else if (j == 4) {
                    var ss = $('#Hidden1').val().split(",");
                    for (var i = 1; i < ss.length; i++) {
                        if ($("#ListBox5 option[value='" + ss[i] + "']").length == 0) $("#ListBox5").append("<option value='" + ss[i] +"'>" + ss[i] + "</option>");
                    }
                }
            }

        }
    }
    function submitset() {
        $("#ListBox1 option").each(function () {
            var val = $(this).val();
            $('#hidListBox1').val($('#hidListBox1').val() + $(this).val() + ",");
        })
        $("#ListBox2 option").each(function () {
            var val = $(this).val();
            $('#hidListBox2').val($('#hidListBox2').val() + $(this).val() + ",");
        })
        $("#ListBox3 option").each(function () {
            var val = $(this).val();
            $('#hidListBox3').val($('#hidListBox3').val() + $(this).val() + ",");
        })
        $("#ListBox4 option").each(function () {
            var val = $(this).val();
            $('#hidListBox4').val($('#hidListBox4').val() + $(this).val() + ",");
        })
        $("#ListBox5 option").each(function () {
            var val = $(this).val();
            $('#hidListBox5').val($('#hidListBox5').val() + $(this).val() + ",");
        })
    }
</script>
