隨筆 - 154  文章 - 60  trackbacks - 0
          <2007年10月>
          30123456
          78910111213
          14151617181920
          21222324252627
          28293031123
          45678910

          聲明:

          該blog是為了收集資料,認識朋友,學習、提高技術,所以本blog的內容除非聲明,否則一律為轉載!!

          感謝那些公開自己技術成果的高人們!!!

          支持開源,尊重他人的勞動!!

          常用鏈接

          留言簿(3)

          隨筆分類(148)

          隨筆檔案(143)

          收藏夾(2)

          其他

          學習(技術)

          觀察思考(非技術)

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          <button onclick=s.moveNext()>next</button><button onclick=s.movePre()>pre</button><button onclick=s.reLoad()>reload</button>
          <script>
          function eyunTree(Tname)
            {if(typeof(Tname) != "string" || Tname == "")
               throw(new Error(-1, '創建類實例的時候請把類實例的引用變量名傳遞進來!'));
             this.O=null;
             this.tree="";
             this.nodes=new Array();
             this.header="<table border='0'  height='20' cellspacing='0' cellpadding='1'>\r\n";
             this.footer="</table>\r\n";
             this.style= "<style type='text/css'>\r\n";
             this.style+="  td{white-space: nowrap;font:9pt/150% '宋體';}\r\n";
             this.style+="  .on{cursor:hand;background-color:#B5BED6;border:1px solid #08246B;}\r\n";
             this.style+="  .click{cursor:hand;background-color:#FFFFFF;border:1px solid #B5BED6;}\r\n";
             this.style+="</style>";
             this.addNode=function (parent,text,hasChild,href,target)
                            {if(hasChild!=1 && arguments.length!=5)
                               throw(new Error(-2, '參數錯誤!'));
                             var nodeHeader="  <tr style='display:none'>\r\n    <td><table style='margin-left:15' border='0'  height='20' cellspacing='0' cellpadding='1'>\r\n";
                             var nodeFooter="</table></td>\r\n  </tr>\r\n";
                             var treeHead="  <tr>\r\n";
                             treeHead+=   "    <td><span onclick='"+Tname+".nodeClick(this)' onmouseout='"+Tname+".nodeOut(this)' onmouseover='"+Tname+".nodeOver(this)'";
                             var treeFoot="</span></td>\r\n";
                             treeFoot+=   "  </tr>\r\n";
                             var treeNode=treeHead+"hasChild='"+hasChild+"'";
                             if(hasChild!=1)
                               {treeNode+=" href='"+href+"' target='"+target+"'";
                                var src="comm/img/tree/leaf.gif";
                               }
                             else
                               var src="comm/img/tree/shrink.gif"
                             treeNode+="><img src='"+src+"' align='absmiddle'>"+text+treeFoot;
                             if(parent=="root")
                                treeNode=this.header+treeNode;
                             if(hasChild==1)
                               {treeNode+=nodeHeader;
                               }
                             if(this.tree!="" && this.nodes.length!=0)
                               {if(parent=="root")
                                  {while(this.nodes.length>0)
                                     {this.tree+=nodeFooter;this.nodes.length--}
                                   this.tree+=this.footer;
                                  }
                                else
                                  {if(this.nodes[this.nodes.length-1]!=parent && this.tree.lastIndexOf(parent)!=this.tree.length-parent.length)
                                     {while(this.nodes.length-1>0)
                                       {if(this.nodes[this.nodes.length-1]!=parent)
                                          this.tree+=nodeFooter;
                                        else
                                          break;
                                        this.nodes.length--
                                       }                             
                                     }
                                   }
                               }
                             if(this.nodes[this.nodes.length-1]!=parent)
                               this.nodes[this.nodes.length]=parent;
                             this.tree+=treeNode;
                             return treeNode;
                            }
              this.nodeOver=function (o)
                            {o.oldClass=o.className;
                             o.className="on";
                            }
              this.nodeOut=function (o)
                             {o.className=o.oldClass;
                             }
              this.nodeClick=function (o)
                               {if(o.hasChild=="1")
                                  {if(o.type=="open")
                                     this.treeClose(o);
                                   else
                                     this.treeOpen(o);
                                  }
                                else
                                  {tmpA.href=typeof o.href=="undefined"?"#":o.href;
                                   tmpA.target=typeof o.target=="undefined"?"_self":o.target;
                                   tmpA.click();
                                  }
                                if(this.O!=null)
                                  this.O.className=this.O.oldClass="";
                                this.O=o;
                                o.oldClass=o.className="click";
                               }
              this.treeClose=function (o)
                               {o=o.parentElement.parentElement;
                                o.nextSibling.style.display="none";
                                o.firstChild.firstChild.firstChild.src="comm/img/tree/shrink.gif";
                                o.firstChild.firstChild.type="close";
                               }

              this.treeOpen=function (o)
                              {o=o.parentElement.parentElement;
                               o.nextSibling.style.display="";s
                               o.firstChild.firstChild.firstChild.src="comm/img/tree/unwrap.gif";
                               o.firstChild.firstChild.type="open";
                              }
              this.moveNext=function ()
                              {var o=document.getElementsByTagName("SPAN");
                               var l=o.length;
                               if(this.O==null)
                                 {o[0].click(o[0]);  
                                  return true;
                                 }
                               for(var i=0;i<l;i++)
                                 if(o[i].className==this.O.className)
                                   break;
                              if(i<l-1)
                                o[i+1].click(o[i+1]);
                              else
                                o[i].click(o[i]);
                              }
              this.movePre=function ()
                             {var o=document.getElementsByTagName("SPAN");
                              var l=o.length;
                              if(this.O==null)
                                {o[0].click(o[0]);  
                                 return true;
                                }
                              for(var i=0;i<l;i++)
                                if(o[i].className==this.O.className)
                                  break;
                              if(i<l && i>0)
                                {var oP=o[i-1].parentElement;
                                 var oC=null;
                                 while(oP!=document.body)
                                   {if(oP.tagName=="TR" && oP.style.display=="none")
                                      {oP.style.display="";
                                       oP.previousSibling.firstChild.firstChild.firstChild.src="comm/img/tree/unwrap.gif";
                                       oP.previousSibling.firstChild.firstChild.type="open";
                                      }
                                    oP=oP.parentElement;
                                   }
                                 o[i-1].click(o[i-1]);
                                }
                              else
                                o[0].click(o[0]);
                             }
              this.reLoad=function ()
                            {var o=document.getElementsByTagName("SPAN");
                             var l=o.length;
                             if(this.O==null)
                               {o[0].click(o[0]);  
                                return true;
                               }
                             for(var i=0;i<l;i++)
                               if(o[i].className==this.O.className)
                                 break;
                             if(i<l)
                               o[i].click(o[i]);
                             else
                               o[0].click(o[0]);
                            }
              this.show=function ()
                          {document.writeln(this.style);
                           document.writeln(this.tree);
                           document.writeln("<a id='tmpA'></a>");
                          }
             }
            var s=new eyunTree("s")
            var n=s.addNode("root","testRoot1",1)
            var a=s.addNode(n,"testNode1",1)
            s.addNode(a,"testNodeChild1",0,"http://www.iecn.net","_blank")
            s.addNode(a,"testNodeChild2",0,"http://www.iecn.net","_blank")
            var t=s.addNode(a,"testNodeChildNode1",1)
            s.addNode(t,"testNodeChild1",0,"http://www.iecn.net","_blank")
            s.addNode(t,"testNodeChild2",0,"http://www.iecn.net","_blank")
            s.addNode(n,"testChild2",0,"http://www.iecn.net","_blank")
            s.addNode(n,"testChild3",0,"http://www.chinaddv.com","_blank")
            var o=s.addNode("root","testRoot2",1)
            s.addNode(o,"testChild1",0,"http://www.chinaddv.com","_blank")
            d=s.addNode(o,"testChild2",1)
            s.addNode(d,"testChild1",0,"http://www.chinaddv.com","_blank")
            e=s.addNode(d,"testChild1",1)
            s.addNode(e,"testChild1",0,"http://www.chinaddv.com","_blank")
            s.addNode(e,"testChild1",0,"http://www.chinaddv.com","_blank")
            s.addNode(e,"testChild1",0,"http://www.chinaddv.com","_blank")
            s.addNode(d,"testChild1",0,"http://www.chinaddv.com","_blank")
            s.addNode(o,"testChild3",0,"http://www.chinaddv.com","_blank")
            s.show();
          </script>

          posted on 2007-10-09 09:53 lk 閱讀(2471) 評論(0)  編輯  收藏 所屬分類: ajax&js
          主站蜘蛛池模板: 剑阁县| 托克逊县| 镇江市| 大渡口区| 泰来县| 莱州市| 天台县| 株洲市| 克什克腾旗| 巴东县| 罗江县| 临清市| 滦平县| 敖汉旗| 长治县| 溧水县| 淮北市| 大石桥市| 邳州市| 区。| 德江县| 鹤壁市| 临夏市| 务川| 天门市| 安达市| 井陉县| 江油市| 扎鲁特旗| 剑阁县| 体育| 肇东市| 舞钢市| 环江| 桂东县| 正阳县| 巴青县| 黄陵县| 大兴区| 奇台县| 西盟|