User:Euphoria/common.js: Difference between revisions

From Test Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 2: Line 2:
mw.loader.using(['mediawiki.util'])
mw.loader.using(['mediawiki.util'])
     .then(function () {
     .then(function () {
         // Add a link to the 'p-cactions' portlet pointing to CentralAuth
         // Check if the current page is associated with the user
         var sulLink = mw.util.addPortletLink(
        var isUserRelatedPage = mw.config.get('wgCanonicalSpecialPageName') === 'CentralAuth' ||
            'p-cactions',
                                mw.config.get('wgCanonicalSpecialPageName') === 'Log' ||
            mw.util.getUrl('Special:CentralAuth/' + mw.user.getName()),
                                mw.config.get('wgCanonicalSpecialPageName') === 'Contributions' ||
            'SUL',
                                mw.config.get('wgNamespaceNumber') === 2 || // User namespace
            'ca-sul',
                                mw.config.get('wgNamespaceNumber') === 3;  // User talk namespace
            'SUL',
 
            null,
        // If the current page is associated with the user, add the "SUL" link
            '#ca-sul'
         if (isUserRelatedPage) {
        );
            var sulLink = mw.util.addPortletLink(
                'p-cactions',
                mw.util.getUrl('Special:CentralAuth/' + mw.user.getName()),
                'SUL',
                'ca-sul',
                'SUL',
                null,
                '#ca-sul'
            );
        }
     });
     });

Revision as of 06:58, 10 November 2023

// Load necessary module asynchronously
mw.loader.using(['mediawiki.util'])
    .then(function () {
        // Check if the current page is associated with the user
        var isUserRelatedPage = mw.config.get('wgCanonicalSpecialPageName') === 'CentralAuth' ||
                                mw.config.get('wgCanonicalSpecialPageName') === 'Log' ||
                                mw.config.get('wgCanonicalSpecialPageName') === 'Contributions' ||
                                mw.config.get('wgNamespaceNumber') === 2 || // User namespace
                                mw.config.get('wgNamespaceNumber') === 3;  // User talk namespace

        // If the current page is associated with the user, add the "SUL" link
        if (isUserRelatedPage) {
            var sulLink = mw.util.addPortletLink(
                'p-cactions',
                mw.util.getUrl('Special:CentralAuth/' + mw.user.getName()),
                'SUL',
                'ca-sul',
                'SUL',
                null,
                '#ca-sul'
            );
        }
    });