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

Aus Shadowhelix
Zur Navigation springen Zur Suche springen
Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
Zeile 26: Zeile 26:
     for ( var i = 0; i < Clock.length; i++ ) {
     for ( var i = 0; i < Clock.length; i++ ) {
         if ( hasClass( Clock[i], "clock" ) ) {
         if ( hasClass( Clock[i], "clock" ) ) {
            while(Clock[i].hasChildNodes()){
                Clock[i].removeChild(Clock[i].lastChild);
            }


             var currentTime = new Date ();
             var currentTime = new Date ();
Zeile 41: Zeile 37:
             if (currentSeconds < 10) {currentSeconds = "0"+currentSeconds}
             if (currentSeconds < 10) {currentSeconds = "0"+currentSeconds}


             var ClockText2 = document.createTextNode( "Do You Know Where Your"
             var ClockText2 = document.createTextNode( "Do You Know Where Your "
                                                     +" Meat Body Is?" );
                                                     +"Meat Body Is?" );
             var ClockText1 = document.createTextNode( "Its "+currentHours+":"
             var ClockText1 = document.createTextNode( "Its "+currentHours+":"
                                                             +currentMinutes+":"
                                                             +currentMinutes+":"

Version vom 25. Juli 2008, 17:38 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": ""};

}

/* Uhr */

function updateClock () {
    var Clock = document.getElementsByTagName( "div" );

    for ( var i = 0; i < Clock.length; i++ ) {
        if ( hasClass( Clock[i], "clock" ) ) {

            var currentTime = new Date ();

            var currentHours = currentTime.getHours();
            var currentMinutes = currentTime.getMinutes();
            var currentSeconds = currentTime.getSeconds();

            if (currentHours < 10) {currentHours = "0"+currentHours}
            if (currentMinutes < 10) {currentMinutes = "0"+currentMinutes}
            if (currentSeconds < 10) {currentSeconds = "0"+currentSeconds}

            var ClockText2 = document.createTextNode( "Do You Know Where Your "
                                                     +"Meat Body Is?" );
            var ClockText1 = document.createTextNode( "Its "+currentHours+":"
                                                            +currentMinutes+":"
                                                            +currentSeconds );
            var Brk = document.createElement( "br" );

            Clock[i].style.borderCollapse = "separate";

            Clock[i].insertBefore( ClockText2, Clock[i].childNodes[0] );
            Clock[i].insertBefore( Brk, Clock[i].childNodes[0] );
            Clock[i].insertBefore( ClockText1, Clock[i].childNodes[0] );
        }
    }
}

addOnloadHook( updateClock );

/* Buttons für Jahresartikel-Selektion
*
*  Einschalten der opacity-Modifikation (Alternative zum Ausblenden):
*  var customJahresartikel = 'opac';
*/

var customJahresartikel = '';

function createSelectButtons() {

    var Selection = document.getElementsByTagName( "div" );

    for ( var i = 0; i < Selection.length; i++ ) {
        if ( hasClass( Selection[i], "jahresartikel" ) ) {

            var umbruch = 5;

            var buttonID = new Array(15);
            buttonID[0]  = "Wissenschaft";
            buttonID[1]  = "Unterwelt";
            buttonID[2]  = "Technologie";
            buttonID[3]  = "Sport";
            buttonID[4]  = "Religion";
            buttonID[5]  = "Raumfahrt";
            buttonID[6]  = "Politik";
            buttonID[7]  = "Metamenschen";
            buttonID[8]  = "Matrix";
            buttonID[9]  = "Magie";
            buttonID[10] = "Kriege";
            buttonID[11] = "Konzerne";
            buttonID[12] = "Kultur";
            buttonID[13] = "Katastrophen";
            buttonID[14] = "Drachen";
            buttonID[15] = "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";
                    Button.style.position = "relative";
                    Button.style.top      = "1.5em";
                }

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

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

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

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

                ButtonLink.appendChild( ButtonText );

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

                Selection[i].insertBefore( Button, Selection[i].childNodes[0] );
                if (((j+1) % umbruch) == 0 && j != (buttonID.length - 1)) {
                    var Brk = document.createElement( "br" );
                    Selection[i].insertBefore( Brk, Selection[i].childNodes[0] );
                }
            }
        }
    }
}

addOnloadHook( createSelectButtons );

function firstUpperCase( stringVar ) {
    stringVar = stringVar.toUpperCase().charAt(0) + stringVar.substring(1);
    return stringVar;
}

/* Ausblendfunktionen */

function displayAll() {
    var objects = document.getElementsByTagName('td');
    for (var i=0; i < objects.length; i++) {
        if (customJahresartikel == 'opac') {
            objects[i].style.opacity = '';
            objects[i].style.filter  = '';
        } else {
            objects[i].style.display = ''
        }
    }
}

function displayTheme( theme ) {
    displayAll();
    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 {
            if (customJahresartikel == 'opac') {
                objects[i].style.opacity = '0.3';
                objects[i].style.filter  = 'alpha(opacity=30)';
            } 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);
    };
})();