MediaWiki:Common.js: Difference between revisions

No edit summary
No edit summary
Line 903: Line 903:
     wrap.appendChild( makeItem( '/My_wiki:About', 'About' ) );
     wrap.appendChild( makeItem( '/My_wiki:About', 'About' ) );
     var userName = window.mw ? mw.config.get( 'wgUserName' ) : null;
     var userName = window.mw ? mw.config.get( 'wgUserName' ) : null;
     if ( userName ) { var la = document.querySelector( 'a[href*="action=logout"]' ); wrap.appendChild( makeItem( la ? la.href : '/index.php?title=Special:UserLogout', 'Log out' ) ); }
     if ( userName ) {
      wrap.appendChild( makeItem( ( window.mw && mw.util && mw.util.getUrl ) ? mw.util.getUrl( 'Special:Profile' ) : '/Special:Profile', 'Profile' ) );
      var la = document.querySelector( 'a[href*="action=logout"]' );
      wrap.appendChild( makeItem( la ? la.href : '/index.php?title=Special:UserLogout', 'Log out' ) );
    }
     else wrap.appendChild( makeItem( '/index.php?title=Special:UserLogin', 'Log in' ) );
     else wrap.appendChild( makeItem( '/index.php?title=Special:UserLogin', 'Log in' ) );
     var pageLeft = document.getElementById( 'mw-mf-page-left' );
     var pageLeft = document.getElementById( 'mw-mf-page-left' );
Line 1,024: Line 1,028:
     // Logged-out: show a single Login/Signup link, nothing else
     // Logged-out: show a single Login/Signup link, nothing else
     if ( isAnon ) {
     if ( isAnon ) {
        // Remove MediaWiki's native account links so only our button shows
        [ '#pt-createaccount', '#pt-login', '#pt-anoncontribs',
          '#pt-anontalk', '#pt-anonuserpage' ].forEach( function ( sel ) {
            document.querySelectorAll( sel ).forEach( function ( el ) {
                if ( el && el.parentNode ) el.parentNode.removeChild( el );
            } );
        } );
         if ( document.getElementById( 'gr-login-link' ) ) return;
         if ( document.getElementById( 'gr-login-link' ) ) return;
         var loginA = document.createElement( 'a' );
         var loginA = document.createElement( 'a' );