MediaWiki:Common.js: Difference between revisions
From TANGOWIKI-TITAF
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
$(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(); | ||
} | |||
}); | }); | ||
}); | }); | ||
Revision as of 21:03, 26 May 2025
$(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();
}
});
});