godoc: new design

This is not the finished product,
but a good checkpoint from which to
proceed with further development.

R=golang-dev, dsymonds, r
CC=golang-dev
https://golang.org/cl/5571061
This commit is contained in:
Andrew Gerrand 2012-02-13 21:22:36 +11:00
parent 159ee8a42f
commit d84de09e1d
15 changed files with 678 additions and 802 deletions

View file

@ -23,7 +23,6 @@ bindEvent(window, 'load', godocs_onload);
function godocs_onload() {
godocs_bindSearchEvents();
godocs_generateTOC();
godocs_addTopLinks();
godocs_bindExampleToggles();
}
@ -64,8 +63,15 @@ function godocs_generateTOC() {
var toc_items = [];
var i;
var seenNav = false;
for (i = 0; i < navbar.parentNode.childNodes.length; i++) {
var node = navbar.parentNode.childNodes[i];
if (!seenNav) {
if (node.id == 'nav') {
seenNav = true;
}
continue;
}
if ((node.tagName != 'h2') && (node.tagName != 'H2') &&
(node.tagName != 'h3') && (node.tagName != 'H3')) {
continue;
@ -152,33 +158,6 @@ function godocs_nodeToText(node) {
return text;
}
/* For each H2 heading, add a link up to the #top of the document.
* (As part of this: ensure existence of 'top' named anchor link
* (theoretically at doc's top).)
*/
function godocs_addTopLinks() {
/* Make sure there's a "top" to link to. */
var top = document.getElementById('top');
if (!top) {
document.body.id = 'top';
}
if (!document.getElementsByTagName) return; // no browser support
var headers = document.getElementsByTagName('h2');
for (var i = 0; i < headers.length; i++) {
var span = document.createElement('span');
span.className = 'navtop';
var link = document.createElement('a');
span.appendChild(link);
link.href = '#top';
var textNode = document.createTextNode('[Top]');
link.appendChild(textNode);
headers[i].appendChild(span);
}
}
function godocs_bindExampleToggles() {
var examples = document.getElementsByClassName("example");
for (var i = 0; i < examples.length; i++) {