MediaWiki:Common.js

From TANGOWIKI-TITAF
Revision as of 21:03, 26 May 2025 by Donxello (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.
$(document).ready(function () {
  $('select[name="Tune[Composer][is_list]"], select[name="Tune[Lyricist][is_list]"]').on('select2:select', function (e) {
    var selected = e.params.data.text;
    var match = selected.match(/\((TITAF-[^)]+)\)$/); // extracts TITAF-P-xxxxxxx
    if (match) {
      var newVal = match[1]; // TITAF-P-xxxxxxx
      var newOption = new Option(newVal, newVal, true, true);
      $(this).append(newOption).trigger('change');
      var oldOption = $(this).find('option').filter(function () {
        return $(this).text() === selected;
      });
      oldOption.remove();
    }
  });
});