میدیاویکی:Gadget-UploadTemplates-core.js
تێبینی: دوای پاشەکەوتکردن، پێویستە کاشی وێبگەڕەکەت پاک بکەیتەوە تا گۆڕانکارییەکان ببینیت. بۆ گووگڵ کڕۆم، فایەرفۆکس، مایکرۆسۆفت ئێج و سافاری: پەنجە لەسەر دوگمەی ⇧ Shift ڕاگرە و کرتە لەسەر Reload بکە. بۆ وردەکاری و ڕێنمایییەکان لەسەر وێبگەڕەکانی تر، بڕوانە ئێرە.
// <nowiki>
/*
* Created by: [[User:Aram]]
* Maintained by: [[User:NguoiDungKhongDinhDanh]]
*/
/*
******************************** Documentation *******************************
* This adds a drop-down list to [[Special:Upload]] just above the "Licenses" *
* to choose appropriate non-free template for that file you want to upload. *
******************************************************************************
*/
if (mw.config.get('wgCanonicalSpecialPageName') === 'Upload') {
$(function() {
(new mw.Api()).get({
action: 'query',
prop: 'revisions',
revids: [944075, 944077],
rvprop: ['content', 'ids'],
format: 'json',
formatversion: 2
}).done(function(response) {
var options = [];
var text = [
'داڕێژەیەک ھەڵبژێرە', // This is not a template. Disabled.
'ھۆکاری بەکارھێنانی نائازاد',
'ھۆکاری بەکارھێنانی نائازادی پۆستەر'
]; // etc.
options.push({
text: text[0]
});
for (var i = 0; i < response.query.pages.length; i++) {
options.push({
text: text[i + 1],
value: response.query.pages[i].revisions[0].content
});
}
$('.mw-htmlform-field-HTMLTextAreaField').after(
$('<tr>').addClass('mw-htmlform-field-Non-free-use-rationale-templates').append(
$('<td>').addClass('mw-label').html($('<label>').attr('for', 'templateType').text('جۆری داڕێژە:'))
).append(
$('<td>').addClass('mw-input').html(function() {
var r = $('<select>').attr('name', 'templateType').attr('id', 'templateTypeSelector');
for (var i of options) {
console.log(i);
if (i === options[0]) {
r.append($('<option>').text(i.text));
} else {
r.append($('<option>').val(i.value).text(i.text));
}
}
return r;
})
)
);
$("#templateTypeSelector option:first-child").attr("disabled", "disabled");
$('#templateTypeSelector').on('change', function() {
$('#wpUploadDescription').val($(this).val());
});
});
});
}
// </nowiki>