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

Aus Shadowhelix
Zur Navigation springen Zur Suche springen
(Quellcoe-Update...)
Keine Bearbeitungszusammenfassung
Zeile 19: Zeile 19:
}
}


/* Buttons für Jahresartikel-Navigation */
/* Uhr */


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


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


    for ( var i = 0; i < Navigation.length; i++ ) {
            while(Clock[i].hasChildNodes()){
        if ( hasClass( Navigation[i], "jahresartikel" ) ) {
                Clock[i].removeChild(Clock[i].lastChild);
            }
 
            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].insertBefore( ClockText2, Clock[i].childNodes[0] );
            Clock[i].insertBefore( Brk, Clock[i].childNodes[0] );
            Clock[i].insertBefore( ClockText1, Clock[i].childNodes[0] );
           
            Clock[i].style.lineHeight = "1.5em";
 
            setTimeout('updateClock();',1000);
        }
    }
}


            var ButtonID = new Array(11);
addOnloadHook( updateClock );
            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++ ) {
/* 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" );
                 var Button = document.createElement( "span" );


Zeile 50: Zeile 105:
                 Button.style.width = "12em";
                 Button.style.width = "12em";


                 if (j == (ButtonID.length - 1)) {
                 if (j == (buttonID.length - 1)) {
                     Button.style.styleFloat = "right";
                     Button.style.styleFloat = "right";
                     Button.style.cssFloat = "right";
                     Button.style.cssFloat = "right";
                    Button.style.position = "relative";
                    Button.style.top      = "1.5em";
                 }
                 }


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


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


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


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


Zeile 75: Zeile 132:
                 Button.appendChild( document.createTextNode( "]" ) );
                 Button.appendChild( document.createTextNode( "]" ) );


                 Navigation[i].insertBefore( Button, Navigation[i].childNodes[0] );
                 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] );
                }
             }
             }
         }
         }
Zeile 81: Zeile 142:
}
}


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


/* Ausblendfunktionen */
/* Ausblendfunktionen */


function obj_toggle() {
function displayAll() {
     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 = ''
         if (customJahresartikel == 'opac') {
            objects[i].style.opacity = '';
            objects[i].style.filter  = '';
        } else {
            objects[i].style.display = ''
        }
     }
     }
}
}


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

Version vom 25. Juli 2008, 20:02 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" ) ) {

            while(Clock[i].hasChildNodes()){
                Clock[i].removeChild(Clock[i].lastChild);
            }

            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].insertBefore( ClockText2, Clock[i].childNodes[0] );
            Clock[i].insertBefore( Brk, Clock[i].childNodes[0] );
            Clock[i].insertBefore( ClockText1, Clock[i].childNodes[0] );
            
            Clock[i].style.lineHeight = "1.5em";

            setTimeout('updateClock();',1000);
        }
    }
}

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