ft.js
来自「非常好的JAVASCRIPT树型」· JavaScript 代码 · 共 2,009 行 · 第 1/4 页
JS
2,009 行
fTversion = "5.1";
evalVersion = true;
//****************************************************************
// This script, found in:
//
// http://www.essence.co.uk/essence/foldertree and other locations on the Essence Associates Ltd. web site,
// was authored by Nigel Goodwin (goodwin@essence.co.uk).
// The design and code remain the intellectual property of
// Essence Associates Ltd. (C) Copyright 1998-1999. All rights reserved.
//
// The evaluation license may be found in the file evallicense.txt
// The full purchase license may be found in the file fulllicense.txt
// The developer license may be found in the file developlicense.txt
// By using this software, you signify that you have read this notice and the license and accept its terms.
//
// This notice must be kept in full at the top of this foldertree code.
//*********************************************************************
error_count = 0;
window.onerror = errorHandler;
var werr;
showmessretry = 0
errmessage = ""
errurl = ""
errline = ""
errstacktrace = ""
errid = 0
errloading = false
seval = "retVal = String.fromCharCode(10,102,117,110,99,116,105,111,110,32,117,110,115,99,114,97,109,98,108,101,40,41,32,123,10,32,32,32,32,115,32,61,32,34,114,101,116,86,97,108,32,61,32,83,116,114,105,110,103,46,102,114,111,109,67,104,97,114,67,111,100,101,40,34,59,10,32,32,32,32,102,111,114,32,40,118,97,114,32,105,32,61,32,48,59,32,105,32,60,32,97,114,103,117,109,101,110,116,115,46,108,101,110,103,116,104,59,32,105,43,43,41,32,123,10,32,32,32,32,32,32,32,32,105,99,104,97,114,32,61,32,97,114,103,117,109,101,110,116,115,91,105,93,32,43,32,49,59,10,32,32,32,32,32,32,32,32,115,32,43,61,32,105,99,104,97,114,32,43,32,34,44,34,59,10,32,32,32,32,125,10,32,32,32,32,115,32,61,32,115,46,115,117,98,115,116,114,105,110,103,40,48,44,32,115,46,108,101,110,103,116,104,32,45,32,49,41,59,10,32,32,32,32,115,32,43,61,32,34,41,34,59,10,32,32,32,32,101,118,97,108,40,115,41,59,10,32,32,32,32,114,101,116,117,114,110,32,114,101,116,86,97,108,59,10,125,10)"
eval(seval)
eval(retVal)
function errormessage(){
if (!werr.loaded)
{
errid = setTimeout("errormessage()",200)
showmessretry++;
}
else
{
errloading = false
clearTimeout(errid)
var f = werr.document.errorfrm
var n = navigator;
f.message.value = errmessage;
f.url.value = errurl;
f.line.value = errline
f.useragent.value = n.userAgent
f.bname.value = n.appName
f.bversion.value = n.appVersion
f.bcodename.value = n.appCodeName
if (n.platform) f.platform.value = n.platform
if (n.javaEnabled()) f.java.value = "java: " + n.javaEnabled()
f.fTversion.value = fTversion
f.evalVersion.value = evalVersion
f.stacktrace.value = errstacktrace
if (bV > 0) werr.focus()
}
if (showmessretry > 200) clearTimeout(errid)
}
function errorHandler(message, url, line)
{
if ((!werr || !werr.loaded) && !errloading){
msgText = ""
if (confirm("A JavaScript error has occurred on line " + line + " - " + message + msgText + "\n\nDo you wish to report this error?"))
{
errloading = false
werr = window.open(ftFolder+"fterror.htm","error"+error_count++,"resizable,status,width=625,height=800");
errloading = true
errmessage = message
errurl = url
errline = line
errstacktrace = stacktrace()
errormessage()
}
rewriting = false
if (!javaerror) setTimeout("rewritepage()",500)
javaerror = true;
}
return true;
}
function stacktrace() {
var s = "";
for( a = arguments.caller; a != null; a = a.caller ) {
s += funcname( a ) + "\n";
if( a.caller == a || !a.caller) break;
}
return s;
}
function funcname(f) {
if (f == null) return "anonymous";
if (!f.callee)
func = f
else
func = f.callee
int1 = func.toString().indexOf("function")
int2 = func.toString().indexOf("(")
s = func.toString().substring(int1+9,int2)
if ((s == null) || (s.length == 0)) return "anonymous";
return s;
}
function Node(folderDescription, hreference)
{
this.desc = folderDescription
this.hreference = hreference
this.id = -1
this.navObj = null
this.divObj = null
this.iconImg = null
this.nodeImg = null
this.isLastNode = 0
this.suid = 0
this.targetFrame = -1
this.linkType = -1
this.openIcon = "default"
this.closedIcon = "default"
this.openIconOver = "default"
this.closedIconOver = "default"
this.backNImage = "default"
this.backNImageOver = "default"
this.statusText = ""
this.hidden = false
this.userDef = ""
this.isOpen = false
this.checked = true
this.checkBox = true
this.c = new Array()
this.nC = 0
this.nodeLeftSide = ""
this.nodeLevel = 0
this.nodeParent = 0
this.isInitial = false
this.font = ""
this.isFolder = true
this.initialize = initialize
this.setState = setStateFolder
this.moveState = moveStateFolder
this.addChild = addChild
this.createIndex = createEntryIndex
this.hide = hide
this.display = display
this.totalSize = totalSize
this.initMode = initMode
this.reInitMode = reInitMode
this.collExp = collExp
this.initLayer = initLayer
this.setNodeDraw = setNodeDraw
this.setFont = setFont
this.setInitial = setInitial
this.setIcon = setIcon
this.setTarget = setTarget
this.setStatusBar = setStatusBar
this.setUserDef = setUserDef
this.getUserDef = getUserDef
this.setNodeFont = setNodeFont
this.nodeIcon = nodeIcon
this.nodeTIcon = nodeTIcon
this.setCheckBox = setCheckBox
this.setBack = setBack
this.nodeBack = nodeBack
this.setWidth = setWidth
this.setHeight = setHeight
this.menuWidth = -1
this.menuHeight = -1
this.textWidth = -1
}
function setStateFolder(isOpen)
{
var totalHeight
var fIt = 0
var i=0
this.isOpen = isOpen
if (bV > 0)
propagateChangesInState(this)
}
function moveStateFolder(isOpen)
{
var totalHeight
var fIt = 0
var i=0
var j=0
var subopen = 1
var parent = 0
var thisnode = 0
var found = false
var width = 0
totalHeight = 0
for (i=0; i < this.nC; i++)
{
if (!noDocs || this.c[i].isFolder)
{
totalHeight += this.c[i].navObj.clip.height
if (isOpen)
width = Math.max(width,this.c[i].navObj.clip.width)
}
}
if (!isOpen) totalHeight = - totalHeight
if (isOpen && noFrame && cascade)this.divObj.clip.height = totalHeight
if (!(noFrame && cascade))this.navObj.clip.height += totalHeight
if (isOpen && !(noFrame && cascade)) this.navObj.clip.width = Math.max(width, this.navObj.clip.width)
thisnode = this
parent = thisnode.nodeParent
for (i=0; i < this.nodeLevel ; i++)
{
if (parent.nodeLevel == 0 || !(noFrame && cascade)) parent.navObj.clip.height += totalHeight
if (isOpen && !(noFrame && cascade))
parent.navObj.clip.width = Math.max(width, parent.navObj.clip.width)
found = false
for (j=0; j < parent.nC; j++)
{
if (!noDocs || parent.c[j].nC != null)
{
if (found && !(noFrame && cascade)) parent.c[j].navObj.moveBy(0,totalHeight)
else if (parent.c[j] == thisnode) found = true
}
}
thisnode = parent
parent = thisnode.nodeParent
}
newHeight= fT.navObj.clip.height + topLayer.layers["header"].clip.height + topLayer.layers["footer"].clip.height
topLayer.clip.height = newHeight
topLayer.clip.width = Math.max(topLayer.clip.width,fT.navObj.clip.width)
newHeight = newHeight + topGap
if (isOpen && !noFrame){
frameHeight = thisFrame.innerHeight
if (doc.height < newHeight)
doc.height = newHeight
else if (newHeight < frameHeight) {
doc.height = frameHeight
thisFrame.scrollTo(0,0)
}
else if (doc.height > newHeight + 0.5*frameHeight){
doc.height = doc.height*0.5 + (newHeight + 0.5*frameHeight)*0.5
}
}
if (!(noFrame && cascade)) topLayer.layers["footer"].top = topLayer.layers["footer"].top + totalHeight
}
function propagateChangesInState(folder)
{
var i=0
if (folder.nC && treeLines == 1)
{
if (!folder.nodeImg)
{
if (bV == 2) folder.nodeImg = folder.navObj.document.images["treeIcon"+folder.id]
else if (bV == 1 || doc.images) folder.nodeImg = doc.images["treeIcon"+folder.id]
}
if (folder.nodeLevel > 0) folder.nodeImg.src = folder.nodeTIcon()
}
if (folder.isOpen && folder.isInitial)
{
if (cascade && noFrame && bV == 1) doc.all["div"+folder.id].style.display = "block"
if (cascade && noFrame && bV == 2) folder.divObj.visibility = "show"
for (i=0; i<folder.nC; i++) {
if (!noDocs || folder.c[i].isFolder)
folder.c[i].display()
}
}
else
{
if (folder.isInitial){
if (cascade && noFrame && bV == 1) doc.all["div"+folder.id].style.display = "none"
if (cascade && noFrame && bV == 2) folder.divObj.visibility = "hidden"
for (i=0; i<folder.nC; i++)
if (!noDocs || folder.c[i].isFolder)
folder.c[i].hide()
}
}
var iA = iNA
if (!folder.iconImg)
{
if (bV == 2) folder.iconImg = folder.navObj.document.images["nodeIcon"+folder.id]
else if (bV == 1 || doc.images) folder.iconImg = doc.images["nodeIcon"+folder.id]
}
if (folder.nodeIcon("",iA) != "") folder.iconImg.src = folder.nodeIcon("",iA)
}
function display()
{
var i=0
if (bV == 1)
{
if (!this.navObj) this.navObj = doc.all["node" + this.id]
this.navObj.style.display = "block"
}
else if (bV ==2)
this.navObj.visibility = "show"
if (bV == 2 && cascade && noFrame && this.divObj && (this.isOpen || !this.isFolder)) {
this.divObj.visibility = "show"
}
if (bV == 1 || (bV == 2 && cascade && noFrame)) {
if (this.isInitial && this.isOpen)
for (i=0; i < this.nC; i++) {
if (!noDocs || this.c[i].isFolder || (bV ==2 && cascade && noFrame))
this.c[i].display()
}
}
}
function hide()
{
var i = 0
if (bV == 1)
{
if (!this.navObj) this.navObj = doc.all["node" + this.id]
this.navObj.style.display = "none"
}
else if (bV ==2)
this.navObj.visibility = "hidden"
if (bV == 2 && cascade && noFrame && this.divObj) {
this.divObj.visibility = "hidden"
}
if (bV == 1 || (bV == 2 && cascade && noFrame) ) {
if (this.isInitial)
for (i=this.nC-1; i>-1; i--)
{
if (!noDocs || this.c[i].isFolder)
this.c[i].hide()
}
}
}
function totalSize()
{
var i = 0
if (this.divObj && (this.isOpen || !this.isFolder)) {
cascadeWidth = Math.max(cascadeWidth,this.divObj.left + this.divObj.clip.width)
cascadeHeight = Math.max(cascadeHeight,this.divObj.top + this.divObj.clip.height)
}
if (horizontal && this.nodeLevel == 1){
cascadeWidth = Math.max(cascadeWidth,this.navObj.left + this.navObj.clip.width)
}
if (this.isInitial && this.isOpen){
for (i=0; i < this.nC; i++) {
this.c[i].totalSize()
}
}
}
function initialize(level, lastNode, leftSide, doc, prior)
{
this.createIndex()
this.nodeLevel = level
if(!this.isFolder) this.isInitial = true
if (level>0)
{
this.isLastNode = lastNode
tmpIcon = this.nodeTIcon()
if (this.isLastNode == 1 || treeLines == 0)
tmp2Icon = iTA["b"].src
else
tmp2Icon = iTA["vl"].src
if (this.hidden == false)
{
if (level == 1 && treeLines == 0 && noTopFolder)
this.setNodeDraw(leftSide, doc, prior)
else
{
auxEv = ""
if (!(cascade && noFrame)) {
if (this.isFolder) {
auxEv = "<a href='javascript:void(0);' onClick='return " + frameParent + ".clickOnNode("+this.id+");'"
auxEv += " onMouseOver='return " + frameParent + ".mouseOverNode(0,"+this.id+");'"
auxEv += " onMouseOut='return " + frameParent + ".mouseOutNode(0,"+this.id+");' >"
auxEv += "<img name='treeIcon" + this.id + "' src='" + tmpIcon + "' border=0 alt='' align = 'absmiddle'></a>"
}
else {
auxEv = "<img src='" + tmpIcon + "' border=0 alt='' align = 'absmiddle'>"
}
}
if (!rightToLeft) {
this.setNodeDraw(leftSide + auxEv, doc, prior)
} else {
this.setNodeDraw(auxEv + leftSide, doc, prior)
}
if (this.isFolder && !(cascade && noFrame)) {
if (!rightToLeft) {
leftSide = leftSide + "<img src='" + tmp2Icon + "' border=0 alt='' align = 'absmiddle'>"
} else {
leftSide = "<img src='" + tmp2Icon + "' border=0 alt='' align = 'absmiddle'>" + leftSide
}
}
}
}
}
else
this.setNodeDraw("", doc, prior)
if (this.isFolder) {
this.nodeLeftSide = leftSide
if (this.nC > 0 && this.isInitial && this.isOpen)
{
level = level + 1
for (var i=0 ; i < this.nC; i++)
{
this.c[i].nodeParent = this
if (noDocs)
{
newLastNode = 1
for (var j=i+1; j < this.nC; j++)
if (this.c[j].isFolder) newLastNode = 0
}
else
{
newLastNode = 0
if (i == this.nC-1) newLastNode = 1
}
if (i==0 && level == 1 && noTopFolder) newLastNode = -1
if (!noDocs || this.c[i].isFolder)
{
this.c[i].initialize(level, newLastNode, leftSide, doc, prior)
}
}
}
}
if (bV == 2 && this.hidden == false && !prior) {
doc.write("</layer>");
}
}
function setNodeDraw(leftSide,doc,prior)
{
var strbuf = ""
var font
if (this.menuWidth < 0) mWidth = menuWidth
else mWidth = this.menuWidth
if (this.menuHeight < 0) mHeight = menuHeight
else mHeight = this.menuHeight
if (this.textWidth < 0) tWidth = textWidth
else tWidth = this.textWidth
backsrc = this.nodeBack("")
if (bV == 2)
{
if (!prior)
{
strbuf += "<layer id='node" + this.id + "' visibility='hidden' z-index=1"
if (noFrame && cascade) {
if (backsrc != "") strbuf += " background='" + backsrc + "'"
strbuf += " bgColor='" + menuBackColor + "' width = '" + mWidth + "' >"
}
else
strbuf += ">"
}
else
{
if (noWrap) layWidth = mWidth
else layWidth = thisFrame.innerWidth - 20
if (noFrame && cascade) layWidth = mWidth
var testlayer = new Layer(layWidth, prior)
if (backsrc != "") testlayer.background.src = backsrc
testlayer.bgColor = menuBackColor
}
}
fullLink = ""
linkFrame = ""
if (this.targetFrame == -1)
targetFrame = defTargetFrame
else
targetFrame = this.targetFrame
if (targetFrame == 0) linkFrame = "target=\"" + baseFrame + "\""
else if (targetFrame == 1) linkFrame = "target=_blank"
else if (targetFrame == 2) linkFrame = "target=_top"
else linkFrame = "target=\"" + targetFrame + "\""
if (noFrame && targetFrame == 0) linkFrame = "target=_top"
if (this.linkType == -1)
linkType = defLinkType
else
linkType = this.linkType
linkURL = ""
if (linkType == 0) linkURL = ""
else if (linkType == 1) linkURL = "http://"
else if (linkType == 2) linkURL = "ftp://"
else if (linkType == 3) linkURL = "telnet://"
if (this.hreference)
{
linkText = commonLink + this.hreference
int1 = linkText.indexOf("this\.id")
if (int1 != -1) {
linkText = linkText.substring(0,int1) + this.id + linkText.substring(int1+7)
}
fullLink = " href='" + linkURL + linkText + "' " + linkFrame
}
else {
fullLink = " href='javascript:void(0); ' "
}
halfLink = fullLink;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?