<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ShareMng.aspx.cs" Inherits="Webdisk.ShareMng" %>
<%@ Register TagPrefix="uc" TagName="uc1" Src="~/Top.ascx" %>
<%@ Register TagPrefix="uc" TagName="uc2" Src="bottom.ascx" %>
<%@ Import Namespace="Webdisk.DAL" %>
<%@ Import Namespace="Global" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head>
    <link href="css/common.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" href="css/treeview.css" />
    <link href="js/artDialog/css/ui-dialog.css" rel="stylesheet" type="text/css" />
    <link href="js/lib/pagination.css" rel="stylesheet" type="text/css" />

    <script src="js/jquery-1.7.1.min.js" type="text/javascript"></script>
    <script src="js/lib/jquery.pagination.js" type="text/javascript"></script>
    <script src="js/treeview.js" type="text/javascript"></script>
    <script src="js/artDialog/dist/dialog-plus.js" type="text/javascript"></script>
    <script src="js/index.js" type="text/javascript"></script>
    <title>共享文件</title>
</head>
<body>
    <!-- Header Start -->
    <div>
	    <uc:uc1 ID="top" runat="server" />
    </div>
    <!-- Header End -->
    <!-- Content Start -->
    <div class="content">
        <div class="cLeft2 mt30">
            <div class="block06">
                <div class="title02">
                    <h4>文件分类</h4>
                </div>
                <div id="sidetreecontrol" class="menuBut2 mt10">
                    <a href="?#" class="close">收起</a><a href="?#" class="open">展开</a></div>
                    <ul id="tree" class="mt10 ml20 treeview">
                        <%=template.getMenu("shareKind", Session["username"] == null ? "" : Session["username"].ToString()) %>
                    </ul>
            </div>
        </div>
        <div class="cRight3 mt30">
            <div class="searchBox3">
                <form id="search" method="post" target="_self" action="sharemng.aspx">
                <p>
                    <input class="sInput2" name="key" title="请输入搜索内容...." value="<%=Request["key"]==null?"":Request["key"].ToString() %>" type="text" id="key" />
                    <input class="sBut2" name="" type="submit" value=""/>
                    <a href="#" onclick="adSearch.showAdvanceSearch('setAdSearch.aspx?target=shareMng')">高级搜索</a></p>
                <p class="mt10">
                    <input name="fileType" type="radio" value="all" checked=checked/>
                    全部
                    <input name="fileType" type="radio" value="doc,docx" />
                    DOC
                    <input name="fileType" type="radio" value="jpg,jpeg,gif,bmp" />
                    JPG
                    <input name="fileType" type="radio" value="mp3,wma,wav,mod,mid,cd" />
                    MP3
                    <input name="fileType" type="radio" value="pdf" />
                    PDF
                    <input name="fileType" type="radio" value="xls,xlsx" />
                    XLS</p>
                </form>
            </div>
            <div class="title04 mt20">
                <h2>
                    共享文件列表</h2>
            </div>
            <div class="zyBlock2 mt10">
                <div class="xsfs" style="float:none;">
                    显示方式：<a runat="server" id="sltBtn">缩略显示</a> | <a class="slt" runat="server" id="lbBtn" Property="disabled:true">列表显示</a></div>
                    <input type="hidden" id="shareKind" />
                    <div id="divlist" runat="server">
                    <table class="zyList" id="sharedg" width="100%" border="0" cellspacing="0" cellpadding="0" style="clear:both;">
                        <tr class="title" id="title"> 
                            <td align="center" style="width:298px;">
                                文件名
                            </td>
                            <td align="center" style="width:75px;">
                                教材版本
                            </td>
                            <td align="center" style="width:75px;">
                                文件类型
                            </td>
                            <td align="center" style="width:60px;">
                                文件格式
                            </td>
                            <td align="center" style="width:250px;">
                                文件备注
                            </td>
                        </tr>
                        <tr class="td1" id="item">
                            <td class="name" align="left" id="filename">
                            </td>
                            <td align="center" id="jcvar">
                            </td>
                            <td align="center" id="zyType">
                            </td>
                            <td align="center" id="fileext">
                            </td>
                            <td align="center" id="note">
                            </td>
                        </tr>
                    </table>
                    </div>
                    <div id="divSlt" runat="server">
                    <ul class="menuSlt" id="shareul">
                    <li id="items" style="text-align:center">
                        <table><tr><td width="220" height="80" align="center" id="pic"></td></tr></table><br/>
                        <a id="filenames" class="files"></a><br />
                    </li>
                    </ul>
                    </div>
                <br/>
                <div id="Pagination" class="pageList" align="center" style="float:left;"><!-- 这里显示分页 --></div>
            </div>
        </div>
		<div class="clear"></div>
    </div>
    <!-- Content End -->
    <!-- Footer Start -->
    <div id="foot">
        <div class="foot">
            <uc:uc2 ID="bootom" runat="server" />
        </div>
    </div>
    <!-- Footer End -->
</body>
</html>
<script type="text/javascript" language="javascript">
    setHeadMenu(3);
    var strUrl=window.location.href.toString();
    var rowTem,rowsTem,url="",tempPara="";
    function init(Kind) {
        $('#key').attr("value", '<%=Request["key"]==null?"":Request["key"].ToString() %>');
        if(Kind!=undefined)
            $("#shareKind").val(Kind);
        var num_entries = 0;
        //设置ajax请求为同步
        $.ajaxSetup({ async: false ,cache:false});

        var fileType = $('input:radio[name=\'fileType\'][checked]').val();

        url="FileSpaceHandler.ashx?cmd=GetShareAllpathPage";
        tempPara="";

        if($("#shareKind").val()=="")
            tempPara+='&kind=<%=Request["kind"]==null?"":Request["kind"].ToString() %>';
        else 
            tempPara+='&kind='+$("#shareKind").val();
        
        $('#key').attr("value", '<%=Request["key"]==null?"":Request["key"].ToString() %>');
        var key=$("#key").val();

        tempPara+='&fileType=' + fileType+'&txttype=<%=Request["txttype"]==null?"":Request["txttype"].ToString() %>&key='+key+'&txttime1=<%=Request["txttime1"]==null?"":Request["txttime1"].ToString() %>&txttime2=<%=Request["txttime2"]==null?"":Request["txttime2"].ToString() %>&txtsize1=<%=Request["txtsize1"]==null?"":Request["txtsize1"].ToString() %>&txtsize2=<%=Request["txtsize2"]==null?"":Request["txtsize2"].ToString() %>&txtnote=<%=Request["txtnote"]==null?"":Request["txtnote"].ToString() %>&txtname=<%=Request["txtname"]==null?"":Request["txtname"].ToString() %>';

        url+=tempPara;
        $.getJSON(url, null, function (obj) {
            num_entries = obj.total;
        });
        $("#Pagination").pagination(num_entries, {
            prev_text: "上一页",
            next_text: "下一页",
            num_edge_entries: 1, //边缘页数
            num_display_entries: 4, //主体页数
            callback: pageselectCallback,
            items_per_page:<%=Session["username"]==null?10:Convert.ToInt32(Common.GetListCount(Session["username"].ToString())) %> //每页显示项数
        });
    };
    function SetData(page_index) {
        var tempUrl="";
        if($("#shareKind").val()=="")
            tempUrl=url+'&page=' + page_index+ '&rows='+<%=Session["username"]==null?10:Convert.ToInt32(Common.GetListCount(Session["username"].ToString())) %>;
        else
            tempUrl=url+'&page=' + page_index+ '&rows='+<%=Session["username"]==null?10:Convert.ToInt32(Common.GetListCount(Session["username"].ToString())) %>
            
        $.getJSON(tempUrl, null, function (obj) {
            //先擦除下数据
            $("tr").eq(1).nextAll().remove();
            $("#shareul li").eq(0).nextAll().remove();
            //拷贝模版
            if(rowTem==undefined){
                rowTem=$("#item").clone();
            }
            if(rowsTem==undefined){
                rowsTem=$("#items").clone();
            }
            //擦除模版数据
            $("tr").eq(0).next().remove();
            $("#shareul li").eq(0).remove();

            for (var i = 0; i < obj.rows.length; i++) {
                row = rowTem.clone();
                rows = rowsTem.clone();

                row.find("#filename").html("<img src=\"" + obj.rows[i].showPicFileext + "\" width=\"15px\" height=\"15px\" class=\"icon\"/>" + obj.rows[i].filename);
                rows.find("#pic").html("<a href=\"resourceDetail.aspx?fileId="+obj.rows[i].id+"\"><img src=\"" + obj.rows[i].showPicFileext2 + "\" width=\"100px\" height=\"100px\"/></a>");
                rows.find("#filenames").html(obj.rows[i].filename);
                row.find("#jcvar").text(obj.rows[i].jcvar);
                row.find("#zyType").text(obj.rows[i].zytype);
                row.find("#fileext").text(obj.rows[i].fileext);
                row.find("#note").html("<div class='note'>"+obj.rows[i].note+"</div>");
                row.appendTo("#sharedg");
                rows.appendTo("#shareul");
            }
        });
    }
    function pageselectCallback(page_index, jq) {
        SetData(page_index);
        return false;
    }
    $(function () {
        //树状菜单
        $("#tree").treeview({
            collapsed: true,
            animated: "medium",
            control: "#sidetreecontrol",
            persist: "location"
        });
        //保持文件的搜索类型
        $("input:radio[name='fileType']").val(['<%=Request["fileType"]==null?"all":Request["fileType"].ToString() %>']);
        
        init();
         if(url.indexOf("?")>-1)
            if(url.indexOf("showDataType")==-1) tempPara="&"+url.substr(url.indexOf("?")+1);
            else tempPara=url.substr(url.indexOf("?")+1);
        else tempPara="";
        $("#lbBtn").attr("href", 'ShareMng.aspx?'+(tempPara.indexOf("showDataType")>-1?tempPara.replace(tempPara.substr(tempPara.indexOf("showDataType"),14),"showDataType=0"):'showDataType=0'+tempPara));
        $("#sltBtn").attr("href", 'ShareMng.aspx?'+(tempPara.indexOf("showDataType")>-1?tempPara.replace(tempPara.substr(tempPara.indexOf("showDataType"),14),"showDataType=1"):'showDataType=1'+tempPara));
    });    
</script>