Advertisement
Guest User

Untitled

a guest
Nov 6th, 2011
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function getTree(o){
  2.     var a = [],
  3.         child = o.firstElementChild;
  4.     while(child!=='undefined')
  5.     {
  6.         a.push({
  7.             parent : child,
  8.             childs : (function(){
  9.                 if (child.firstElementChild)
  10.                 {
  11.                     return getTree(child);
  12.                 }
  13.                 else
  14.                 {
  15.                     return null;
  16.                 }
  17.             })()
  18.         });
  19.         if (child.nextElementSibling)
  20.         {
  21.             child=child.nextElementSibling;
  22.         }
  23.         else
  24.         {
  25.             child='undefined';
  26.         }
  27.     }
  28.    
  29.     return a;
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement