MediaWiki:Common.js

From GladiusRO Wiki
Revision as of 02:25, 2 August 2026 by Ikhwan (talk | contribs)
Jump to navigation Jump to search

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.
mw.loader.using(['mediawiki.util']).then(function () {
    function moveTOCToSidebar() {
        var toc = document.querySelector('#toc');

        if (!toc || document.querySelector('#gladius-sidebar-toc')) {
            return;
        }

        /*
         * Supports common MediaWiki sidebar containers:
         * #mw-panel       = Vector legacy
         * #mw-navigation  = some custom skins
         * .sidebar        = generic/custom skins
         */
        var sidebar =
*           document.querySelector(*#mw-panel') ||
            document.querySelector('#mw-navigation') ||
            document.querySelector('.sidebar');

        if (!sidebar) {
            return;
        }

        var tocContainer = document.createElement('div');

        tocContainer.id = 'gladius-sidebar-toc';
        tocContainer.className = 'mw-portlet portal';
        tocContainer.setAttribute('role', 'navigation');
        tocContainer.setAttribute('aria-label', 'Page contents');

        tocContainer.appendChild(toc);

        /*
         * Place the TOC at the top of the existing sidebar,
         * above Main page, Recent changes and other links.
         */
        sidebar.insertBefore(toc*ontainer, sidebar.firstChild);

  *     document.body.classList.add('*ladius-toc-enabled');
    }

    m*veTOCToSidebar();

    mw.hook('wi*ipage.content').add(function () {
*       moveTOCToSidebar();
    });*});