3,661
edits
(UTC clocks all around!) |
m (this probably wont work either) |
||
Line 106: | Line 106: | ||
} | } | ||
} | } | ||
function createContentTabs() { | |||
var ict=0; var ctdiv; var tabs; var toggle;var firstTab;var firstToggle; | |||
var divs = document.getElementsByTagName("div"); | |||
for (var i=0; i<divs.length; i++) { | |||
ctdiv = divs[i]; | |||
if (ctdiv.className == "Tabs") { | |||
ict++; | |||
//alert("tab for div i "+i + " ict="+ict); | |||
if (document.getElementById("ct_"+ict)) continue; | |||
ctdiv.parentNode.id = "ct_"+ict; | |||
tabs = ctdiv.childNodes; | |||
for (var j=0; j < tabs.length; j++) { | |||
var tab = tabs[j]; | |||
var toggle = document.createElement("a"); | |||
var tabName = tab.className; | |||
if (!tabName) continue; | |||
//toggle.setAttribute('href', 'javascript:toggleTab(this,\''+'ct_'+ict+'\', \'' + tabName + '\',0);'); | |||
toggle.setAttribute('href', 'javascript:void(0)'); | |||
toggle.setAttribute('onclick', 'toggleTab(this,\''+'ct_'+ict+'\', \'' + tabName + '\',0);'); | |||
var spLabel = tab.innerHTML; | |||
if (!spLabel) continue; | |||
toggle.innerHTML = spLabel; | |||
if (!firstTab) { | |||
firstTab = tabName; | |||
toggle.setAttribute('id','ct_'+ict+'_first'); | |||
//toggle.setAttribute('class',"first"); | |||
} | |||
ctdiv.appendChild(toggle); | |||
ctdiv.removeChild(tab); | |||
} | |||
toggleTab(1,'ct_'+ict, firstTab,1); | |||
firstTab=null; | |||
} | |||
} | |||
} | |||
function toggleTab(elem,ct_id,tab_id,first) { | |||
//alert("in "+ct_id+ " hiding all but " +tab_id + " sender: "+elem); | |||
var ctdiv = document.getElementById(ct_id); | |||
for (var i=0; i < ctdiv.childNodes.length;i++) { | |||
if (ctdiv.childNodes[i].className=="Contents") { | |||
var contentdiv = ctdiv.childNodes[i]; | |||
for (var j=0; j <contentdiv.childNodes.length;j++) { | |||
if (contentdiv.childNodes[j].style) contentdiv.childNodes[j].style.display = "none"; | |||
} | |||
} | |||
if (ctdiv.childNodes[i].className=="Tabs") { | |||
var contentdiv = ctdiv.childNodes[i]; | |||
for (var j=0; j <contentdiv.childNodes.length;j++) { | |||
if (contentdiv.childNodes[j].className){ | |||
contentdiv.childNodes[j].className = ""; | |||
} | |||
} | |||
if (first) contentdiv.childNodes[0].className = "active"; | |||
} | |||
} | |||
if (document.getElementById(tab_id).style) { | |||
//alert("setting style of id "+tab_id); | |||
document.getElementById(tab_id).style.display = "block"; | |||
if (!first) elem.className = "active"; | |||
} | |||
} | |||
addOnloadHook(createContentTabs); | |||
/*</nowiki>*/ | /*</nowiki>*/ |
edits