| 1 |
function setup_dropdowns() { |
| 2 |
var els = document.getElementsByTagName('UL'); |
| 3 |
for (var i = 0; i < els.length; i++) { |
| 4 |
var el = els[i]; |
| 5 |
if (el.className.search(/\bcontents\b/) > -1) { |
| 6 |
enable_dropdown(el); |
| 7 |
} |
| 8 |
} |
| 9 |
} |
| 10 |
|
| 11 |
function enable_dropdown(el) { |
| 12 |
var title = el.getElementsByTagName('LI')[0]; |
| 13 |
var plus_minus = document.createTextNode(' [-]'); |
| 14 |
if (title.childNodes[0].tagName != 'A') { |
| 15 |
anchor = document.createElement('A'); |
| 16 |
while (title.childNodes.length) { |
| 17 |
anchor.appendChild(title.childNodes[0]); |
| 18 |
} |
| 19 |
anchor.setAttribute('href', '#'); |
| 20 |
anchor.style.padding = '1px'; |
| 21 |
title.appendChild(anchor); |
| 22 |
} else { |
| 23 |
anchor = title.childNodes[0]; |
| 24 |
} |
| 25 |
anchor.appendChild(plus_minus); |
| 26 |
function show_hide() { |
| 27 |
if (el.sub_hidden) { |
| 28 |
set_sub_li(el, ''); |
| 29 |
anchor.removeChild(plus_minus); |
| 30 |
plus_minus = document.createTextNode(' [-]'); |
| 31 |
anchor.appendChild(plus_minus); |
| 32 |
} else { |
| 33 |
set_sub_li(el, 'none'); |
| 34 |
anchor.removeChild(plus_minus); |
| 35 |
plus_minus = document.createTextNode(' [+]'); |
| 36 |
anchor.appendChild(plus_minus); |
| 37 |
} |
| 38 |
el.sub_hidden = ! el.sub_hidden; |
| 39 |
return false; |
| 40 |
} |
| 41 |
anchor.onclick = show_hide; |
| 42 |
show_hide(); |
| 43 |
} |
| 44 |
|
| 45 |
function set_sub_li(list, display) { |
| 46 |
var sub = list.getElementsByTagName('LI'); |
| 47 |
for (var i = 1; i < sub.length; i++) { |
| 48 |
sub[i].style.display = display; |
| 49 |
} |
| 50 |
} |
| 51 |
|
| 52 |
function add_onload(func) { |
| 53 |
if (window.onload) { |
| 54 |
var old_onload = window.onload; |
| 55 |
function new_onload() { |
| 56 |
old_onload(); |
| 57 |
func(); |
| 58 |
} |
| 59 |
window.onload = new_onload; |
| 60 |
} else { |
| 61 |
window.onload = func; |
| 62 |
} |
| 63 |
} |
| 64 |
|
| 65 |
add_onload(setup_dropdowns); |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|