diff options
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. */ |