Jump to content

MediaWiki:Common.js

From Once Human Guide
Revision as of 21:00, 21 April 2026 by Bones (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.
mw.loader.using(['mediawiki.util']).then(function () {
  $(function () {

    document.querySelectorAll('.mw-dropdown-ui').forEach(container => {
      const select = container.querySelector('select');
      const output = container.querySelector('.mw-dropdown-output');

      if (!select || !output) return;

      // Build lookup from hidden content
      const map = {};

      container.querySelectorAll('[data-value]').forEach(el => {
        map[el.getAttribute('data-value')] = el.innerHTML;
        el.style.display = 'none';
      });

      select.addEventListener('change', function () {
        const val = this.value;
        output.innerHTML = map[val] || "";
      });

    });

  });
});