www.gusucode.com > YulinCMS 雨林内容管理系统 2.0源码程序 > Admin/JS/FileManager.js

    

    // 新建目录
    function newDir()
    {
        var dirName = prompt('请输入你要新建的目录名称:','');
        if ((dirName) && (dirName!=""))
        {
            document.forms[0].elements[getClientId('txtFuncParam')].value = dirName;
            __doPostBack(getClientName('lbtnNewDir'), '');
        }
    }
    	
    // 新建文件
    function newFile()
    {
        var fileName = prompt('请输入你要新建的文件名称:','');
        if ((fileName) && (fileName!=""))
        {
            document.forms[0].elements[getClientId('txtFuncParam')].value = fileName;
            __doPostBack(getClientName('lbtnNewFile'), '');
        }
	}
		
	// 批量复制
	function batchCopy()
	{
	    var dir = escape("/");
	    var width = 580;
	    var height = 600;
	    var destPath = openDialog("SelectDir.aspx?Dir="+dir+"",width,height);
	    if ((destPath) && (destPath!=""))
	    {
	        document.forms[0].elements[getClientId('txtFuncParam')].value = destPath;
	        __doPostBack(getClientName('lbtnBatchCopy'), '');
	    }
	}
		
	// 批量移动
    function batchMove()
    {
       var dir = escape("/");
	    var width = 580;
	    var height = 600;
	    var destPath = openDialog("SelectDir.aspx?Dir="+dir+"",width,height);
	    if ((destPath) && (destPath!=""))
	    {
	        document.forms[0].elements[getClientId('txtFuncParam')].value = destPath;
	        __doPostBack(getClientName('lbtnBatchMove'), '');
	    }
   }
    	
    // 批量删除
    function batchDelete()
    {
        if (confirm('你确认要删除所选的目录或文件吗?'))
        {
            __doPostBack(getClientName('lbtnBatchDelete'),'');
        }
    }
    
    // 打开文件上传窗口
    function uploadFile()
    {
        if(location.href.indexOf("?")<0)
        {
            var urlParameter = "";
        }
        else
        {
            var urlParameter = location.href.substring(location.href.indexOf("?"));
        }
        var width = 520;
        var height = 360;
        var leftPos = (screen.availWidth-width) / 2;
        var topPos = (screen.availHeight-height) / 2;
        var popupWin = window.open('UploadFile.aspx'+urlParameter,'','width='+width+',height='+height+',scrollbars=yes,resizable=yes,titlebar=0,top='+topPos+',left='+leftPos+'');        
	
	 
	}
	
	// 增加文件上传框
	function addFile()
	{
	    var fileInputString = "<br><input type=\"file\" name=\"UploadedFile\" size=\"60\">";
	    document.getElementById("uploadFileList").insertAdjacentHTML("beforeEnd",fileInputString);
	}

		
	// 设置文件或目录属性
	function setAttribute(path)
	{
	    attribs = prompt('请给这个目录或者文件输入新的属性.\nA=Archive(存档),R=ReadOnly(只读),H=Hidden(隐藏),S=System(系统):','');
	    if ((attribs) && (attribs!=""))
	    {
	        document.forms[0].elements[getClientId('txtFuncParam')].value = path;
	        document.forms[0].elements[getClientId('txtFuncExtraParam')].value = attribs;
	        __doPostBack(getClientName('lbtnSetAttribute'), '');
	    }
	}
	
	// 修改文件名字
	function rename(path)
	{
	    oldName = path.substr(path.lastIndexOf('/')+1);
	    var newName = prompt('请输入新的目录或者文件名称:',oldName);
	    if ((newName) && (newName!=""))
	    {
	        document.forms[0].elements[getClientId('txtFuncParam')].value = path;
	        document.forms[0].elements[getClientId('txtFuncExtraParam')].value = newName;
	        __doPostBack(getClientName('lbtnRename'), '');
	    }
	}
	




    // 排序表格	
    function sortTable(obj,tableId,col,dataType)
    {
	    var tab = document.getElementById(tableId);	    
	    var tbody = tab.tBodies[0];
	    var rows = tbody.rows;
	    var arrTR = new Array;
	    for(var i=0;i<rows.length;i++)
	    {
	    	arrTR.push(rows[i]);
	    }  
	    if(tab.sortCol == col)
    	{
    		arrTR.reverse();
    		tab.sortMode = !tab.sortMode;
    	}
    	else
    	{
    		arrTR.sort(generateCompareTR(col,dataType));
    		tab.sortMode = true; // true 代表 asc  , false 代表 desc	
    	}
    	var fragment = document.createDocumentFragment();
    	for(var i=0;i<arrTR.length; i++)
    	{
    		fragment.appendChild(arrTR[i]);
    	}
    	tbody.appendChild(fragment);	
    	tab.sortCol = col;
    	
    	
    	var sortPics = document.getElementsByName("sortPic");
    	for(var i=0; i<sortPics.length;i++)
    	{
       	    sortPics[i].style.visibility = "hidden";
        }    
    	if(tab.sortMode)
    	{  
    	    obj.children[obj.children.length-1].style.visibility = "visible";
    	    obj.children[obj.children.length-1].src="../Images/FileManager/SortAsc.gif";
    	}
    	else
    	{ 
    	    obj.children[obj.children.length-1].style.visibility = "visible";
      	    obj.children[obj.children.length-1].src="../Images/FileManager/SortDesc.gif";
    	}
    }


    // 比较函数生成器
    function generateCompareTR(col,dataType)
    {
	    return function compareTR(tr1,tr2)
	    {
	    	var value1 = convert(tr1.cells[col].firstChild.innerText,dataType);
	    	var value2 = convert(tr2.cells[col].firstChild.innerText,dataType);
	    	if(value1<value2) return -1;
    		else if(value1>value2) return 1;
    		else return 0;
    	};
    }

    // 字符串数据转换成指定的数据类型
    function convert(value,dataType)
    {
    	switch(dataType)
    	{
    		case "int":
    			return parseInt(value);
    		case "float":
    			return parseFloat(value);
    		case "date":
    			return new Date(Date.parse(value.replace(/-/g,"/")));
    		default:
    			return value.toString().toLowerCase();
    	}
    }
    
    
    /* 鼠标移到图标样式 */
    function onMouseOverIcon(obj)
    {
        obj.parentNode.style.backgroundColor='#cccccc';
        obj.style.backgroundColor = '#dff1ff';
    }
    /* 鼠标移出图标样式 */
    function onMouseOutIcon(obj)
    {
        obj.parentNode.style.backgroundColor='';
        obj.style.backgroundColor='';
    }
    /* 鼠标移到缩略图样式 */
    function onMouseOverSmallPic(obj)
    {
        obj.parentNode.style.backgroundColor='#dff1ff';
    }
    /* 鼠标移除缩略图样式 */
    function onMouseOutSmallPic(obj)
    {
        obj.parentNode.style.backgroundColor='';
    }
    
    // 确定选择目录
    function selectDirOk()
    {
        var val = getCheckedValue("CheckItem");
        if(val) 
        { 
            window.returnValue = val;
    	    window.close();
        }
        else
        {
           alert("请选择目的目录");
        }
    }
    // 取消选择目录
    function selectDirCancel()
    {
        window.close();
    }
    
    // 上传文件OK
    function uploadFileOk()
    {
        window.opener.location.reload();
    }