-
Notifications
You must be signed in to change notification settings - Fork 175
Expand file tree
/
Copy pathload_toc.js
More file actions
22 lines (20 loc) · 714 Bytes
/
load_toc.js
File metadata and controls
22 lines (20 loc) · 714 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
var httpRequest = new XMLHttpRequest();
httpRequest.onreadystatechange = function() {
if (httpRequest.readyState === XMLHttpRequest.DONE) {
if (httpRequest.status === 200) {
document.getElementById('header').innerHTML += httpRequest.responseText;
var subheaders = document.getElementsByClassName('sectlevel2');
var section;
for (var i=0; i<subheaders.length; i++) {
section = subheaders[i];
if (section.innerHTML.indexOf(window.location.pathname) === -1) {
section.style.display = 'none';
} else {
section.scrollIntoView && section.scrollIntoView();
}
}
}
}
};
httpRequest.open('GET', 'toc.html');
httpRequest.send();