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

Aus Shadowhelix
Zur Navigation springen Zur Suche springen
(Quellcode-Test...)
 
(Quellcoe-Update...)
Zeile 24: Zeile 24:


     var Navigation = document.getElementsByTagName( "div" );
     var Navigation = document.getElementsByTagName( "div" );
 
     for ( var i = 0; i < Navigation.length; i++ ) {
     for ( var i = 0; i < Navigation.length; i++ ) {
         if ( hasClass( Navigation[i], "jahresartikel" ) ) {
         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 ButtonID = new Array(11);
             var Button2Link = document.createElement( "a" );
            ButtonID[0]  = "Unterwelt";
             var Button2Text = document.createTextNode( "Magie" );
            ButtonID[1]  = "Technologie";
            ButtonID[2]  = "Sport";
            Button2.style.styleFloat = "left";
            ButtonID[3]  = "Politik";
            Button2.style.cssFloat = "left";
            ButtonID[4]  = "Metamenschen";
            Button2.style.fontWeight = "normal";
            ButtonID[5]  = "Magie";
            Button2.style.textAlign = "left";
            ButtonID[6]  = "Kriege";
            Button2.style.width = "6em";
            ButtonID[7]  = "Konzerne";
            ButtonID[8]  = "Katastrophen";
            Button2Link.style.color = Navigation[i].style.color;
            ButtonID[9]  = "Drachen";
            Button2Link.setAttribute( "id", "MagieButton" );
             ButtonID[10] = "Alles";
            Button2Link.setAttribute( "href", "javascript:obj_toggle_magie()" );
 
            Button2Link.appendChild( Button2Text );
             for ( var j = 0; j < ButtonID.length; j++ ) {
                var Button = document.createElement( "span" );
            Button2.appendChild( document.createTextNode( "[" ) );
 
            Button2.appendChild( Button2Link );
                Button.style.styleFloat = "left";
            Button2.appendChild( document.createTextNode( "]" ) );
                Button.style.cssFloat = "left";
                Button.style.fontWeight = "normal";
            Navigation[i].insertBefore( Button2, Navigation[i].childNodes[0] );
                Button.style.textAlign = "center";
                Button.style.width = "12em";
 
                if (j == (ButtonID.length - 1)) {
                    Button.style.styleFloat = "right";
                    Button.style.cssFloat = "right";
                }
 
                var ButtonLink = document.createElement( "a" );
 
                ButtonLink.style.color = Navigation[i].style.color;
                ButtonLink.setAttribute( "id", ButtonID[j] );
 
                var ButtonText = document.createTextNode( ButtonID[j] );


                if (j == (ButtonID.length - 1) ) {
                    ButtonLink.setAttribute( "href", "javascript:obj_toggle()" );
                } else {
                    ButtonLink.setAttribute( "href", "javascript:obj_toggle_theme('"
                    +ButtonID[j].toLowerCase()+"')" );
                }
                ButtonLink.appendChild( ButtonText );
                Button.appendChild( document.createTextNode( "[" ) );
                Button.appendChild( ButtonLink );
                Button.appendChild( document.createTextNode( "]" ) );
                Navigation[i].insertBefore( Button, Navigation[i].childNodes[0] );
            }
         }
         }
     }
     }
}
}
 
addOnloadHook( createNavButtons );
addOnloadHook( createNavButtons );


Zeile 80: Zeile 86:


function obj_toggle() {
function obj_toggle() {
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++) {
objects[i].style.display = ''
        objects[i].style.display = ''
}
    }
}
 
function obj_toggle_magie() {
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(/magie/) != -1) {}
else {objects[i].style.display = 'none'}
}
}
}


function obj_toggle_theme( theme ) {
function obj_toggle_theme( theme ) {
obj_toggle();
    obj_toggle();
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(theme) != -1) {}
        if (keys.search(theme) != -1) {}
else {objects[i].style.display = 'none'}
        else {objects[i].style.display = 'none'}
}
    }
}
}



Version vom 22. Juli 2008, 18:34 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 ButtonID = new Array(11);
            ButtonID[0]  = "Unterwelt";
            ButtonID[1]  = "Technologie";
            ButtonID[2]  = "Sport";
            ButtonID[3]  = "Politik";
            ButtonID[4]  = "Metamenschen";
            ButtonID[5]  = "Magie";
            ButtonID[6]  = "Kriege";
            ButtonID[7]  = "Konzerne";
            ButtonID[8]  = "Katastrophen";
            ButtonID[9]  = "Drachen";
            ButtonID[10] = "Alles";

            for ( var j = 0; j < ButtonID.length; j++ ) {
                var Button = document.createElement( "span" );

                Button.style.styleFloat = "left";
                Button.style.cssFloat = "left";
                Button.style.fontWeight = "normal";
                Button.style.textAlign = "center";
                Button.style.width = "12em";

                if (j == (ButtonID.length - 1)) {
                    Button.style.styleFloat = "right";
                    Button.style.cssFloat = "right";
                }

                var ButtonLink = document.createElement( "a" );

                ButtonLink.style.color = Navigation[i].style.color;
                ButtonLink.setAttribute( "id", ButtonID[j] );

                var ButtonText = document.createTextNode( ButtonID[j] );

                if (j == (ButtonID.length - 1) ) {
                    ButtonLink.setAttribute( "href", "javascript:obj_toggle()" );
                } else {
                    ButtonLink.setAttribute( "href", "javascript:obj_toggle_theme('"
                    +ButtonID[j].toLowerCase()+"')" );
                }

                ButtonLink.appendChild( ButtonText );

                Button.appendChild( document.createTextNode( "[" ) );
                Button.appendChild( ButtonLink );
                Button.appendChild( document.createTextNode( "]" ) );

                Navigation[i].insertBefore( Button, 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_theme( theme ) {
    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) != -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);
    };
})();