在看别人的一段代码(web中树形菜单显示)时,其中有一行代码window.TV=[];是什么意思,请帮忙解释一下.还有就是该找什么样的资料可以清楚这种代码的作用?
var Icon = {
root : "root.gif",
folderopen : "folderopen.gif",
folderclosed : "folderclosed.gif",
leaf : "leaf.gif",
Rminus: "Rminus.gif",
Rplus: "Rplus.gif",
minusbottom: "Lminus.gif",
plusbottom: "Lplus.gif",
minus: "minus.gif",
plus: "plus.gif",
join: "T.gif",
joinbottom: "L.gif",
blank: "blank.gif",
line: "I.gif"
}window.TV = [];
function TreeView()
{
this.id = window.TV.length;
window.TV[this.id] = this;
this.target = "_self";
this.showLeaf = true;
this.showAll = true;
this.Nodes ={ 0 : { ID : 0, ParentID : -1, Text : null, Href : null, Image : null, childNodes: new Array() } };
}
var tv = TreeView.prototype;
tv.setTarget = function(v) {
this.target = v;
}
tv.useLeaf = function(v) {
this.showLeaf = v;
}
tv.setShowAll = function(v) {
this.showAll = v;
}
tv.setImagePath = function(sPath) {
for(o in Icon){
tmp = sPath + Icon[o];
Icon[o] = new Image();
Icon[o].src = tmp;
}
}
tv.add = function(iD,ParentiD,sText,sHref,sTarget,sImage) {
this.Nodes[iD] = { ID : iD, ParentID : ParentiD, Text : sText, Href : sHref, Target : sTarget, Image : sImage , childNodes: new Array() , open : false ,isLast : true};
var ch = this.getNode(ParentiD).childNodes;
ch[ch.length] = this.Nodes[iD];
if (ch.length>1) { ch[ch.length-2].isLast = false;}
};
......
var Icon = {
root : "root.gif",
folderopen : "folderopen.gif",
folderclosed : "folderclosed.gif",
leaf : "leaf.gif",
Rminus: "Rminus.gif",
Rplus: "Rplus.gif",
minusbottom: "Lminus.gif",
plusbottom: "Lplus.gif",
minus: "minus.gif",
plus: "plus.gif",
join: "T.gif",
joinbottom: "L.gif",
blank: "blank.gif",
line: "I.gif"
}window.TV = [];
function TreeView()
{
this.id = window.TV.length;
window.TV[this.id] = this;
this.target = "_self";
this.showLeaf = true;
this.showAll = true;
this.Nodes ={ 0 : { ID : 0, ParentID : -1, Text : null, Href : null, Image : null, childNodes: new Array() } };
}
var tv = TreeView.prototype;
tv.setTarget = function(v) {
this.target = v;
}
tv.useLeaf = function(v) {
this.showLeaf = v;
}
tv.setShowAll = function(v) {
this.showAll = v;
}
tv.setImagePath = function(sPath) {
for(o in Icon){
tmp = sPath + Icon[o];
Icon[o] = new Image();
Icon[o].src = tmp;
}
}
tv.add = function(iD,ParentiD,sText,sHref,sTarget,sImage) {
this.Nodes[iD] = { ID : iD, ParentID : ParentiD, Text : sText, Href : sHref, Target : sTarget, Image : sImage , childNodes: new Array() , open : false ,isLast : true};
var ch = this.getNode(ParentiD).childNodes;
ch[ch.length] = this.Nodes[iD];
if (ch.length>1) { ch[ch.length-2].isLast = false;}
};
......
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货