This is a Javascript + xml tree list downloaded on www.java2s.com. the list interface is very beautiful, but because of its complicated content, this list is now used by the project, I haven't figured out how to make it
This is a tree-type list of Javascript xml downloaded from www.java2s.com. the list interface is very beautiful, but the list needs to be used by projects because of its complicated content, so far, I have not figured out how to transfer a tree-type project to another webpage. I hope my friends who are interested can study it together.
Some code is as follows:
Script
Function dtmlXMLLoaderObject (funcObject, dhtmlObject ){
This. xmlDoc = "";
This. onloadAction = funcObject | null;
This. mainObject = dhtmlObject | null;
Return this;
};
DtmlXMLLoaderObject. prototype. waitLoadFunction = function (dhtmlObject ){
This. check = function (){
If (! DhtmlObject. xmlDoc. readyState) dhtmlObject. onloadAction (dhtmlObject. mainObject );
Else {
If (dhtmlObject. xmlDoc. readyState! = 4) return false;
Else dhtmlObject. onloadAction (dhtmlObject. mainObject );}
};
Return this. check;
};
DtmlXMLLoaderObject. prototype. getXMLTopNode = function (tagName ){
If (this. xmlDoc. responseXML) {var temp = this. xmlDoc. responseXML. getElementsByTagName (tagName); var z = temp [0];}
Else var zw.this.xmldoc.doc umentElement;
If (z) return z;
Alert ("Incorrect XML ");
Return document. createElement ("DIV ");
};
DtmlXMLLoaderObject. prototype. loadXMLString = function (xmlString ){
Try
{
Var parser = new DOMParser ();
This. xmlDoc = parser. parseFromString (xmlString, "text/xml ");
}
Catch (e ){
This. xmlDoc = new ActiveXObject ("Microsoft. XMLDOM ");
This. xmlDoc. loadXML (xmlString );
}
This. onloadAction (this. mainObject );
}
DtmlXMLLoaderObject. prototype. loadXML = function (filePath ){
Try
{
This. xmlDoc = new XMLHttpRequest ();
This. xmlDoc. open ("GET", filePath, true );
This. xmlDoc. onreadystatechange = new this. waitLoadFunction (this );
This. xmlDoc. send (null );
}
Catch (e ){
If (document. implementation & document. implementation. createDocument)
{
This. xmlDoc = document. implementation. createDocument ("", "", null );
This. xmlDoc. onload = new this. waitLoadFunction (this );
}
Else
{
This. xmlDoc = new ActiveXObject ("Microsoft. XMLDOM ");
This. xmlDoc. async = "true ";
This. xmlDoc. onreadystatechange = new this. waitLoadFunction (this );
}
This. xmlDoc. load (filePath );
}
};
Function callerFunction (funcObject, dhtmlObject ){
This. handler = function (e ){
If (! E) e = event;
FuncObject (e, dhtmlObject );
Return true;
};
Return this. handler;
};
Function getAbsoluteLeft (htmlObject ){
Var xPos = htmlObject. offsetLeft;
Var temp = htmlObject. offsetParent;
While (temp! = Null ){
XPos = temp. offsetLeft;
Temp = temp. offsetParent;
}
Return xPos;
}
Function getAbsoluteTop (htmlObject ){
Var yPos = htmlObject. offsetTop;
Var temp = htmlObject. offsetParent;
While (temp! = Null ){
YPos = temp. offsetTop;
Temp = temp. offsetParent;
}
Return yPos;
}
Function convertStringToBoolean (inputString) {if (typeof (inputString) = "string") inputString = inputString. toLowerCase ();
Switch (inputString ){
Case "1 ":
Case "true ":
Case "yes ":
Case "y ":
Case 1:
Case true:
Return true;
Break;
Default: return false;
}
}
Function getUrlSymbol (str ){
If (str. indexOf ("? ")! =-1)
Return "&"
Else
Return "? "
}
Function dhtmlDragAndDropObject (){
This. lastLanding = 0;
This. dragNode = 0;
This. dragStartNode = 0;
This. dragStartObject = 0;
This. tempDOMU = null;
This. tempDOMM = null;
This. waitDrag = 0;
If (window. dhtmlDragAndDrop) return window. dhtmlDragAndDrop;
Window. dhtmlDragAndDrop = this;
Return this;
};
DhtmlDragAndDropObject. prototype. removeDraggableItem = function (htmlNode ){
HtmlNode. onmousedown = null;
HtmlNode. dragStarter = null;
HtmlNode. dragLanding = null;
}
DhtmlDragAndDropObject. prototype. addDraggableItem = function (htmlNode, dhtmlObject ){
HtmlNode. onmousedown = this. preCreateDragCopy;
HtmlNode. dragStarter = dhtmlObject;
This. addDragLanding (htmlNode, dhtmlObject );
}
DhtmlDragAndDropObject. prototype. addDragLanding = function (htmlNode, dhtmlObject ){
HtmlNode. dragLanding = dhtmlObject;
}
DhtmlDragAndDropObject. prototype. preCreateDragCopy = function (e)
{
If (window. dhtmlDragAndDrop. waitDrag ){
Window. dhtmlDragAndDrop. waitDrag = 0;
Document. body. onmouseup = window. dhtmlDragAndDrop. tempDOMU;
Document. body. onmousemove = window. dhtmlDragAndDrop. tempDOMM;
Return;
}
Window. dhtmlDragAndDrop. waitDrag = 1;
Window. dhtmlDragAndDrop. tempDOMU = document. body. onmouseup;
Window. dhtmlDragAndDrop. tempDOMM = document. body. onmousemove;
Window. dhtmlDragAndDrop. dragStartNode = this;
Window. dhtmlDragAndDrop. dragStartObject = this. dragStarter;
Document. body. onmouseup = window. dhtmlDragAndDrop. preCreateDragCopy;
Document. body. onmousemove = window. dhtmlDragAndDrop. callDrag;
};
DhtmlDragAndDropObject. prototype. callDrag = function (e ){
If (! E) e = window. event;
Dragger = window. dhtmlDragAndDrop;
If (! Dragger. dragNode ){
Dragger. dragNode = dragger. dragStartObject. _ createDragNode (dragger. dragStartNode );
Document. body. appendChild (dragger. dragNode );
Document. body. onmouseup = dragger. stopDrag;
Dragger. waitDrag = 0;
}
Dragger. dragNode. style. left = e. clientX 15 document. body. scrollLeft; dragger. dragNode. style. top = e. clientY 3 document. body. scrollTop;
If (! E. srcElement) var zw.e.tar get; else z = e. srcElement;
Dragger. checkLanding (z );
}
DhtmlDragAndDropObject. prototype. checkLanding = function (htmlObject ){
If (htmlObject. dragLanding) {if (this. lastLanding) this. lastLanding. dragLanding. _ dragOut (this. lastLanding );
This. lastLanding = htmlObject; this. lastLanding = this. lastLanding. dragLanding. _ dragIn (this. lastLanding, this. dragStartNode );}
Else {
If (htmlObject. tagName! = "BODY") this. checkLanding (htmlObject. parentNode );
Else {if (this. lastLanding) this. lastLanding. dragLanding. _ dragOut (this. lastLanding); this. lastLanding = 0 ;}
}
}
DhtmlDragAndDropObject. prototype. stopDrag = function (e ){
Dragger = window. dhtmlDragAndDrop;
If (dragger. lastLanding) dragger. lastLanding. dragLanding. _ drag (dragger. dragStartNode, dragger. dragStartObject, dragger. lastLanding );
Dragger. lastLanding = 0;
Dragger. dragNode. parentNode. removeChild (dragger. dragNode );