MediaWiki:Common.js: Unterschied zwischen den Versionen

Keine Bearbeitungszusammenfassung
Markierung: Zurückgesetzt
Keine Bearbeitungszusammenfassung
Markierung: Zurückgesetzt
Zeile 163: Zeile 163:


// Template LoginStatus: conditional text depending on login status
// Template LoginStatus: conditional text depending on login status
// v250921r1
// v250921r2


// Show/hide conditional content
$(function() {
$(function() {
    // First show/hide content
     if (mw.user.isAnon()) {
     if (mw.user.isAnon()) {
         $('.logged-out-only').show();
         $('.logged-out-only').show();
        $('.logged-in-only').hide(); // Explicitly hide
     } else {
     } else {
         $('.logged-in-only').show();
         $('.logged-in-only').show();
        $('.logged-out-only').hide(); // Explicitly hide
     }
     }
});
   
 
    // Then clean TOC - with debugging
// Clean up TOC entries for hidden sections
     $('.logged-out-only:hidden, .logged-in-only:hidden').each(function() {
$(function() {
         $(this).find('h1, h2, h3, h4, h5, h6').each(function() {
     $('.logged-out-only, .logged-in-only').each(function() {
            var headingId = this.id;
         var $section = $(this);
            console.log('Found hidden heading:', headingId); // Debug
        var isHidden = $section.css('display') === 'none';
           
       
            if (headingId) {
        if (isHidden) {
                // Try multiple selectors
            // Find all headings in hidden section
                $('#toc a[href="#' + headingId + '"]').closest('li').hide();
            $section.find('h1, h2, h3, h4, h5, h6').each(function() {
                $('.toc a[href="#' + headingId + '"]').closest('li').hide();
                var headingId = this.id;
                 $('a[href="#' + $.escapeSelector(headingId) + '"]').closest('li').hide();
                if (headingId) {
             }
                    // Hide corresponding TOC entry
         });
                    $('.toc a[href="#' + headingId + '"]').closest('li').hide();
                 }
             });
         }
     });
     });
});
});