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

Aus Shadowhelix
Zur Navigation springen Zur Suche springen
Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
 
(547 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": "",
        "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": "",
         "tagClose": "",
         "sampleText": ""};
         "sampleText": ""};
Zeile 19: Zeile 82:
}
}


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


function createNavButtons() {
function testButton() {


     var Tables = document.getElementsByTagName( "table" );
     var Selection = document.getElementsByClassName( "jsFunctionButton" );
    for ( var i = 0; i < Tables.length; i++ ) {
        if ( hasClass( Tables[i], "jahresartikel" ) ) {
            /* only add button and increment count if there is a header row to work with */
            var HeaderRow = Tables[i].getElementsByTagName( "tr" )[0];
            if (!HeaderRow) continue;
            var Header = HeaderRow.getElementsByTagName( "th" )[0];
            if (!Header) continue;


            Header.setAttribute( "id", "jahresartikel" );
    for ( var i = Selection.length - 1; i >= 0 ; i-- ) {


            var Button1    = document.createElement( "span" );
        var input = Selection[i].id.split("_");
            var Button1Link = document.createElement( "a" );
        var jsFunction = input.shift();
            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 = Header.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( "]" ) );
            Header.insertBefore( Button1, Header.childNodes[0] );


            var Button2    = document.createElement( "span" );
        var Button = document.createElement( "a" );
            var Button2Link = document.createElement( "a" );
 
            var Button2Text = document.createTextNode( "Magie" );
        var inputString = "";
        for ( var j = 0; j < input.length; j++ ) {
            Button2.style.styleFloat = "left";
              inputString = inputString + "'"+input[j];
            Button2.style.cssFloat = "left";
              if (j != input.length - 1) {
            Button2.style.fontWeight = "normal";
                  inputString = inputString + "',";
            Button2.style.textAlign = "left";
              } else {
            Button2.style.width = "6em";
                  inputString = inputString + "'";
              }
            Button2Link.style.color = Header.style.color;
        }
            Button2Link.setAttribute( "id", "MagieButton" );
 
            Button2Link.setAttribute( "href", "javascript:obj_toggle_magie()" );
        Button.setAttribute( "href", "javascript:"+jsFunction+"("+inputString+")" );
            Button2Link.appendChild( Button2Text );
 
//      Button.style.color = Selection[i].style.color;
            Button2.appendChild( document.createTextNode( "[" ) );
//      Button.style.fontSize = Selection[i].style.fontSize;
            Button2.appendChild( Button2Link );
 
            Button2.appendChild( document.createTextNode( "]" ) );
        Button.appendChild( Selection[i].childNodes[0] );
 
            Header.insertBefore( Button2, Header.childNodes[0] );
        $(Selection[i]).replaceWith( Button );


        }
     }
     }
 
}
}
addOnloadHook( createNavButtons );


/* Ausblendfunktionen */
function toggleVisibility( targetClass, targetID ) {


function obj_toggle() {
    var objects = document.getElementsByClassName( targetClass );
var objects = document.getElementsByTagName('tr');
for (var i=1; i < objects.length; i++) {
objects[i].style.display = ''
}
}


function obj_toggle_nav() {
    for ( var i = 0; i < objects.length; i++ ) {   
var objects = document.getElementById('jahresartikel');
alert('Test');
objects[0].style.display = '';
}


function obj_toggle_magie() {
        if (objects[i].id != targetID) {
obj_toggle();
                objects[i].style.display = 'none';
var objects = document.getElementsByTagName('tr');
        } else {
for (var i=1; i < objects.length; i++) {
                objects[i].style.display = '';
var keys = String(objects[i].getAttribute('keys'));
        }
if (keys.search(/magie/) != -1) {}
    }
else {objects[i].style.display = 'none'}
}
obj_toggle_nav();
}
}


/* 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 );