Benutzer:Curilias/monobook.js: Unterschied zwischen den Versionen

Aus MIDGARD-Wiki
Zur Navigation springen Zur Suche springen
K
K
Zeile 3: Zeile 3:


function toggleInfobox(indexInfobox) {
function toggleInfobox(indexInfobox) {
var Infobox = document.getElementById("Infobox" + indexInfobox);
var InfoboxContent = document.getElementById("Infobox" + indexInfobox);
var ToggleInfobox = document.getElementById("ToggleInfobox" + indexInfobox);
var ToggleInfobox = document.getElementById("ToggleInfobox" + indexInfobox);


if (!Infobox || !ToggleInfobox) { return false; }
if (!InfoboxContent || !ToggleInfobox) { return false; }


if (ToggleInfobox.firstChild.data == HideInfobox) {
if (ToggleInfobox.firstChild.data == HideInfobox) {
Infobox.style.display = 'none';
InfoboxContent.style.display = 'none';
} else if (ToggleInfobox.firstChild.data == ShowInfobox) {
} else if (ToggleInfobox.firstChild.data == ShowInfobox) {
Infobox.style.display = 'block';
InfoboxContent.style.display = 'block';
}
}


Zeile 23: Zeile 23:
function addToggleInfoboxButton() {
function addToggleInfoboxButton() {
var indexInfobox = 0;
var indexInfobox = 0;
for (var i=0; InfoboxContainer = document.getElementsByTagName("div")[i]; i++) {
for (var i = 0; InfoboxContainer = document.getElementsByTagName("div")[i]; i++) {
if (InfoboxContainer.className == "ib_container") {
if (InfoboxContainer.className == "ib_container") {
indexInfobox++;
indexInfobox++;
// create linkt to toggle visibility
var ToggleInfobox = document.createElement("a");
var ToggleInfobox = document.createElement("a");
ToggleInfobox.className = 'ib_toggle';
ToggleInfobox.className = 'ib_toggle';
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);


InfoboxContainer.insertBefore(ToggleInfobox, InfoboxContainer.firstChild);
InfoboxContainer.insertBefore(ToggleInfobox, InfoboxContainer.firstChild);
var Infobox = InfoboxContainer.getElementsByTagName('table')[0];
 
Infobox.setAttribute('id', 'Infobox' + indexInfobox);
for (var j=0; InfoboxContent = InfoboxContainer.getElementsByTagName("div")[j]; j++) {
if (InfoboxContainer.className == "ib_content") {
Infobox.setAttribute('id', 'Infobox' + indexInfobox);
}
}
}
}
}
}

Version vom 22. Juli 2008, 23:50 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 (InfoboxContainer.className == "ib_content") {
					Infobox.setAttribute('id', 'Infobox' + indexInfobox);
				}
			}
		}
	}
}
 
addOnloadHook(addToggleInfoboxButton);