function PhpTreeView(Tname)
{
if(typeof(Tname) != "string" || Tname == "")
throw(new Error(-1, 'need Tname Object'));
this.url = "#";
this.target = "_self";
this.name = Tname;
this.wordLine = false;
this.currentNode = null;
this.useArrow = true;
this.nodes = {};
this.node = {};
this.names = "";
this._d = "\x0f";
this.index = 0;
this.divider = "_";
this.node["0"] =
{
"id": "0",
"path": "0",
"isLoad": false,
"childNodes": [],
"childAppend": "",
"sourceIndex": "0"
};
this.colors =
{
"highLight" : "#0A246A",
"highLightText" : "#FFFFFF",
"mouseOverBgColor" : "#D4D0C8"
};
this.icons = {
L0 : 'L0.gif',
L1 : 'L1.gif',
L2 : 'L2.gif',
L3 : 'L3.gif',
L4 : 'L4.gif',
PM0 : 'P0.gif',
PM1 : 'P1.gif',
PM2 : 'P2.gif',
PM3 : 'P3.gif',
empty : 'L5.gif',
root : 'root.ico',
folder : 'folder.gif',
file : 'file.gif',
exit : 'exit.gif'
};
this.iconsExpand = {
PM0 : 'M0.gif',
PM1 : 'M1.gif',
PM2 : 'M2.gif',
PM3 : 'M3.gif',
folder : 'folderopen.gif',
exit : 'exit.gif'
};
this.getElementById = function(id)
{
if (typeof(id) != "string" || id == "") return null;
if (document.getElementById) return document.getElementById(id);
if (document.all) return document.all(id);
try {return eval(id);} catch(e){ return null;}
}
this.toString = function()
{
this.browserCheck();
this.dataFormat();
this.setStyle();
this.load("0");
var rootCN = this.node["0"].childNodes;
var str = "<A id='"+ this.name +"_RootLink' href='#' style='DISPLAY: none'></A>";
if(rootCN.length>0)
{
this.node["0"].hasChild = true;
for(var i=0; i<rootCN.length; i++)
str += this.nodeToHTML(rootCN[i], i==rootCN.length-1);
setTimeout(this.name +".expand('"+ rootCN[0].id +"', true); "+
this.name +".focusClientNode('"+ rootCN[0].id +"'); "+ this.name +".atRootIsEmpty()",10);
}
if (this.useArrow)
{
if (document.attachEvent)
document.attachEvent("onkeydown", this.onkeydown);
else if (document.addEventListener)
document.addEventListener('keydown', this.onkeydown, false);
}
return "<DIV class='PhpTreeView' "+
"onclick='"+ this.name +".clickHandle(event)' "+
"ondblclick='"+ this.name +".dblClickHandle(event)' "+
">"+ str +"</DIV>";
};
this.onkeydown= function(e)
{
e = window.event || e; var key = e.keyCode || e.which;
switch(key)
{
case 37 : eval(Tname).upperNode(); break;
case 38 : eval(Tname).pervNode(); break;
case 39 : eval(Tname).lowerNode(); break;
case 40 : eval(Tname).nextNode(); break;
}
};
}
PhpTreeView.prototype.browserCheck = function()
{
var ua = window.navigator.userAgent.toLowerCase(), bname;
if(/msie/i.test(ua))
{
this.navigator = /opera/i.test(ua) ? "opera" : "";
if(!this.navigator) this.navigator = "msie";
}
else if(/gecko/i.test(ua))
{
var vendor = window.navigator.vendor.toLowerCase();
if(vendor == "firefox") this.navigator = "firefox";
else if(vendor == "netscape") this.navigator = "netscape";
else if(vendor == "") this.navigator = "mozilla";
}
else this.navigator = "msie";
if(window.opera) this.wordLine = false;
};
PhpTreeView.prototype.setStyle = function()
{
var style = "<style>"+
"DIV.PhpTreeView DIV IMG{border: 0px solid #FFFFFF;}"+
"DIV.PhpTreeView DIV SPAN IMG{border: 0px solid #FFFFFF;}";
if(this.wordLine)
{
style +="\
DIV.PhpTreeView DIV\
{\
height: 20px;"+
(this.navigator=="firefox" ? "line-height: 20px;" : "" ) +
(this.navigator=="netscape" ? "" : "overflow: hidden;" ) +"\
}\
DIV.PhpTreeView DIV SPAN\
{\
vertical-align: middle; font-size: 21px; height: 20px; color: #D4D0C8; cursor: default;\
}\
DIV.PhpTreeView DIV SPAN.pm\
{\
width: "+ (this.navigator=="msie"||this.navigator=="opera" ? "11" : "9") +"px;\
height: "+ (this.navigator=="netscape"?"9":(this.navigator=="firefox"?"10":"11")) +"px;\
font-size: 7pt;\
overflow: hidden;\
margin-left: -16px;\
margin-right: 5px;\
color: #000080; \
vertical-align: middle;\
border: 1px solid #D4D0C8;\
cursor: "+ (this.navigator=="msie" ? "hand" : "pointer") +";\
padding: 0 2px 0 2px;\
text-align: center;\
background-color: #F0F0F0;\
}";
}
style += "<\/style>";
document.write(style);
};
PhpTreeView.prototype.atRootIsEmpty = function()
{
var RCN = this.node["0"].childNodes;
for(var i=0; i<RCN.length; i++)
{
if(!RCN[i].isLoad) this.expand(RCN[i].id);
if (RCN[i].text=="")
{
var node = RCN[i].childNodes[0], HCN = node.hasChild;
if(this.wordLine)
{
var span = this.getElementById(this.name +"_tree_"+ node.id);
span = span.childNodes[0].childNodes[0].childNodes[0];
span.innerHTML = RCN[i].childNodes.length>1 ? "庚" : "岸";
}
else
{
node.iconExpand = RCN[i].childNodes.length>1 ? HCN ? "PM0" : "L0" : HCN ? "PM3" : "L3"
this.getElementById(this.name +"_expand_"+ node.id).src = this.icons[node.iconExpand].src;
}
}
}
};
PhpTreeView.prototype.dataFormat = function()
{
var a = new Array();
for (var id in this.nodes) a[a.length] = id;
this.names = a.join(this._d + this._d);
this.totalNode = a.length; a = null;
};
PhpTreeView.prototype.load = function(id)
{
var node = this.node[id], d = this.divider, _d = this._d;
var sid = node.sourceIndex.substr(node.sourceIndex.indexOf(d) + d.length);
var reg = new RegExp("(^|"+_d+")"+ sid +d+"[^"+_d+d +"]+("+_d+"|$)", "g");
var cns = this.names.match(reg), tcn = this.node[id].childNodes; if (cns){
reg = new RegExp(_d, "g"); for (var i=0; i<cns.length; i++)
tcn[tcn.length] = this.nodeInit(cns[i].replace(reg, ""), id); }
node.isLoad = true;
};
PhpTreeView.prototype.nodeInit = function(sourceIndex, parentId)
{
this.index++;
var source= this.nodes[sourceIndex], d = this.divider;
var text = this.getAttribute(source, "text");
var hint = this.getAttribute(source, "hint");
var sid = sourceIndex.substr(sourceIndex.indexOf(d) + d.length);
this.node[this.index] =
{
"id" : this.index,
"text" : text,
"hint" : hint ? hint : text,
"icon" : this.getAttribute(source, "icon"),
"path" : this.node[parentId].path + d + this.index,
"isLoad": false,
"isExpand": false,
"parentId": parentId,
"parentNode": this.node[parentId],
"sourceIndex" : sourceIndex,
"childAppend" : ""
};
this.nodes[sourceIndex] = "index:"+ this.index +";"+ source;
this.node[this.index].hasChild = this.names.indexOf(this._d + sid + d)>-1;
if(this.node[this.index].hasChild) this.node[this.index].childNodes = [];
return this.node[this.index];
};
PhpTreeView.prototype.getAttribute = function(source, name)
{
var reg = new RegExp("(^|;|\\s)"+ name +"\\s*:\\s*([^;]*)(\\s|;|$)", "i");
if (reg.test(source)) return RegExp.$2.replace(/[\x0f]/g, ";"); return "";
};
PhpTreeView.prototype.nodeToHTML = function(node, AtEnd)
{
var source = this.nodes[node.sourceIndex];
var target = this.getAttribute(source, "target");
var data = this.getAttribute(source, "data");
var url = this.getAttribute(source, "url");
if(!url) url = this.url;
if(data) url += (url.indexOf("?")==-1?"?":"&") + data;
if(!target) target = this.target;
var id = node
未加密的RTX状态感知js文件
5星 · 超过95%的资源 需积分: 9 180 浏览量
2012-10-23
11:01:13
上传
评论 1
收藏 11KB ZIP 举报
搏天鹰
- 粉丝: 9
- 资源: 19
最新资源
- Unity导入Excel文件自动创建class文件和ScriptObject文件,并转化成ScriptObject的插件pro版
- UE4仅k位移产生完美行走动作-UE4项目
- 基于 Python 的校园导航系统
- tensorflow-2.6.3-cp37-cp37m-manylinux2010-x86-64.whl
- tensorflow-2.6.2-cp39-cp39-win-amd64.whl
- tensorflow-2.6.2-cp39-cp39-manylinux2010-x86-64.whl
- 基于Python卷积神经网络人脸识别驾驶员疲劳检测与预警系统源码+使用说明+全部资料.zip
- BPNN-预测.rar
- 灾难分类数据集 PNG(12类 4.8K+ 张图像)
- java8和17的windows、linux版本
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
前往页