MediaWiki:Common.js: Unterschied zwischen den Versionen

Aus TerranianStar
Zur Navigation springen Zur Suche springen
Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
Zeile 1: Zeile 1:
/* Das folgende JavaScript wird für alle Benutzer geladen. */
/* Das folgende JavaScript wird für alle Benutzer geladen. */
alert("Common.js wird geladen!");
document.addEventListener('DOMContentLoaded', function () {
 
    const box = document.createElement('div');
    box.textContent = "Testanzeige: Script läuft!";
    box.style.position = "fixed";
    box.style.top = "10px";
    box.style.left = "10px";
    box.style.background = "yellow";
    box.style.color = "black";
    box.style.padding = "10px";
    box.style.border = "2px solid red";
    box.style.zIndex = "99999";
 
    document.body.appendChild(box);
 
    setTimeout(() => {
        box.remove();
    }, 5000);
});
 
/** Namensräume für die Seitenvorschau **/
/** Namensräume für die Seitenvorschau **/
mw.config.set('wgContentNamespaces', [0, 100]);
mw.config.set('wgContentNamespaces', [0, 100]);

Version vom 24. Mai 2026, 14:32 Uhr

/* Das folgende JavaScript wird für alle Benutzer geladen. */
document.addEventListener('DOMContentLoaded', function () {

    const box = document.createElement('div');
    box.textContent = "Testanzeige: Script läuft!";
    box.style.position = "fixed";
    box.style.top = "10px";
    box.style.left = "10px";
    box.style.background = "yellow";
    box.style.color = "black";
    box.style.padding = "10px";
    box.style.border = "2px solid red";
    box.style.zIndex = "99999";

    document.body.appendChild(box);

    setTimeout(() => {
        box.remove();
    }, 5000);
});

/** Namensräume für die Seitenvorschau **/
mw.config.set('wgContentNamespaces', [0, 100]);

//
// Icons für Bearbeiten / Quelltext bearbeiten (Vector‑2022)
//
mw.hook('wikipage.content').add(function($content) {

    $content.find('.mw-editsection a').each(function() {
        var $a = $(this);
        var text = $a.text().trim();

        // Text ausblenden
        $a.css({
            'font-size': '0',
            'display': 'inline-block',
            'width': '22px',
            'height': '22px',
            'background-size': 'contain',
            'background-repeat': 'no-repeat',
            'background-position': 'center',
            'vertical-align': 'middle',
            'margin-left': '4px'
        });

        // Normales Bearbeiten
        if (text === 'Bearbeiten') {
            $a.css('background-image', 'url("/Wiki_BlueX/images/e/e6/EditIcon.png")');
        }

        // Quelltext bearbeiten
        if (text === 'Quelltext bearbeiten') {
            $a.css('background-image', 'url("/Wiki_BlueX/images/f/f6/QEditIcon.png")');
        }
    });

    // Klammern entfernen
    $content.find('.mw-editsection').css('font-size', '0');
});

// TerranianStar – Sidebar-Portale einklappbar machen (MW 1.45.3 + Vector-2022 + JSON Sidebar)
document.addEventListener('DOMContentLoaded', function () {

    // Alle Portale holen
    const portals = document.querySelectorAll('.vector-menu.mw-portlet');

    portals.forEach(portal => {

        const heading = portal.querySelector('.vector-menu-heading');
        const content = portal.querySelector('.vector-menu-content');

        // Sicherheit
        if (!heading || !content) return;

        // Navigation NICHT einklappbar machen
        if (heading.textContent.trim() === 'Navigation') return;

        // Klickbar machen
        heading.style.cursor = 'pointer';

        // Ein/Ausklappen
        heading.addEventListener('click', () => {
            content.classList.toggle('ts-collapsed');
        });
    });
});