www.gusucode.com > 因特达Access数据库在线管理系统 > 因特达Access数据库在线管理系统\code\access\js\file_select_left.js

    function create_folder()
{
	var curDiv=get_cur_folder();
	if (curDiv==false)
	{
		var divID="";
		path="/";//在根目录创建
	}
	else
	{
		var divID=curDiv.id;
		path='';//path是全局变量,用前先清空
		getPath(curDiv);//这里得到的咱径是包括本级文件夹,多了一层,,如:我的报价/11/00/
	}

	var newname=window.prompt("位置:"+path+"\r请输入要创建文件夹的名称:","");
	if(newname!=null)
	{
		if(newname=='')return;
		newname=url_encode(newname);
		blank.location="file_del.asp?divID="+divID+"&act=createfolder&path="+path+"&newName="+newname;
		//window.open("file_rename.asp?act=refolder&path="+path+"&fname="+folderName+"&newname="+newname,'','');
	}
}
function del()
{
	var curDiv=get_cur_folder();
	if (curDiv==false)return;
	var folderName=curDiv.innerText;//如:00
	var divID=curDiv.id;
	path='';//path是全局变量,用前先清空
	getPath(curDiv);//这里得到的咱径是包括本级文件夹,多了一层,,如:我的报价/11/00/
	if(confirm('删除后是无法找回的!\r\r真的要删除“'+folderName+'”吗?'))
	{
		blank.location.href="file_del.asp?divID="+divID+"&act=delfolder&path="+path;
	}
}

var curDiv//定义当前对象
var oldDiv//定义上次选择的对象
var path=""//定义路径
var oElement
function selectDiv()
{
	oElement = document.elementFromPoint(event.x,event.y);
	get_curDiv(oElement);
	if (oElement.tagName=="A")
	{
		var divs=document.getElementsByTagName('DIV')
		for(var i=0 ;i<divs.length;i++){divs[i].className=''}
		curDiv.className="selected"

		arr=curDiv.all//<<<<要把img变为jan.gif
		for (i=0;i<arr.length;i++)
		{
			if(arr[i].tagName=="IMG")
			{
				cur_img=arr[i];
				i=999999;//i太大,就中止for了.
			}
		}
		cur_img.src='jan.gif'//要把img变为jan.gif>>>>
		get_SubDir()//获取下级目录内容
		
	}
	if	(oElement.tagName=="IMG")
	{
		var t_div=oElement.parentElement//标题div
		var id=t_div.id.replace('t_','c_')
		var c_div=eval(id)
		//alert(c_div.id)
		if(c_div.innerHTML=="")
		{
			get_SubDir()//获取下级目录内容
			oElement.src='jan.gif'
		}
		else//已经有内容了
		{
			if(c_div.style.display=="")
			{
				c_div.style.display="none"
				oElement.src='ja.gif'
			}
			else
			{
				c_div.style.display=""
				oElement.src='jan.gif'
			}
		}
	}
}

function get_SubDir()
{
	path=""//清空路径
	getPath(curDiv)//获取当前路径
	
	blank.location="file_select_left_sub.asp?path="+path+"&all_i="+all_i+"&id="+curDiv.id.replace("t_","c_")//c_3,装内容
	//var url="file_select_right.asp?path=<%=request("path")%>/"+path
	//alert(url)
	if(oElement.tagName=="A")
	{
		var pFile=parent.document.location.href;
		var goFile;
		if (pFile.indexOf('file_select.asp')>0)
		{
			goFile="file_select_right.asp";
		}
		else
		{
			goFile="file_list_right.asp";
		}
		
		parent.rightFrame.location=goFile+"?path="+path
		if(parent.document.all.upfile)
		{
			if (path.indexOf('/'))
			{
				parent.document.all.upfile.innerHTML="<a href=?path="+path+"><img border=0 src=document/fsoimg/up.gif></a>"
			}
			else
			{
				parent.document.all.upfile.innerHTML="<img src='document/fsoimg/up1.gif'>";
			}
		}
		if(parent.document.all.path)parent.document.all.path.value="u:/"+path
	}
}

function getPath(obj)
{//alert("("+obj.id+")")
	if (obj==null)		return false;
	if (obj.tagName=="DIV")
	{
		if (obj.parentElement.tagName=="DIV" && obj.parentElement.id!="")//如果不是最顶层
		{
			path=obj.innerText+"/"+path
			var id=obj.parentElement.id.replace('c_','t_')//只对标题处理
			getPath(eval(id))//转换成上一级的标题
		}
		else
		{
			path=obj.innerText+"/"+path
			//alert("path:"+path)
			return;
		}
	}
	else
	{
		getPath(obj.parentElement)
	} 
}
function get_curDiv(obj)
{
	if (obj==null) return false;
	if (obj.tagName=="DIV")
	{
		curDiv=obj
		return true;
	}
	else
	{
		get_curDiv(obj.parentElement)
	}
}

function rename()
{
	var curDiv=get_cur_folder();
	if (curDiv==false)return;
	var folderName=curDiv.innerText;//如:00
	var divID=curDiv.id;
	path='';//path是全局变量,用前先清空
	getPath(curDiv);//这里得到的咱径是包括本级文件夹,多了一层,,如:我的报价/11/00/
	path=path.substr(0,path.length-(folderName.length+1));//得到:如:我的报价/11/,+1是要把/去了
	folderName=url_encode(folderName)
	var newname=window.prompt("请输入文件夹“"+folderName+"”的新名称:","");
	if(newname!=null)
	{
		newname=url_encode(newname);
		blank.location="file_rename.asp?divID="+divID+"&act=refolder&path="+path+"&fname="+folderName+"&newname="+newname;
		//window.open("file_rename.asp?act=refolder&path="+path+"&fname="+folderName+"&newname="+newname,'','');
	}
}

function get_cur_folder()
{
	var divs=document.getElementsByTagName('DIV')
	for(var i=0;i<divs.length;i++)
	{
		if (divs[i].className=='selected')
		{
			return divs[i];
		}
	}
	return false;
}

function url_encode(s_str)
{
	s_str=s_str.replace("%","%25");
	s_str=s_str.replace("&","%26");
	s_str=s_str.replace("+","%2B");
	s_str=s_str.replace("#","%23");
	s_str=s_str.replace("=","%3D");
	s_str=s_str.replace("?","%3F");
	s_str=s_str.replace(" ","+");
	return(s_str);
}