Benutzer:Curilias/monobook.js: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
K |
K |
||
Zeile 8: | Zeile 8: | ||
if (!Infobox || !ToggleInfobox) { return false; } | if (!Infobox || !ToggleInfobox) { return false; } | ||
if (ToggleInfobox.firstChild.data == HideInfobox) { | |||
Infobox.style.display = 'none'; | |||
} else if (ToggleInfobox.firstChild.data == ShowInfobox) { | |||
Infobox.style.display = 'block'; | |||
} | } | ||
Zeile 28: | 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 ( | if (InfoboxContainer.className == "ib_container") { | ||
indexInfobox++; | indexInfobox++; | ||
var ToggleInfobox = document.createElement("a"); | var ToggleInfobox = document.createElement("a"); | ||
Zeile 35: | Zeile 30: | ||
ToggleInfobox.setAttribute('id', 'ToggleInfobox' + indexInfobox ); | ToggleInfobox.setAttribute('id', 'ToggleInfobox' + indexInfobox ); | ||
ToggleInfobox.setAttribute('href', 'javascript:toggleInfobox(' + indexInfobox + ');'); | ToggleInfobox.setAttribute('href', 'javascript:toggleInfobox(' + indexInfobox + ');'); | ||
var ToggleCaption = document.createTextNode(HideInfobox); | var ToggleCaption = document.createTextNode(HideInfobox); | ||
ToggleInfobox.appendChild(ToggleCaption); | ToggleInfobox.appendChild(ToggleCaption); | ||
Infobox.getElementsByTagName(' | |||
InfoboxContainer.appendChild(ToggleInfobox); | |||
var Infobox = InfoboxContainer.getElementsByTagName('table')[0]; | |||
Infobox.setAttribute('id', 'Infobox' + indexInfobox); | Infobox.setAttribute('id', 'Infobox' + indexInfobox); | ||
} | } |
Version vom 22. Juli 2008, 22:51 Uhr
var HideInfobox = '[Verbergen]'; var ShowInfobox = '[Anzeigen]'; function toggleInfobox(indexInfobox) { var Infobox = document.getElementById("Infobox" + indexInfobox); var ToggleInfobox = document.getElementById("ToggleInfobox" + indexInfobox); if (!Infobox || !ToggleInfobox) { return false; } if (ToggleInfobox.firstChild.data == HideInfobox) { Infobox.style.display = 'none'; } else if (ToggleInfobox.firstChild.data == ShowInfobox) { Infobox.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++; var ToggleInfobox = document.createElement("a"); ToggleInfobox.className = 'ToggleInfobox'; ToggleInfobox.setAttribute('id', 'ToggleInfobox' + indexInfobox ); ToggleInfobox.setAttribute('href', 'javascript:toggleInfobox(' + indexInfobox + ');'); var ToggleCaption = document.createTextNode(HideInfobox); ToggleInfobox.appendChild(ToggleCaption); InfoboxContainer.appendChild(ToggleInfobox); var Infobox = InfoboxContainer.getElementsByTagName('table')[0]; Infobox.setAttribute('id', 'Infobox' + indexInfobox); } } } addOnloadHook(addToggleInfoboxButton);