Benutzer:Loki/monobook.js

Aus Shadowhelix
Zur Navigation springen Zur Suche springen

Hinweis: Leere nach dem Veröffentlichen den Browser-Cache, um die Änderungen sehen zu können.

  • Firefox/Safari: Umschalttaste drücken und gleichzeitig Aktualisieren anklicken oder entweder Strg+F5 oder Strg+R (⌘+R auf dem Mac) drücken
  • Google Chrome: Umschalttaste+Strg+R (⌘+Umschalttaste+R auf dem Mac) drücken
  • Internet Explorer/Edge: Strg+F5 drücken oder Strg drücken und gleichzeitig Aktualisieren anklicken
  • Opera: Strg+F5
/* 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": ""};

}

/* Buttons für Jahresartikel-Navigation */

function createNavButtons() {

    var Tables = document.getElementsByTagName( "table" );
 
    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;

            HeaderRow.setAttribute( "id", "navigation" );

            var Button1     = document.createElement( "span" );
            var Button1Link = document.createElement( "a" );
            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 Button2Link = document.createElement( "a" );
            var Button2Text = document.createTextNode( "Magie" );
 
            Button2.style.styleFloat = "left";
            Button2.style.cssFloat = "left";
            Button2.style.fontWeight = "normal";
            Button2.style.textAlign = "left";
            Button2.style.width = "6em";
 
            Button2Link.style.color = Header.style.color;
            Button2Link.setAttribute( "id", "MagieButton" );
            Button2Link.setAttribute( "href", "javascript:obj_toggle_magie()" );
            Button2Link.appendChild( Button2Text );
 
            Button2.appendChild( document.createTextNode( "[" ) );
            Button2.appendChild( Button2Link );
            Button2.appendChild( document.createTextNode( "]" ) );
 
            Header.insertBefore( Button2, Header.childNodes[0] );

        }
    }
 
}
 
addOnloadHook( createNavButtons );

/* Ausblendfunktionen */

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

function obj_toggle_magie() {
	obj_toggle();
	var objects = document.getElementsByTagName('tr');
        if (objects[i].getAttribute('id') != 'navigation') {
		for (var i=1; i < objects.length; i++) {
			var keys = String(objects[i].getAttribute('keys'));
			if (keys.search(/magie/) != -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);
    };
})();