MediaWiki:Common.js: Difference between revisions
From TANGOWIKI-TITAF
No edit summary Tag: Manual revert |
No edit summary |
||
| Line 1: | Line 1: | ||
/* Any JavaScript here will be loaded for all users on every page load. */ | /* Any JavaScript here will be loaded for all users on every page load. */ | ||
mw.loader.using(' | mw.loader.using('jquery').done(function () { | ||
$(document).ready(function () { | |||
// Wait for Select2 to fully initialize | |||
setTimeout(function () { | |||
$('select[name="Recording[Composer][]"], select[name="Recording[Lyricist][]"]').on('select2:select', function () { | |||
const $select = $(this); | |||
// Wait a bit to ensure the new option is added | |||
setTimeout(function () { | |||
$select.find('option:selected').each(function () { | |||
const label = $(this).text(); | |||
const match = label.match(/\((TITAF-P-\d+)\)$/); // e.g., "Name (TITAF-P-1234567)" | |||
if (match) { | |||
const id = match[1]; | |||
$(this).text(id).val(id); | |||
} | |||
}); | |||
}, 50); | |||
}); | |||
}, 500); | |||
}); | |||
}); | |||
Revision as of 20:44, 26 May 2025
/* Any JavaScript here will be loaded for all users on every page load. */
mw.loader.using('jquery').done(function () {
$(document).ready(function () {
// Wait for Select2 to fully initialize
setTimeout(function () {
$('select[name="Recording[Composer][]"], select[name="Recording[Lyricist][]"]').on('select2:select', function () {
const $select = $(this);
// Wait a bit to ensure the new option is added
setTimeout(function () {
$select.find('option:selected').each(function () {
const label = $(this).text();
const match = label.match(/\((TITAF-P-\d+)\)$/); // e.g., "Name (TITAF-P-1234567)"
if (match) {
const id = match[1];
$(this).text(id).val(id);
}
});
}, 50);
});
}, 500);
});
});