diff options
author | Ondřej Surý <ondrej@sury.org> | 2011-01-17 12:40:45 +0100 |
---|---|---|
committer | Ondřej Surý <ondrej@sury.org> | 2011-01-17 12:40:45 +0100 |
commit | 3e45412327a2654a77944249962b3652e6142299 (patch) | |
tree | bc3bf69452afa055423cbe0c5cfa8ca357df6ccf /doc/godocs.js | |
parent | c533680039762cacbc37db8dc7eed074c3e497be (diff) | |
download | golang-upstream/2011.01.12.tar.gz |
Imported Upstream version 2011.01.12upstream/2011.01.12
Diffstat (limited to 'doc/godocs.js')
-rw-r--r-- | doc/godocs.js | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/doc/godocs.js b/doc/godocs.js index b2fc1b357..8b451547d 100644 --- a/doc/godocs.js +++ b/doc/godocs.js @@ -11,17 +11,32 @@ /* We want to do some stuff on page load (after the HTML is rendered). So listen for that: */ -if (window.addEventListener){ - window.addEventListener('load', godocs_onload, false); -} else if (window.attachEvent){ - window.attachEvent('onload', godocs_onload); +function bindEvent(el, e, fn) { + if (el.addEventListener){ + el.addEventListener(e, fn, false); + } else if (el.attachEvent){ + el.attachEvent('on'+e, fn); + } } +bindEvent(window, 'load', godocs_onload); function godocs_onload() { + godocs_bindSearchEvents(); godocs_generateTOC(); godocs_addTopLinks(); } +function godocs_bindSearchEvents() { + var search = document.getElementById('search'); + function clearInactive() { + if (search.className == "inactive") { + search.value = ""; + search.className = ""; + } + } + bindEvent(search, 'focus', clearInactive); +} + /* Generates a table of contents: looks for h2 and h3 elements and generates * links. "Decorates" the element with id=="nav" with this table of contents. */ |