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

Aus Shadowhelix
Zur Navigation springen Zur Suche springen
Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
 
(416 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
/* Skriptimport */
customHighlightFarbe = 'lightgrey';
importScript('Benutzer:Loki/universalimpressumOverviewHighlight.js');
importScript('Benutzer:Loki/shadowtalkDisplay.js');
importScript('Benutzer:Loki/refDisplay.js');
importScript('Benutzer:Loki/vorlageUhr.js');
importScript('Benutzer:Loki/vorlageButton.js');
function testFunktionen () {
    addPortletLink('p-cactions', 'javascript:alert(document.location.href)', 'URL', 'ca-last', 'url');
    addPortletLink('p-cactions', 'javascript:alert(document.location.href.length)', 'URL-Laenge', 'ca-last', 'url laenge');
}
// addOnloadHook( testFunktionen );
// ----------------------------------------------------------
// ----------------------------------------------------------
/* Ergänzung der Editierzeile mit zusätzlichen Buttons */
/* Ergänzung der Editierzeile mit zusätzlichen Buttons */


Zeile 13: Zeile 34:
         "imageFile": "http://shadowhelix.de/images/b/b0/Button_trash.png",
         "imageFile": "http://shadowhelix.de/images/b/b0/Button_trash.png",
         "speedTip": "Löschantrag",
         "speedTip": "Löschantrag",
         "tagOpen": "{{Löschantrag|}}",
         "tagOpen": "\{\{Löschantrag||}}",
         "tagClose": "",
         "tagClose": "",
         "sampleText": ""};
         "sampleText": ""};


}
    mwCustomEditButtons[mwCustomEditButtons.length] = {
        "imageFile": "http://shadowhelix.de/images/3/3e/Button_STD.png",
        "speedTip": "Standardartikel",
        "tagOpen": '\{\{stub}}\n\{\{+quelle}}\n\'\'\'\'\'\'\n<ref></ref>\n<ref group=\"E\"></ref>\n<ref group=\"W\"></ref>\n\n<!-- Ende des Artikelinhalts - Metainformationen -->\n\n==Erläuterungen==\n<references group=\"E\"/>\n\n==Widersprüche==\n<references group=\"W\"/>\n\n==Quellenindex==\n\{\{IdxTab\n|\n*\{\{Qde|}} \{\{+idx}}\n|\n*\{\{Qen|}} \{\{+idx}}\n}}\n\n==Quellenangabe==\n<references/>\n\n==Weblinks==\n*[[wp:|Wikipedia: ]]\n\n{{DEFAULTSORT:}}\n\{\{KatSchema|schema=}}\n\{\{KatSort|cat=|}}\n[[Kategorie:]]',
        "tagClose": "",
        "sampleText": ""};


/* Uhr */
    mwCustomEditButtons[mwCustomEditButtons.length] = {
        "imageFile": "http://shadowhelix.de/images/b/ba/Button_Stub.png",
        "speedTip": "Stubartikel",
        "tagOpen": '\{\{stub}}\n\'\'\'\'\'\'\n\n<!-- Ende des Artikelinhalts - Metainformationen -->\n\n==Quellenindex==\n*\{\{Qde|}} \{\{+idx}}\n*\{\{Qen|}} \{\{+idx}}\n\n==Weblinks==\n*[[wp:|Wikipedia: ]]\n\n\{\{DEFAULTSORT:}}\n\{\{KatSchema|schema=}}\n\{\{KatSort|cat=|}}\n[[Kategorie:]]',
        "tagClose": "",
        "sampleText": ""};


function updateClock () {
    mwCustomEditButtons[mwCustomEditButtons.length] = {
    var Clock = document.getElementsByTagName( "div" );
        "imageFile": "http://shadowhelix.de/images/8/84/Button_Redirect.png",
        "speedTip": "Weiterleitung",
        "tagOpen": '#WEITERLEITUNG [[',
        "tagClose": "]]",
        "sampleText": ""};


     for ( var i = 0; i < Clock.length; i++ ) {
     mwCustomEditButtons[mwCustomEditButtons.length] = {
         if ( hasClass( Clock[i], "clock" ) ) {
         "imageFile": "http://shadowhelix.de/images/9/9d/Button_Person.png",
        "speedTip": "Vorlage:Person",
        "tagOpen": '\{\{Person\n|GESCHLECHT=\n|METATYP=\n|MAGISCH=\n}}',
        "tagClose": "",
        "sampleText": ""};


            while(Clock[i].hasChildNodes()){
    mwCustomEditButtons[mwCustomEditButtons.length] = {
                Clock[i].removeChild(Clock[i].lastChild);
        "imageFile": "http://shadowhelix.de/images/8/8e/Button_Stadt.png",
            }
        "speedTip": "Vorlage:Stadt",
        "tagOpen": '\{\{Stadt\n|STAND=?\n|STATUS=\n|KOORD_DISPLAY=1\n|KOORD_LAENGE=\n|KOORD_BREITE=\n|KOORD_KBS=1\n|KOORD_ZGM=\n|POSITIONSKARTE=\n|POS_LABEL=\n}} \{\{KoordTransform|}}',
        "tagClose": "",
        "sampleText": ""};


            var currentTime = new Date ();
    mwCustomEditButtons[mwCustomEditButtons.length] = {
 
        "imageFile": "http://shadowhelix.de/images/a/a1/Button_adhoc.png",
            var currentHours = currentTime.getHours();
        "speedTip": "adhoc",
            var currentMinutes = currentTime.getMinutes();
        "tagOpen": '\| align=\"center\" style=\"height:120px; background-color:white;\" \| \[\[\|80px\]\]',
            var currentSeconds = currentTime.getSeconds();
        "tagClose": "",
        "sampleText": ""};


            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
function testButton() {
*
*  Einschalten der opacity-Modifikation (Alternative zum Ausblenden):
*  var customJahresartikel = 'opac';
*/


var customJahresartikel = '';
    var Selection = document.getElementsByClassName( "jsFunctionButton" );


function createSelectButtons() {
    for ( var i = Selection.length - 1; i >= 0 ; i-- ) {


    var Selection = document.getElementsByTagName( "div" );
        var input = Selection[i].id.split("_");
        var jsFunction = input.shift();


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


            var umbruch = 5;
        var inputString = "";
        for ( var j = 0; j < input.length; j++ ) {
              inputString = inputString + "'"+input[j];
              if (j != input.length - 1) {
                  inputString = inputString + "',";
              } else {
                  inputString = inputString + "'";
              }
        }


            var buttonID = new Array(15);
        Button.setAttribute( "href", "javascript:"+jsFunction+"("+inputString+")" );
            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++ ) {
//      Button.style.color = Selection[i].style.color;
                var Button = document.createElement( "span" );
//      Button.style.fontSize = Selection[i].style.fontSize;


                Button.style.styleFloat = "left";
        Button.appendChild( Selection[i].childNodes[0] );
                Button.style.cssFloat = "left";
                Button.style.fontWeight = "normal";
                Button.style.textAlign = "center";
                Button.style.width = "12em";


                if (j == (buttonID.length - 1)) {
        $(Selection[i]).replaceWith( Button );
                    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 toggleVisibility( targetClass, targetID ) {


function firstUpperCase( stringVar ) {
     var objects = document.getElementsByClassName( targetClass );
     stringVar = stringVar.toUpperCase().charAt(0) + stringVar.substring(1);
    return stringVar;
}


/* Ausblendfunktionen */
    for ( var i = 0; i < objects.length; i++ ) {   


function displayAll() {
         if (objects[i].id != targetID) {
    var objects = document.getElementsByTagName('td');
                objects[i].style.display = 'none';
    for (var i=0; i < objects.length; i++) {
         if (customJahresartikel == 'opac') {
            objects[i].style.opacity = '';
            objects[i].style.filter  = '';
         } else {
         } else {
            objects[i].style.display = ''
                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
// addOnloadHook( testButton );
*
* 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);
    };
})();

Aktuelle Version vom 19. April 2017, 18:55 Uhr

/* Skriptimport */

customHighlightFarbe = 'lightgrey';

importScript('Benutzer:Loki/universalimpressumOverviewHighlight.js');
importScript('Benutzer:Loki/shadowtalkDisplay.js');
importScript('Benutzer:Loki/refDisplay.js');
importScript('Benutzer:Loki/vorlageUhr.js');
importScript('Benutzer:Loki/vorlageButton.js');

function testFunktionen () {
    addPortletLink('p-cactions', 'javascript:alert(document.location.href)', 'URL', 'ca-last', 'url');
    addPortletLink('p-cactions', 'javascript:alert(document.location.href.length)', 'URL-Laenge', 'ca-last', 'url laenge');
}

// addOnloadHook( testFunktionen );

// ----------------------------------------------------------

// ----------------------------------------------------------

/* 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": ""};

    mwCustomEditButtons[mwCustomEditButtons.length] = {
        "imageFile": "http://shadowhelix.de/images/3/3e/Button_STD.png",
        "speedTip": "Standardartikel",
        "tagOpen": '\{\{stub}}\n\{\{+quelle}}\n\'\'\'\'\'\'\n<ref></ref>\n<ref group=\"E\"></ref>\n<ref group=\"W\"></ref>\n\n<!-- Ende des Artikelinhalts - Metainformationen -->\n\n==Erläuterungen==\n<references group=\"E\"/>\n\n==Widersprüche==\n<references group=\"W\"/>\n\n==Quellenindex==\n\{\{IdxTab\n|\n*\{\{Qde|}} \{\{+idx}}\n|\n*\{\{Qen|}} \{\{+idx}}\n}}\n\n==Quellenangabe==\n<references/>\n\n==Weblinks==\n*[[wp:|Wikipedia: ]]\n\n{{DEFAULTSORT:}}\n\{\{KatSchema|schema=}}\n\{\{KatSort|cat=|}}\n[[Kategorie:]]',
        "tagClose": "",
        "sampleText": ""};

    mwCustomEditButtons[mwCustomEditButtons.length] = {
        "imageFile": "http://shadowhelix.de/images/b/ba/Button_Stub.png",
        "speedTip": "Stubartikel",
        "tagOpen": '\{\{stub}}\n\'\'\'\'\'\'\n\n<!-- Ende des Artikelinhalts - Metainformationen -->\n\n==Quellenindex==\n*\{\{Qde|}} \{\{+idx}}\n*\{\{Qen|}} \{\{+idx}}\n\n==Weblinks==\n*[[wp:|Wikipedia: ]]\n\n\{\{DEFAULTSORT:}}\n\{\{KatSchema|schema=}}\n\{\{KatSort|cat=|}}\n[[Kategorie:]]',
        "tagClose": "",
        "sampleText": ""};

    mwCustomEditButtons[mwCustomEditButtons.length] = {
        "imageFile": "http://shadowhelix.de/images/8/84/Button_Redirect.png",
        "speedTip": "Weiterleitung",
        "tagOpen": '#WEITERLEITUNG [[',
        "tagClose": "]]",
        "sampleText": ""};

    mwCustomEditButtons[mwCustomEditButtons.length] = {
        "imageFile": "http://shadowhelix.de/images/9/9d/Button_Person.png",
        "speedTip": "Vorlage:Person",
        "tagOpen": '\{\{Person\n|GESCHLECHT=\n|METATYP=\n|MAGISCH=\n}}',
        "tagClose": "",
        "sampleText": ""};

    mwCustomEditButtons[mwCustomEditButtons.length] = {
        "imageFile": "http://shadowhelix.de/images/8/8e/Button_Stadt.png",
        "speedTip": "Vorlage:Stadt",
        "tagOpen": '\{\{Stadt\n|STAND=?\n|STATUS=\n|KOORD_DISPLAY=1\n|KOORD_LAENGE=\n|KOORD_BREITE=\n|KOORD_KBS=1\n|KOORD_ZGM=\n|POSITIONSKARTE=\n|POS_LABEL=\n}} \{\{KoordTransform|}}',
        "tagClose": "",
        "sampleText": ""};

    mwCustomEditButtons[mwCustomEditButtons.length] = {
        "imageFile": "http://shadowhelix.de/images/a/a1/Button_adhoc.png",
        "speedTip": "adhoc",
        "tagOpen": '\| align=\"center\" style=\"height:120px; background-color:white;\" \| \[\[\|80px\]\]',
        "tagClose": "",
        "sampleText": ""};

}

/***********************************************************************/

function testButton() {

    var Selection = document.getElementsByClassName( "jsFunctionButton" );

    for ( var i = Selection.length - 1; i >= 0 ; i-- ) {

         var input = Selection[i].id.split("_");
         var jsFunction = input.shift();

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

         var inputString = "";
         for ( var j = 0; j < input.length; j++ ) {
              inputString = inputString + "'"+input[j];
              if (j != input.length - 1) {
                   inputString = inputString + "',";
              } else {
                   inputString = inputString + "'";
              }
         }

         Button.setAttribute( "href", "javascript:"+jsFunction+"("+inputString+")" );

//       Button.style.color = Selection[i].style.color;
//       Button.style.fontSize = Selection[i].style.fontSize;

         Button.appendChild( Selection[i].childNodes[0] );

         $(Selection[i]).replaceWith( Button );

    }

}

function toggleVisibility( targetClass, targetID ) {

    var objects = document.getElementsByClassName( targetClass );

    for ( var i = 0; i < objects.length; i++ ) {     

        if (objects[i].id != targetID) {
                objects[i].style.display = 'none';
        } else {
                objects[i].style.display = '';
        }
    }
}

// addOnloadHook( testButton );