@@ -82,19 +82,21 @@ function walkTree(tree) {
8282 }
8383}
8484
85- function renderNav ( docstoc ) {
86- for ( let i = 0 ; i < docstoc . horizontalnav . length ; i ++ ) {
87- if ( docstoc . horizontalnav [ i ] . path === pageURL || pageIsInSection ( docstoc [ docstoc . horizontalnav [ i ] . node ] ) ) {
88- // This is the current section. Set the corresponding header-nav link
89- // to active, and build the left-hand (vertical) navigation
90- document . getElementById ( docstoc . horizontalnav [ i ] . node ) . closest ( "li" ) . classList . add ( "active" )
91- walkTree ( docstoc [ docstoc . horizontalnav [ i ] . node ] ) ;
92- document . getElementById ( "jsTOCLeftNav" ) . innerHTML = outputLetNav . join ( "" ) ;
85+ function renderNav ( ) {
86+ getJSON ( "/js/toc.json" , function ( data ) {
87+ for ( const item of data . horizontalnav ) {
88+ if ( item . path === pageURL || pageIsInSection ( data [ item . node ] ) ) {
89+ // This is the current section. Set the corresponding header-nav link
90+ // to active, and build the left-hand (vertical) navigation
91+ _ ( '#' + item . node ) . closest ( "li" ) . classList . add ( "active" )
92+ walkTree ( data [ item . node ] ) ;
93+ _ ( "#jsTOCLeftNav" ) . innerHTML = outputLetNav . join ( "" ) ;
94+ }
9395 }
94- }
95- // Scroll the current menu item into view. We actually pick the item * above*
96- // the current item to give some headroom above
97- scrollMenuItem ( "#jsTOCLeftNav a.currentPage" )
96+ // Scroll the current menu item into view. We actually pick the item *above*
97+ // the current item to give some headroom above
98+ scrollMenuItem ( "#jsTOCLeftNav a.currentPage" )
99+ } ) ;
98100}
99101
100102// Scroll the given menu item into view. We actually pick the item *above*
@@ -256,3 +258,5 @@ window.onload = function () {
256258 $ ( '.nav-tabs > li > a[data-group="' + group + '"]' ) . tab ( "show" ) ;
257259 } ) ;
258260} ;
261+
262+ ready ( renderNav ) ;
0 commit comments