Benutzer:Curilias/monobook.js: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
K |
K |
||
Zeile 23: | Zeile 23: | ||
function addToggleInfoboxButton() { | function addToggleInfoboxButton() { | ||
var indexInfobox = 0; | var indexInfobox = 0; | ||
for (var i = 0; | for (var i = 0; InfoboxContainer = document.getElementsByTagName("div")[i]; i++) { | ||
if (InfoboxContainer.className == "ib_container") { | if (InfoboxContainer.className == "ib_container") { | ||
indexInfobox++; | indexInfobox++; | ||
Zeile 37: | Zeile 37: | ||
InfoboxContainer.insertBefore(ToggleInfobox, InfoboxContainer.firstChild); | InfoboxContainer.insertBefore(ToggleInfobox, InfoboxContainer.firstChild); | ||
for (var j=0; | for (var j=0; InfoboxContent = InfoboxContainer.getElementsByTagName("div")[j]; j++) { | ||
if (InfoboxContent.className == "ib_content") { | if (InfoboxContent.className == "ib_content") { | ||
InfoboxContent.setAttribute('id', 'Infobox' + indexInfobox); | InfoboxContent.setAttribute('id', 'Infobox' + indexInfobox); |
Version vom 23. Juli 2008, 00:00 Uhr
var HideInfobox = '[Verbergen]'; var ShowInfobox = '[Anzeigen]'; function toggleInfobox(indexInfobox) { var InfoboxContent = document.getElementById("Infobox" + indexInfobox); var ToggleInfobox = document.getElementById("ToggleInfobox" + indexInfobox); if (!InfoboxContent || !ToggleInfobox) { return false; } if (ToggleInfobox.firstChild.data == HideInfobox) { InfoboxContent.style.display = 'none'; } else if (ToggleInfobox.firstChild.data == ShowInfobox) { InfoboxContent.style.display = 'block'; } if (ToggleInfobox.firstChild.data == HideInfobox) { ToggleInfobox.firstChild.data = ShowInfobox; } else { ToggleInfobox.firstChild.data = HideInfobox; } } function addToggleInfoboxButton() { var indexInfobox = 0; for (var i = 0; InfoboxContainer = document.getElementsByTagName("div")[i]; i++) { if (InfoboxContainer.className == "ib_container") { indexInfobox++; // create linkt to toggle visibility var ToggleInfobox = document.createElement("a"); ToggleInfobox.className = 'ib_toggle'; ToggleInfobox.setAttribute('id', 'ToggleInfobox' + indexInfobox ); ToggleInfobox.setAttribute('href', 'javascript:toggleInfobox(' + indexInfobox + ');'); var ToggleCaption = document.createTextNode(HideInfobox); ToggleInfobox.appendChild(ToggleCaption); InfoboxContainer.insertBefore(ToggleInfobox, InfoboxContainer.firstChild); for (var j=0; InfoboxContent = InfoboxContainer.getElementsByTagName("div")[j]; j++) { if (InfoboxContent.className == "ib_content") { InfoboxContent.setAttribute('id', 'Infobox' + indexInfobox); } } } } } addOnloadHook(addToggleInfoboxButton);