doc/scripts/toc.js
function(ul) {
    var prevLevel = {level: -1, index: -1, parent: -1, val: ''};
    var levelParent = {0: -1};
    tocList = ul.children("li");
    tocList.each(function(i) {
      var me = $(this).removeClass("toc-active");
      var currentLevel = parseInt(me.attr('class').trim().slice(-1));
      if (currentLevel > prevLevel.level) {
        currentParent = prevLevel.index;
      } else if (currentLevel == prevLevel.level) {
        currentParent = prevLevel.parent;
      } else if (currentLevel < prevLevel.level) {
        currentParent = levelParent[currentLevel] || prevLevel.parent;
      }
      levelParent[currentLevel] = currentParent;
      var currentVal = $('a', this).text().trim().toLowerCase();
      treeObject[i] = {
        val: currentVal,
        level: currentLevel,
        parent: currentParent
      }
      prevLevel = {index: i, val: currentVal, level: currentLevel, parent: currentParent};
    });
  }
function(ul) {
    var prevLevel = {level: -1, index: -1, parent: -1, val: ''};
    var levelParent = {0: -1};
    tocList = ul.children("li");
    tocList.each(function(i) {
      var me = $(this).removeClass("toc-active");
      var currentLevel = parseInt(me.attr('class').trim().slice(-1));
      if (currentLevel > prevLevel.level) {
        currentParent = prevLevel.index;
      } else if (currentLevel == prevLevel.level) {
        currentParent = prevLevel.parent;
      } else if (currentLevel < prevLevel.level) {
        currentParent = levelParent[currentLevel] || prevLevel.parent;
      }
      levelParent[currentLevel] = currentParent;
      var currentVal = $('a', this).text().trim().toLowerCase();
      treeObject[i] = {
        val: currentVal,
        level: currentLevel,
        parent: currentParent
      }
      prevLevel = {index: i, val: currentVal, level: currentLevel, parent: currentParent};
    });
  }
function ( ul ) { var prevLevel = { level : - 1 , index : - 1 , parent : - 1 , val : '' } ; var levelParent = { 0 : - 1 } ; tocList = ul . children ( "li" ) ; tocList . each ( function ( i ) { var me = $ ( this ) . removeClass ( "toc-active" ) ; var currentLevel = parseInt ( me . attr ( 'class' ) . trim ( ) . slice ( - 1 ) ) ; if ( currentLevel > prevLevel . level ) { currentParent = prevLevel . index ; } else if ( currentLevel == prevLevel . level ) { currentParent = prevLevel . parent ; } else if ( currentLevel < prevLevel . level ) { currentParent = levelParent [ currentLevel ] || prevLevel . parent ; } levelParent [ currentLevel ] = currentParent ; var currentVal = $ ( 'a' , this ) . text ( ) . trim ( ) . toLowerCase ( ) ; treeObject [ i ] = { val : currentVal , level : currentLevel , parent : currentParent } prevLevel = { index : i , val : currentVal , level : currentLevel , parent : currentParent } ; } ) ; }
Create the tree
Create the tree