MediaWiki:Common.js: Difference between revisions
From TANGOWIKI-TITAF
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
mw.loader.using('jquery').done(function () { | mw.loader.using('jquery').done(function () { | ||
$(document).ready(function () { | $(document).ready(function () { | ||
setTimeout(function () { | setTimeout(function () { | ||
// Target Composer and Lyricist token fields | |||
$('select[name="Recording[Composer][]"], select[name="Recording[Lyricist][]"]').on('select2:select', function () { | $('select[name="Recording[Composer][]"], select[name="Recording[Lyricist][]"]').on('select2:select', function () { | ||
const $select = $(this); | const $select = $(this); | ||
setTimeout(function () { | setTimeout(function () { | ||
$select.find('option:selected').each(function () { | $select.find('option:selected').each(function () { | ||
const label = $(this).text(); | const label = $(this).text(); | ||
const match = label.match(/\((TITAF-P-\d+)\)$/); // | const match = label.match(/\((TITAF-P-\d+)\)$/); // Look for pattern: (TITAF-P-1234567) | ||
if (match) { | if (match) { | ||
const id = match[1]; | const id = match[1]; | ||
Revision as of 20:49, 26 May 2025
mw.loader.using('jquery').done(function () {
$(document).ready(function () {
setTimeout(function () {
// Target Composer and Lyricist token fields
$('select[name="Recording[Composer][]"], select[name="Recording[Lyricist][]"]').on('select2:select', function () {
const $select = $(this);
setTimeout(function () {
$select.find('option:selected').each(function () {
const label = $(this).text();
const match = label.match(/\((TITAF-P-\d+)\)$/); // Look for pattern: (TITAF-P-1234567)
if (match) {
const id = match[1];
$(this).text(id).val(id);
}
});
}, 50);
});
}, 500);
});
});