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

Aus Shadowhelix
Zur Navigation springen Zur Suche springen
Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
Zeile 38: Zeile 38:
             ButtonID[9]  = "Unterwelt";
             ButtonID[9]  = "Unterwelt";
             ButtonID[10] = "Alles";
             ButtonID[10] = "Alles";
            var Button    = document.createElement( "span" );
            Button.style.styleFloat = "left";
            Button.style.cssFloat = "left";
            Button.style.fontWeight = "normal";
            Button.style.textAlign = "center";
            Button.style.width = "6em";
            var ButtonLink = document.createElement( "a" );
            ButtonLink.style.color = Navigation[i].style.color;
            for ( var j = 0; j < ButtonID.length; j++ ) {
                var CopyButton = Button;
                var CopyButtonLink = ButtonLink;
                if (j == (ButtonID.length - 1)) {
                    CopyButton.style.styleFloat = "right";
                    CopyButton.style.cssFloat = "right";
                }
                var CopyButtonText = document.createTextNode( ButtonID[j] );
                CopyButtonLink.setAttribute( "id", ButtonID[j] );
               
                if (j == (ButtonID.length - 1) ) {
                    CopyButtonLink.setAttribute( "href", "javascript:obj_toggle()" );
                } else {
                    CopyButtonLink.setAttribute( "href", "javascript:obj_toggle_theme('"+ButtonID[j].toLowerCase()+"')" );
                }
                CopyButtonLink.appendChild( CopyButtonText );
                CopyButton.appendChild( document.createTextNode( "[" ) );
                CopyButton.appendChild( CopyButtonLink );
                CopyButton.appendChild( document.createTextNode( "]" ) );
                Navigation[i].insertBefore( CopyButton, Navigation[i].childNodes[0] );


         }
         }

Version vom 22. Juli 2008, 16:31 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": ""};

}

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]  = "Drachen";
            ButtonID[1]  = "Katastrophen";
            ButtonID[2]  = "Konzerne";
            ButtonID[3]  = "Kriege";
            ButtonID[4]  = "Magie";
            ButtonID[5]  = "Metamenschen";
            ButtonID[6]  = "Politik";
            ButtonID[7]  = "Sport";
            ButtonID[8]  = "Technologie";
            ButtonID[9]  = "Unterwelt";
            ButtonID[10] = "Alles";

        }
    }
 
}

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);
    };
})();