[Sync] Componentize UIModelWorker.
[chromium-blink-merge.git] / components / onc / docs / onc_spec.js
blob8cc027a0f807eb30926d615c822dbf9eaea44523
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;
6 var 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;
18   li.appendChild(link);
19   var ul = document.createElement('ul');
20   li.appendChild(ul);
21   outline_ptr = 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');
30   if (in_toc) {
31     onEnter(node);
32   }
33   var child = node.firstChild;
34   while (child) {
35     if (child.tagName === 'SECTION') {
36       outline(child);
37     }
38     child = child.nextSibling;
39   }
40   if (in_toc) {
41     onExit(node);
42   }
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);
52   outline_ptr = ul;
54   outline(root);