MediaWiki:Common.js: различия между версиями
User (обсуждение | вклад) Нет описания правки |
User (обсуждение | вклад) Нет описания правки |
||
| Строка 1: | Строка 1: | ||
// Get the select element and the forms | // Get the select element and the forms | ||
var forms = document.querySelectorAll('.createbox'); | var forms = document.querySelectorAll('.createbox'); | ||
if (typeof(forms ) != 'undefined' && | if (typeof(forms ) != 'undefined' && forms != null) | ||
{ | { | ||
Версия от 16:12, 19 мая 2024
// Get the select element and the forms
var forms = document.querySelectorAll('.createbox');
if (typeof(forms ) != 'undefined' && forms != null)
{
var select = document.createElement('select');
select.id = 'select-template';
select.className = 'mw-ui-input mw-ui-input-inline mw-inputbox-centered';
// Create the select options
var options = [
{ value: 'Шаблон:Личность', text: 'Шаблон: Личность' },
{ value: 'Шаблон:Структура', text: 'Шаблон: Структура' },
{ value: 'Шаблон:Событие', text: 'Шаблон: Событие' }
];
var opt;
for (var i = 0; i < options.length; i++) {
opt = document.createElement('option');
opt.value = options[i].value;
opt.text = options[i].text;
select.appendChild(opt);
}
// Add event listener to the select element
select.addEventListener('change', function(e) {
var value = e.target.value;
var form;
for (var i = 0; i < forms.length; i++) {
form = forms[i];
var preloadInput = form.querySelector('input[name="preload"]');
if (preloadInput) {
preloadInput.value = value;
}
}
});
var form = document.querySelector('.createbox');
form.insertBefore(select, form.querySelector('input[name="veaction"]'));
}