Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

MediaWiki:Common.js

MediaWiki interface page
Revision as of 13:07, 30 March 2025 by Veza (talk | contribs)

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */

// Discord link
$(document).ready(function() {
    // Create the Discord link with responsive image and specific URL
    var discordLink = $('<div id="discord-link-below-logo"><a href="https://discord.com/invite/gscripts"><img src="/w/images/thumb/d/dd/Discord.png/100px-Discord.png" srcset="/w/images/thumb/d/dd/Discord.png/150px-Discord.png 1.5x, /w/images/thumb/d/dd/Discord.png/200px-Discord.png 2x" alt="Discord" width="100" height="100"></a></div>');
    
    // Insert it after the logo container
    $('.vector-header-start').append(discordLink);
});


$(document).ready(function() {
    var $sections = $('.accordion-section');

    // Initialize: disable links in all headers by default (since all start collapsed)
    $sections.find('.accordion-header a').css('pointer-events', 'none');

    // Handle header clicks
    $('.accordion-header').on('click', function(e) {
        var $section = $(this).closest('.accordion-section');
        var $content = $section.find('.accordion-content');
        var isHidden = $content.is(':hidden');

        if (isHidden) {
            // Collapse all other sections
            $sections.not($section).find('.accordion-content').slideUp(200);
            $sections.not($section).removeClass('expanded');
            $sections.not($section).find('.accordion-header a').css('pointer-events', 'none');

            // Expand this section
            $content.slideDown(200);
            $section.addClass('expanded');
            $section.find('.accordion-header a').css('pointer-events', 'auto');
        } else {
            // Collapse this section
            $content.slideUp(200);
            $section.removeClass('expanded');
            $section.find('.accordion-header a').css('pointer-events', 'none');
        }

        // Prevent link click if content is hidden
        if (e.target.tagName === 'A' && $content.is(':hidden')) {
            e.preventDefault();
        }
    });
});