Menü aufrufen
Toggle preferences menu
Persönliches Menü aufrufen
Nicht angemeldet
Ihre IP-Adresse wird öffentlich sichtbar sein, wenn Sie Änderungen vornehmen.

MediaWiki:Common.js: Unterschied zwischen den Versionen

MediaWiki-Schnittstellenseite
Keine Bearbeitungszusammenfassung
Markierung: Zurückgesetzt
Keine Bearbeitungszusammenfassung
Markierung: Manuelle Zurücksetzung
Zeile 10: Zeile 10:
});
});


window.addEventListener('load', function() {
$(document).ready(function() {
     function alignGrid() {
     setTimeout(function() {
        // Alle wiki-overview-grids durchgehen
         document.querySelectorAll('.wiki-overview-grid').forEach(function(grid) {
         document.querySelectorAll('.wiki-overview-grid').forEach(function(grid) {
             var cols = Array.from(grid.querySelectorAll('.wiki-overview-col'));
             var cols = grid.querySelectorAll('.wiki-overview-col');
           
            // Erste Überschrift pro Spalte angleichen
            var firstHeaders = [];
            cols.forEach(function(col) {
                var h = col.querySelector('h4');
                if (h) firstHeaders.push(h);
            });
           
            var maxH = 0;
            firstHeaders.forEach(function(h) { if (h.offsetHeight > maxH) maxH = h.offsetHeight; });
            firstHeaders.forEach(function(h) {
                h.style.minHeight = maxH + 'px';
                h.style.display = 'flex';
                h.style.alignItems = 'flex-end';
                h.style.justifyContent = 'center';
            });


             // Reset
             // Zweite Überschrift pro Spalte angleichen
            var secondHeaders = [];
             cols.forEach(function(col) {
             cols.forEach(function(col) {
                 col.querySelectorAll('h4').forEach(function(h) {
                 var hs = col.querySelectorAll('h4');
                    h.style.minHeight = '';
                if (hs[1]) secondHeaders.push(hs[1]);
                    h.style.marginTop = '';
                });
             });
             });


            // Erste Überschriften angleichen
             if (secondHeaders.length > 1) {
            var firstHeaders = cols.map(function(col) { return col.querySelector('h4'); }).filter(Boolean);
                 var maxH2 = 0;
             if (firstHeaders.length) {
                secondHeaders.forEach(function(h) { if (h.offsetHeight > maxH2) maxH2 = h.offsetHeight; });
                 var maxH1 = Math.max.apply(null, firstHeaders.map(function(h) { return h.offsetHeight; }));
                 secondHeaders.forEach(function(h) {
                 firstHeaders.forEach(function(h) {
                     h.style.minHeight = maxH2 + 'px';
                     h.style.minHeight = maxH1 + 'px';
                     h.style.display = 'flex';
                     h.style.display = 'flex';
                     h.style.alignItems = 'flex-end';
                     h.style.alignItems = 'flex-end';
Zeile 34: Zeile 49:
                 });
                 });
             }
             }
            // Erste Galerie pro Spalte messen
            var maxGalleryH = 0;
            cols.forEach(function(col) {
                var firstWrapper = col.querySelector('.ext-gallery-wrapper');
                if (firstWrapper && firstWrapper.offsetHeight > maxGalleryH) {
                    maxGalleryH = firstWrapper.offsetHeight;
                }
            });
            // Zweite Überschriften angleichen
            cols.forEach(function(col) {
                var hs = col.querySelectorAll('h4');
                if (!hs[1]) return;
                var firstWrapper = col.querySelector('.ext-gallery-wrapper');
                var thisH = firstWrapper ? firstWrapper.offsetHeight : 0;
                var diff = maxGalleryH - thisH;
                if (diff > 0) hs[1].style.marginTop = diff + 'px';
                hs[1].style.display = 'flex';
                hs[1].style.alignItems = 'flex-end';
                hs[1].style.justifyContent = 'center';
            });
         });
         });
     }
     }, 300);
 
    // Auf alle Bilder warten
    var images = document.querySelectorAll('.wiki-overview-grid img');
    var loaded = 0;
    if (images.length === 0) { alignGrid(); return; }
    images.forEach(function(img) {
        if (img.complete) {
            loaded++;
            if (loaded === images.length) alignGrid();
        } else {
            img.addEventListener('load', function() {
                loaded++;
                if (loaded === images.length) alignGrid();
            });
            img.addEventListener('error', function() {
                loaded++;
                if (loaded === images.length) alignGrid();
            });
        }
    });
});
});



Version vom 27. Juli 2026, 16:22 Uhr

mw.hook('wikipage.content').add(function($content) {
    const headings = document.querySelectorAll('.citizen-section-heading');
    if (headings.length === 0) return;
    
    const sections = document.querySelectorAll('.citizen-section');
    sections.forEach(function(section, index) {
        if (index === 0) return; // Einleitungstext überspringen
        section.hidden = 'until-found';
    });
});

$(document).ready(function() {
    setTimeout(function() {
        // Alle wiki-overview-grids durchgehen
        document.querySelectorAll('.wiki-overview-grid').forEach(function(grid) {
            var cols = grid.querySelectorAll('.wiki-overview-col');
            
            // Erste Überschrift pro Spalte angleichen
            var firstHeaders = [];
            cols.forEach(function(col) {
                var h = col.querySelector('h4');
                if (h) firstHeaders.push(h);
            });
            
            var maxH = 0;
            firstHeaders.forEach(function(h) { if (h.offsetHeight > maxH) maxH = h.offsetHeight; });
            firstHeaders.forEach(function(h) {
                h.style.minHeight = maxH + 'px';
                h.style.display = 'flex';
                h.style.alignItems = 'flex-end';
                h.style.justifyContent = 'center';
            });

            // Zweite Überschrift pro Spalte angleichen
            var secondHeaders = [];
            cols.forEach(function(col) {
                var hs = col.querySelectorAll('h4');
                if (hs[1]) secondHeaders.push(hs[1]);
            });

            if (secondHeaders.length > 1) {
                var maxH2 = 0;
                secondHeaders.forEach(function(h) { if (h.offsetHeight > maxH2) maxH2 = h.offsetHeight; });
                secondHeaders.forEach(function(h) {
                    h.style.minHeight = maxH2 + 'px';
                    h.style.display = 'flex';
                    h.style.alignItems = 'flex-end';
                    h.style.justifyContent = 'center';
                });
            }
        });
    }, 300);
});

// Ausklappen des ersten Abschnitts bei fehlendem Einleitungstext
$(document).ready(function() {
    setTimeout(function() {
        var content = document.querySelector('.mw-parser-output');
        if (!content) return;

        var children = Array.from(content.children);

        // Prüfen ob die erste Section Text enthält (= Einleitungstext)
        var firstSection = children.find(function(el) {
            return el.classList.contains('citizen-section');
        });

        if (firstSection && firstSection.textContent.trim() !== '') return;

        // Erste H2 aufklappen
        var firstH2 = children.find(function(el) {
            return el.tagName === 'H2' && el.classList.contains('citizen-section-heading');
        });

        if (firstH2) {
            var indicator = firstH2.querySelector('.citizen-section-indicator');
            if (indicator) indicator.click();
        }
    }, 500);
});

// Social Icons in Sidebar ersetzen
$(function() {
    $('#n-sidebar-label-contactus').closest('ul').addClass('sgpggb-external-menu');

    var icons = {
        'n-Discord':    'fab fa-discord',
        'n-Facebook':   'fab fa-facebook-f',
        'n-Instagram':  'fab fa-instagram',
        'n-X':          'fab fa-x-twitter',
        'n-YouTube':    'fab fa-youtube',
        'n-Twitch':     'fab fa-twitch',
        'n-E-Mail':     'fas fa-envelope',
        'n-Support-us': 'fas fa-heart'
    };

    $.each(icons, function(id, cls) {
        $('#' + id + ' a').html('<i class="' + cls + '"></i>');
    });
});

var tagline = document.getElementById('footer-tagline');
if (tagline) {
    var original = tagline.innerHTML;
    var shown = localStorage.getItem('footer_gender_dismissed');

    if (!shown) {
        tagline.innerHTML = 'Aus Gründen der besseren Lesbarkeit wird auf diesem Wiki überwiegend das generische Maskulinum verwendet. Es sind stets alle Geschlechter gleichermaßen gemeint. <button id="footer-gender-dismiss" style="background:none; border:none; cursor:pointer; font-size:0.9em; opacity:0.6; padding:0 4px;" title="Verstanden">✕</button>';

        document.getElementById('footer-gender-dismiss').addEventListener('click', function() {
            tagline.innerHTML = original;
            localStorage.setItem('footer_gender_dismissed', '1');
        });
    }
}

// mw-anon Klasse für nicht angemeldete User setzen
if ( !mw.config.get('wgUserId') ) {
    document.documentElement.classList.add('mw-anon');
}