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

Aus Shadowhelix
Zur Navigation springen Zur Suche springen
(test)
Keine Bearbeitungszusammenfassung
Zeile 88: Zeile 88:
function obj_toggle_magie() {
function obj_toggle_magie() {
obj_toggle();
obj_toggle();
        var test = "/magie/";
var objects = document.getElementsByTagName('td');
var objects = document.getElementsByTagName('td');
for (var i=0; i < objects.length; i++) {
for (var i=0; i < objects.length; i++) {
var keys = String(objects[i].getAttribute('id'));
var keys = String(objects[i].getAttribute('id'));
if (keys.search("/magie/") != -1) {}
if (keys.search(test) != -1) {}
else {objects[i].style.display = 'none'}
else {objects[i].style.display = 'none'}
}
}

Version vom 22. Juli 2008, 11:45 Uhr

/* Ergänzung der Editierzeile mit zusätzlichen Buttons */

if (mwCustomEditButtons) {

    mwCustomEditButtons[mwCustomEditButtons.length] = {
        "imageFile": "http://shadowhelix.de/images/b/b9/Button_E.png",
        "speedTip": "Artikelende",
        "tagOpen": "<!-- Ende des Artikelinhalts - Metainformationen -->",
        "tagClose": "",
        "sampleText": ""};

    mwCustomEditButtons[mwCustomEditButtons.length] = {
        "imageFile": "http://shadowhelix.de/images/b/b0/Button_trash.png",
        "speedTip": "Löschantrag",
        "tagOpen": "{{Löschantrag|}}",
        "tagClose": "",
        "sampleText": ""};

}

/* Buttons für Jahresartikel-Navigation */

function createNavButtons() {

    var Navigation = document.getElementsByTagName( "div" );
 
    for ( var i = 0; i < Navigation.length; i++ ) {
        if ( hasClass( Navigation[i], "jahresartikel" ) ) {
 
            var Button1     = document.createElement( "span" );
            var Button1Link = document.createElement( "a" );
            var Button1Text = document.createTextNode( "Alles" );
 
            Button1.style.styleFloat = "right";
            Button1.style.cssFloat = "right";
            Button1.style.fontWeight = "normal";
            Button1.style.textAlign = "right";
            Button1.style.width = "6em";
 
            Button1Link.style.color = Navigation[i].style.color;
            Button1Link.setAttribute( "id", "AllesButton" );
            Button1Link.setAttribute( "href", "javascript:obj_toggle()" );
            Button1Link.appendChild( Button1Text );
 
            Button1.appendChild( document.createTextNode( "[" ) );
            Button1.appendChild( Button1Link );
            Button1.appendChild( document.createTextNode( "]" ) );
 
            Navigation[i].insertBefore( Button1, Navigation[i].childNodes[0] );

            var Button2     = document.createElement( "span" );
            var Button2Link = document.createElement( "a" );
            var Button2Text = document.createTextNode( "Magie" );
 
            Button2.style.styleFloat = "right";
            Button2.style.cssFloat = "right";
            Button2.style.fontWeight = "normal";
            Button2.style.textAlign = "left";
            Button2.style.width = "6em";
 
            Button2Link.style.color = Navigation[i].style.color;
            Button2Link.setAttribute( "id", "MagieButton" );
            Button2Link.setAttribute( "href", "javascript:obj_toggle_magie()" );
            Button2Link.appendChild( Button2Text );
 
            Button2.appendChild( document.createTextNode( "[" ) );
            Button2.appendChild( Button2Link );
            Button2.appendChild( document.createTextNode( "]" ) );
 
            Navigation[i].insertBefore( Button2, Navigation[i].childNodes[0] );

        }
    }
 
}
 
addOnloadHook( createNavButtons );

/* Ausblendfunktionen */

function obj_toggle() {
	var objects = document.getElementsByTagName('td');
	for (var i=0; i < objects.length; i++) {
		objects[i].style.display = ''
	}
}

function obj_toggle_magie() {
	obj_toggle();
        var test = "/magie/";
	var objects = document.getElementsByTagName('td');
	for (var i=0; i < objects.length; i++) {
		var keys = String(objects[i].getAttribute('id'));
		if (keys.search(test) != -1) {}
		else {objects[i].style.display = 'none'}
	}
}

function obj_toggle_theme( themeIdx ) {

        var theme = new Array(10);
        theme[0]  = "/drachen/";
        theme[1]  = "/katastrophen/";
        theme[2]  = "/konzerne/";
        theme[3]  = "/kriege/";
        theme[4]  = "/magie/";
        theme[5]  = "/metamenschen/";
        theme[6]  = "/politik/";
        theme[7]  = "/sport/";
        theme[8]  = "/technologie/";
        theme[9]  = "/unterwelt/";

	obj_toggle();
	var objects = document.getElementsByTagName('td');
	for (var i=0; i < objects.length; i++) {
		var keys = String(objects[i].getAttribute('id'));
		if (keys.search(theme[themeIdx]) != -1) {}
		else {objects[i].style.display = 'none'}
	}
}

/* Test if an element has a certain class
 *
 * Copied from Wikipedia
 */
 
var hasClass = (function () {
    var reCache = {};
    return function (element, className) {
        return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className);
    };
})();