1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 var outline_root
= null;
7 var outline_ptr
= null;
9 function onEnter(node
) {
10 var li
= document
.createElement('li');
11 outline_ptr
.appendChild(li
);
13 var header
= node
.querySelector('h1');
14 header
.id
= 'sec_' + header
.textContent
.replace(/ /g
, '_');
15 var link
= document
.createElement('a');
16 link
.href
= '#' + header
.id
;
17 link
.textContent
= header
.textContent
;
19 var ul
= document
.createElement('ul');
24 function onExit(node
) {
25 outline_ptr
= outline_ptr
.parentNode
.parentNode
;
28 function outline(node
) {
29 var in_toc
= !node
.classList
.contains('not_in_toc');
33 var child
= node
.firstChild
;
35 if (child
.tagName
=== 'SECTION') {
38 child
= child
.nextSibling
;
46 window
.onload = function () {
47 outline_root
= document
.getElementById('outline');
48 root
= document
.getElementById('root');
50 var ul
= document
.createElement('ul');
51 outline_root
.appendChild(ul
);