Tree.js Code
********************************
List of tree organization frames
v1.0
January 6, 2011
Author: Flycrosscloud
********************************/
Initializing the framework
var allimages = {
Hasnodeclose: "Hasnodeopen: "Lasthasnodeclose: "Lasthasnodeopen: "Commonnode: "Lastcommonnode: "Nodeline: "Nodeclose: "Nodeopen: "Nodeblank: "};
$ (function ()
{
$.post ("Http://localhost/system/asmx/wstree.asmx/helloworld", function (data) {inittree (data);});
});
function Inittree (org_data)
{
var org = eval ("+ Org_data +"));
Drawtree (org, 1, "", "#nodetree");
$ ("#nodetree img"). Bind ("click", Function (event)
{
$ (this). Parent (). FIND ("ul"). Toggle ();
});
}
function Drawtree (org, S, Ppreline, Ulname)
{
var orglength = org.length;
var preline;
var count = s;
for (var i = 0; i < orglength; i++)
{
var nodeimg = Allimages.nodeclose; Project Front icon
var prenodeline; Project Icon Front Line
To determine the front icon for a project
if (org[i].childunits!= null)//If a child node is included
{
nodeimg = Allimages.nodeopen;
}
To determine the front line of a graphic
if ((org[i].childunits!= null) && (i = = orglength-1))
{
Contains child nodes and is the last node in this layer
Prenodeline = Allimages.lasthasnodeopen;
}
if ((org[i].childunits = null) && (i = = orglength-1))
{
Does not contain child nodes and is the last node in this layer
Prenodeline = Allimages.lastcommonnode;
}
if ((org[i].childunits!= null) && (i!= orglength-1))
{
Contains child nodes and is not the last node in this layer
Prenodeline = Allimages.hasnodeopen;
}
if ((org[i].childunits = null) && (i!= orglength-1))
{
Does not contain child nodes and is not the last node in this layer
Prenodeline = Allimages.commonnode;
}
if (i = = orglength-1)
{
Preline = Ppreline + Allimages.nodeblank;
}
Else
{
Preline = Ppreline + allimages.nodeline;
}
var temp = $ ("<li>" + ppreline + prenodeline + nodeimg + "<a href= ' # ' >" + org[i].unit_name + "</a></l I> ");
$ (ulname). Append (temp);
if (org[i].childunits!= null)
{
Temp.append ("<ul></ul>");
var content = Temp.find ("ul");
Drawtree (Org[i].childunits, Count + 1, preline,content);
}
}
}
TREE.CSS Tutorial