ft.js

来自「非常好的JAVASCRIPT树型」· JavaScript 代码 · 共 2,015 行 · 第 1/4 页

JS
2,015
字号
halfLink = fullLink;
fullLink += " onMouseOver='return " + frameParent + ".mouseOverNode(1,"+this.id+");' onMouseOut='return " + frameParent + ".mouseOutNode(1,"+this.id+");' "
	fullLink += " onClick='return " + frameParent + ".clickNode("+this.id+");' "
if (bV == 2) halfLink = fullLink

if (this.statusText == "")
	var toolTip= this.desc
else
	var toolTip = this.statusText
if (bV > 0) {
	eval("toolTip = toolTip.replace(/<[^<>]*>/g,'');");
}
else {
	int1 = toolTip.indexOf("<")
	toolTip = toolTip.substring(0,int1)
}
fullLink += " TITLE ='" + toolTip + "' "

if (bV == 1) {
strbuf += "<div id='node" + this.id + "' style='position:static;"
if (cascade && noFrame) {
if (backsrc != ""){
strbuf += "background-image: url(" + backsrc + ");background-repeat:repeat-y;"
}
strbuf += "width:" + mWidth + ";height:" + mHeight + "'"
} else {
strbuf += "'"
}
if (cascade && noFrame) {
strbuf += " align = 'center'"
}
else if (rightToLeft) {
	strbuf += " align = 'right'"
}
strbuf += ">"
}
strbuftable = "" 
if (cascade && noFrame) 
	strbuftable = "<table border=0 cellspacing=0 cellpadding=0 height=" + mHeight + ">"
else 
	strbuftable = "<table border=0 cellspacing=0 cellpadding=0 >"
if (vSpacer) {
if ((this.nodeLevel == 1 && noTopFolder) || (this.nodeLevel == 2 && noTopFolder && this.nodeParent.c[0] == this))
{
if (iTA["vSpacer"] != null && iTA["vSpacer"].src != null)
	strbuftable = "<table border=0 cellspacing=0 cellpadding=0 width='100%' bgcolor='" + vSpacerColor + "'><tr><td><img src='" + iTA["vSpacer"].src + "' border=0  alt='' ></td></tr></table>" + strbuftable;
}
}
if (!rightToLeft) {
strbufbtd = "<td valign = "
} else {

strbufbtd = "<td align = 'right' valign = "
}
if (noWrap) strbufbtd += " 'middle' "
else strbufbtd += " 'top' "
strbufbtd += " nowrap>"

strbufbl = "<a " + fullLink + ">"
var iA = iNA
tmpIcon = this.nodeIcon("",iA)

strbufni = "<img name='nodeIcon" + this.id + "' "
if (tmpIcon != "") {
strbufni += "src='" + tmpIcon + "' "
} else {
strbufni += "src='" + iTA["bn"].src + "' width = 0"
}
strbufni += " border=0 align = 'absmiddle' alt = '" + toolTip

if (cascade && noFrame && tmpIcon != "") {
strbufni +=  "' hspace = '4'>"
} else {
strbufni +=  "'>"

}
strbufsp = ""
if (this.isFolder)
	var space = folderIconSpace
else
	var space = documentIconSpace
if (space > 0) {
hspace = parseInt("" + (space/2 + .5) + "")
wspace = 1
if (hspace*2 == space) wspace = 2
hspace = hspace - 1; 
 strbufsp = "<IMG border=0  alt='' align = 'absmiddle' height = '" + wspace + "' width = '" + wspace + "' src='" + iTA["bn"].src + "' hspace = '" + hspace + "'>"
}

if (!(cascade && noFrame)) 
strbuftx = "<td valign=middle "
else
strbuftx = "<td valign=middle width = '" + tWidth + "' "

if (noWrap) strbuftx += "nowrap>"
else strbuftx += ">"

if (checkBox && this.checkBox) 
	{
	strbuftx += "<input type=checkbox NAME='" + this.suid + "' VALUE = 'Yes' "
	strbuftx += "onClick = 'node = parent.indexOfEntries[" + this.id + "];node.checked = !node.checked;' "
	if (this.checked == true) strbuftx += " checked>"
	else strbuftx += ">"
	}
font = this.setNodeFont()
if (bV > 0) eval("font = font.replace(/<font/i,'');");
if (bV == 1) font = "<font id='text" + this.id + "' " + font;
if (bV == 2) font = "<font " + font;

if (cascade && noFrame && bV > 0) {	
if (bV == 1) {
if (useTextLinks && this.hreference) strbuftx += "<a " + halfLink 
else strbuftx += "<div "
strbuftx += " style='width:" + tWidth + ";text-decoration: none;"
if (this.nodeLevel == 1 && horizontal)
	strbuftx += "text-align:center'"
else 
	strbuftx += "'"
strbuftx += ">" + font + this.desc + "</font>"
if (useTextLinks && this.hreference) strbuftx += "</a>"
else strbuftx += "</div>"
} else {
// This is because reloads crash when using styles with NN4.5 at least.
styleindex = font.search(/style/i)
if (styleindex > -1) {
font = font.substring(0,styleindex)
if (font.search(/color/i) == -1)
 font += " color='" + menuTextColor + "'"
font += ">"
}
strbuftx +=  font  + this.desc + "</font>"
if (useTextLinks && this.hreference) strbuftx +=  "</a>"
}

} else {
if (useTextLinks) {
strbuftx += "<a " + fullLink + " >" + font +    this.desc + "</font></a>"
} else {
strbuftx += font + this.desc + "</font>"
}
}
strbuftx += "</td>"
//alert(strbuftx)
if (!(cascade && noFrame)) {
if (!rightToLeft) {
strbuf += strbuftable + "<tr>" + strbufbtd + leftSide + strbufbl + strbufni + strbufsp + "</a>" + "</td>" + strbuftx
} else {
strbuf += strbuftable +  "<tr>" + strbuftx + strbufbtd +  strbufbl + strbufsp + strbufni  + "</a>" + leftSide + "</td>"  
}
} else {
strbuf +=  strbufbl + strbuftable + "<tr>" + strbufbtd + leftSide + strbufni + strbufsp  + "</td>" + strbuftx

}
if (!(cascade && noFrame)) {
strbuf += "</tr></table>"
} else {
strbuf += "<td align=right>"
if (this.isFolder && this.nodeLevel > 1 && iTA["arr"] != null  && iTA["arr"].src != "") strbuf += "<IMG border=0  alt='' src='" + iTA["arr"].src + "'>"
else if (this.nodeLevel > 1) strbuf += "<IMG border=0  alt='' src='" + iTA["bn"].src + "'>"
strbuf += "</td></tr></table></a>"

}
if (bV == 1) strbuf += "</div>"
if (this.nodeLevel == 0 && noTopFolder)
	{
	if (bV == 2) strbuf = "<layer id='node" + this.id + "' visibility='hidden'>"
	else if (bV == 1 && !rightToLeft) strbuf = "<div id='node" + this.id + "'></div>"
	else if (bV == 1 && rightToLeft) strbuf = "<div align = 'right' id='node" + this.id + "'></div>"
	else if (bV == 0) strbuf = ""
	}

this.navObj = null
if (this.isFolder) this.nodeImg = null
this.iconImg = null
if (bV == 0 || !prior) 
{
      if (cascade && horizontal && noFrame && bV == 1) {
		strbufhSpacer = ""
		if (iTA["hSpacer"] != null && iTA["hSpacer"].src != "" && this.nodeLevel == 1 && this.nodeParent.c[0] != this)
 		strbufhSpacer = "<td><IMG border=0  alt='' align = 'absmiddle'  src='" + iTA["hSpacer"].src + "'></td>"
		strbuf = strbufhSpacer + "<td>" +  strbuf + "</td>"     
 	}
   	if (bV != 1) {
    		 doc.write(strbuf)
   	}
   	else {
         strbufarray[this.id] = strbuf
   	}
}
else
	{
	if (bV == 2) 
		{
		testlayer.document.open()
		testlayer.document.write(strbuf)
		testlayer.document.close()
		testlayer.zIndex=1
		this.navObj = testlayer
		this.navObj.top = doc.yPos
		this.navObj.visibility = "show"
		doc.yPos += this.navObj.clip.height
		}
	else if (bV == 1)
		{
		strbufarray[strbufIndex] = strbuf
		strbufIndex++
		}
	}
}

function setNodeFont()
{
font = "<FONT>"
if (!levelDefFont[this.nodeLevel])
	levelDefFont[this.nodeLevel] = ""
if (this.font != "")
	font = this.font
else
	if (levelDefFont[this.nodeLevel] != "")
		font = levelDefFont[this.nodeLevel]
	else
		if (defFolderFont != "" && this.isFolder)
			font = defFolderFont
		else
			if (defDocFont != "" && !this.isFolder)
				font = defDocFont
return font;
}

function createEntryIndex()
{
this.id = nEntries
indexOfEntries[nEntries] = this
nEntries++
}
function mouseOverNode(type,folderId)
{
var mouseNode = 0
mouseNode = indexOfEntries[folderId]
if (!mouseNode) return false;
if (bV == 1 && !mouseNode.navObj) {
	if (noFrame) {
		doc = document
	}
	else
	{
		doc = self.frames[menuFrame].document
	}
	mouseNode.navObj = doc.all["node" + mouseNode.id]
}
if (bV == 1 && (doc != mouseNode.navObj.document && !isNav6)) {
	clearTimeout(rewriteID)
	checkload()
	return true;
}
if (cascade && noFrame) {
backsrc = mouseNode.nodeBack("Over")
if (bV == 1) {
mouseNode.navObj.style.backgroundColor = menuBackColorOver
if (doc.all["text" + mouseNode.id]) {
doc.all["text" + mouseNode.id].style.color = menuTextColorOver
}
if (backsrc != "") mouseNode.navObj.style.backgroundImage = "url(" + backsrc + ")"
}
if (bV == 2 && backsrc != "") mouseNode.navObj.background.src = backsrc
if (bV == 2) mouseNode.navObj.bgColor = menuBackColorOver
}
if (type == 0)
	if (mouseNode.isOpen)
		{
		setStatus("Click to close")
		if (mouseOverPMMode == 2) clickOnNode(folderId)
		}
	else
		{
		setStatus("Click to open")
		if (mouseOverPMMode > 0) clickOnNode(folderId)
		}
else if (type == 1)
	{
	clearTimeout(timeoutIDOver)
	if (mouseNode.statusText == "")
		{
		if (bV == 1 && doc.all["text" + mouseNode.id])
			setStatus(doc.all["text" + mouseNode.id].innerHTML)
		else
			setStatus(mouseNode.desc)
		}
	else
		{
		setStatus(mouseNode.statusText)
		}
	if (mouseNode.isFolder)
		if ((!mouseNode.isOpen && mouseOverIconMode == 1) || mouseOverIconMode == 2) {
 if (cascade && noFrame) timeoutIDOver = setTimeout("clickOnNode(" + folderId + ")",50)
else  timeoutIDOver = setTimeout("clickOnNode(" + folderId + ")",350)
}
	}
if (document.images && type == 1)
	{
	over = "Over"
	var iA = iNAO
if (cascade && noFrame && mouseNode.isFolder) iA = iNA
if (!mouseNode.iconImg)
{
	if (bV == 2) mouseNode.iconImg = mouseNode.navObj.document.images["nodeIcon"+mouseNode.id]
	else if (bV == 1 || doc.images) mouseNode.iconImg = doc.images["nodeIcon"+mouseNode.id]
}
	if ( mouseNode.nodeIcon(over,iA)  != "") mouseNode.iconImg.src = mouseNode.nodeIcon(over,iA)
}
if (cascade && noFrame && bV == 1) {
if (modalClick && (mouseNode.nodeLevel > 0))

	for (i=0; i < mouseNode.nodeParent.nC; i++)
		{
		if (mouseNode.nodeParent.c[i].isOpen && (mouseNode.nodeParent.c[i] != mouseNode))
			{
			for (j=0; j < mouseNode.nodeParent.c[i].nC; j++) {
				if (mouseNode.nodeParent.c[i].c[j].isFolder && mouseNode.nodeParent.c[i].c[j].isOpen) mouseNode.nodeParent.c[i].c[j].setState(false)
			}
			mouseNode.nodeParent.c[i].setState(false)
			}
		}

}
return true;
}
function clickNode(folderId)
{
var thisNode = 0
thisNode = indexOfEntries[folderId]
if (!thisNode) return false;
if (thisNode.isFolder) {
if (clickIconMode == 1 && thisNode.isOpen != null)
{
	if(!thisNode.isOpen) clickOnNode(folderId)
}
else if (clickIconMode == 2 && thisNode.isOpen != null)
		clickOnNode(folderId)
}
if (clickAction)
	clickAction(thisNode)
if (thisNode.hreference) return true;
else return false;
}
function nodeTIcon (){
iName = ""
if (this.isFolder) {
if (this.isOpen)
	{
	if (this.isLastNode == 0)
		iName = "mn"
	else if (this.isLastNode == 1)
		iName = "mln"
	else
		iName = "mfn"
	}
else
	{
	if (this.isLastNode == 0)
		iName = "pn"
	else if (this.isLastNode == 1)
		iName = "pln"
	else
		iName = "pfn"
	}
if (noDocs)
	{
	folderChildren = false
	for (i=0 ; i < this.nC; i++)
		{
		if (this.c[i].isFolder) folderChildren = true
		}
	if (!folderChildren) 
		if (this.isLastNode == 0)
			iName = "n"
		else if (this.isLastNode == 1)
			iName = "ln"
		else
			iName = "fn"
	}
}
else
{
	if (this.isLastNode == 0)
		iName = "n"
	else if (this.isLastNode == 1)
		iName = "ln"
	else
		iName = "fn"
}
if (treeLines == 0) iName = "b"
tmpIcon = iTA[iName].src
return tmpIcon
}
function nodeBack(over){
tmpImage = ""
if (this["backNImage" + over] == "")
tmpImage = ""
else if (this["backNImage" + over] != "default")
tmpImage =  imageArray[this["backNImage" + over]].src
else
if (over == "Over") {
if(iNAO["bck"] != null) tmpImage = iNAO["bck"].src
}
else
{
if(iNA["bck"] != null) tmpImage = iNA["bck"].src
}
//alert(tmpImage)
return tmpImage
}
function nodeIcon(over,iA){
	tmpIcon = ""
	if (this.isFolder)
		{
		if (this.isOpen)
			{
                        if (this["openIcon"+over] == "")
				tmpIcon = ""		
                        else if (this["openIcon"+over] != "default")
				tmpIcon = imageArray[this["openIcon"+over]].src
			else if (this.nodeLevel == 0 || (this.nodeLevel == 1 && noTopFolder)) {
				if(iA["tOF"] != null)tmpIcon = iA["tOF"].src
			}
			else {
				if(iA["oF"] != null) tmpIcon = iA["oF"].src
			}
			}
		else
			{
                        if (this["closedIcon"+over] == "")
				tmpIcon = ""		
			else if (this["closedIcon" + over] != "default") 
				tmpIcon = imageArray[this["closedIcon"+over]].src
			else if (this.nodeLevel == 0  || (this.nodeLevel == 1 && noTopFolder)) {
				if(iA["tCF"] != null) tmpIcon = iA["tCF"].src
			}
			else {
				if(iA["cF"] != null) tmpIcon = iA["cF"].src
			}
			}
		}
	else
		{
                 if (this["openIcon"+over] == "")
			tmpIcon = ""		
		else if (this["openIcon"+over] != "default")
			tmpIcon = imageArray[this["openIcon"+over]].src
		else if (this.nodeLevel == 0  || (this.nodeLevel == 1 && noTopFolder)) {
			if(iA["tD"] != null) tmpIcon = iA["tD"].src
		}
		else {
			if(iA["d"] != null) tmpIcon = iA["d"].src
		}
		}

return tmpIcon;
}
function mouseOutNode(type,folderId)
{
var mouseNode = 0
mouseNode = indexOfEntries[folderId]
if (!mouseNode) return false;
clearTimeout(timeoutIDOver)
over = ""
if (document.images && type == 1)
	{
	var iA = iNA
if (!mouseNode.iconImg)
{
if (bV == 2) mouseNode.iconImg = mouseNode.navObj.document.images["nodeIcon"+mouseNode.id]
else if (bV == 1 || doc.images) mouseNode.iconImg = doc.images["nodeIcon"+mouseNode.id]
}
	if (mouseNode.nodeIcon(over,iA) != "") mouseNode.iconImg.src = mouseNode.nodeIcon(over,iA)
	}
if (cascade && noFrame) {
backsrc = mouseNode.nodeBack(over)
 if (bV == 1) {
 mouseNode.navObj.style.backgroundColor = menuBackColor
if (doc.all["text" + mouseNode.id]) {
doc.all["text" + mouseNode.id].style.color = menuTextColor
if (backsrc != "") mouseNode.navObj.style.backgroundImage = "url(" + backsrc + ")"
}
}
if (bV == 2 && backsrc != "") mouseNode.navObj.background.src = backsrc
if (bV == 2) mouseNode.navObj.bgColor = menuBackColor
}
setStatus("")
return true;
}
function setStatus(statusText){
var str = statusText
if (bV > 0)
	eval("str = str.replace(/<[^<>]*>/g,'');")
top.window.defaultStatus = ""
top.window.status = str
thisFrame.defaultStatus = str
thisFrame.status = str
if (bV == 0)
	{
	clearTimeout(timeoutID)
	timeoutID = setTimeout("top.status = ''",5000)
	}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?