MediaWiki:Common.js: Difference between revisions

No edit summary
Tag: Reverted
No edit summary
Tag: Reverted
Line 53: Line 53:


if ( mw.config.get( 'wgPageName' ) === 'Discord' ) {
if ( mw.config.get( 'wgPageName' ) === 'Discord' ) {
    // Make the "Discord" tab active
$(document).ready(function() {
    $('#ca-my_namespace').addClass('selected');  // Highlight the Discord tab
    // Get the current page title
 
    var currentPage = mw.config.get('wgTitle');
    // Make the "Page" tab (ca-nstab-main) clickable and go back to the previous page
    var previousPage = document.referrer; // Get the URL of the previous page
    $('#ca-nstab-main').show().find('a').attr('href', previousPage).text('Go Back');  // Update link to go to previous page
} else {
    // Check if the current page is 'Discord'
    // If not on the Discord page, reset the link and remove the active class
    if (currentPage === 'Discord') {
    $('#ca-my_namespace').removeClass('selected');  // Remove the "selected" class from Discord tab
        // Make the "Discord" tab active (remove 'selected' from ca-nstab-main and add it to ca-my_namespace)
    $('#ca-nstab-main').show().find('a').attr('href', '/wiki/Main_Page').text('Main');  // Reset link back to the main page
        $('#ca-nstab-main').removeClass('selected');  // Remove 'selected' from "Page" tab
        $('#ca-my_namespace').addClass('selected');  // Add 'selected' to the "Discord" tab
        // Make the "Page" tab (ca-nstab-main) link to the previous page (i.e., 'Go Back')
        $('#ca-nstab-main').show().find('a').attr('href', previousPage).text('Go Back');  // Update link to go to the previous page
    } else {
        // If not on the Discord page, reset the "Page" tab link back to Main Page
        $('#ca-my_namespace').removeClass('selected');  // Remove 'selected' from "Discord" tab
        $('#ca-nstab-main').show().find('a').attr('href', '/wiki/Main_Page').text('Main');  // Reset link to the Main page
    }
});
}
}