MediaWiki:Gadget-Adiutor-AIV.js
Eʼtibor bering: Oʻzgartirishlaringizni koʻrish uchun, yangi moslamalaringizning saqlashdan keyin, brauzer keshini tozalash kerak:
Mozilla / Firefox: Ctrl+Shift+R, IE: Ctrl+F5, Safari: Cmd+Shift+R, Konqueror: F5, Opera: Tools → Preferences orqali keshni tozalang.
/*
* Adiutor: A gadget to assist various user actions
* Author: Vikipolimer
* Licencing and attribution: [[VP:Adiutor#Litsenziya]]
* Module: Administrator intervention against vandalism
*/
/* <nowiki> */
$.when(mw.loader.using(["mediawiki.user", "oojs-ui-core", "oojs-ui-windows", ]), $.ready).then(function() {
var mwConfig = mw.config.get(["wgAction", "wgPageName", "wgTitle", "wgUserGroups", "wgUserName", "wgCanonicalNamespace", "wgNamespaceNumber"]);
api = new mw.Api();
var RDRRationale, VandalizedPageInput, revId;
var VandalizedPage = {};
var RequestRationale = false;
VandalizedPage.value = null;
var revisionID = {};
revisionID.value = null;
function RevisionDeleteRequestDialog(config) {
RevisionDeleteRequestDialog.super.call(this, config);
}
OO.inheritClass(RevisionDeleteRequestDialog, OO.ui.ProcessDialog);
RevisionDeleteRequestDialog.static.name = 'RevisionDeleteRequestDialog';
RevisionDeleteRequestDialog.static.title = 'Adiutor — Foydalanuvchini chetlashtirishga soʻrov qoldirish';
RevisionDeleteRequestDialog.static.actions = [{
action: 'save',
label: 'Soʻrov qoldirish',
flags: ['primary', 'progressive']
}, {
label: 'Yopish',
flags: 'safe'
}];
RevisionDeleteRequestDialog.prototype.initialize = function() {
RevisionDeleteRequestDialog.super.prototype.initialize.apply(this, arguments);
var RationaleSelector = new OO.ui.DropdownWidget({
menu: {
items: [
new OO.ui.MenuOptionWidget({
data: 1,
label: 'Vandalizm'
}),
new OO.ui.MenuOptionWidget({
data: 2,
label: 'Nomaqbul foydalanuvchi nomi'
}),
]
},
label: "Soʻrov turi"
});
var headerTitle = new OO.ui.MessageWidget({
type: 'notice',
inline: true,
label: new OO.ui.HtmlSnippet('<strong>Foydalanuvchini chetlashtirishga soʻrov (FChS)</strong><br><small>Soʻrov qoldirishdan avval, iltimos, <a href="https://uz.wikipedia.org/wiki/Vikipediya:Chetlashtirish_qoidalari">chetlashtirish siyosatimiz</a> bilan yaqindan tanishib chiqing.</small>')
});
this.content = new OO.ui.PanelLayout({
padded: true,
expanded: false
});
var RequestRationaleContainer = new OO.ui.FieldsetLayout({
classes: ['adiutor-report-window-rationale-window']
});
RationaleSelector.getMenu().on('choose', function(menuOption) {
switch(menuOption.getData()) {
case 1:
RequestRationale = new OO.ui.FieldsetLayout({
label: 'Soʻrov sababi'
});
RequestRationale.addItems([
new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
selected: false,
data: 'Ogohlantirishlarga qaramay, bezorilik qilishda davom etyapti',
}), {
label: 'Ogohlantirishlarga qaramay, bezorilik qilishda davom etyapti',
align: 'inline'
}),
new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
selected: false,
data: 'Chetlashtirish muddati tugagach, yana bezorilik qilishda davom etyapti',
}), {
label: 'Chetlashtirish muddati tugagach, yana bezorilik qilishda davom etyapti',
align: 'inline'
}),
]);
break;
case 2:
RequestRationale = new OO.ui.FieldsetLayout({
label: 'Soʻrov sababi'
});
RequestRationale.addItems([
new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
selected: false,
data: 'Reklamani ifodalovchi foydalanuvchi nomi',
}), {
label: 'Reklamani ifodalovchi foydalanuvchi nomi',
align: 'inline'
}),
new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
selected: false,
data: 'Haqoratomuz soʻzlarni oʻz ichiga olgan foydalanuvchi nomi',
}), {
label: 'Haqoratomuz soʻzlarni oʻz ichiga olgan foydalanuvchi nomi',
align: 'inline'
}),
]);
break;
}
RequestRationaleContainer.$element.html(RequestRationale.$element);
});
this.content.$element.append(headerTitle.$element, '<hr><br>', RationaleSelector.$element, '<br><br>', RequestRationaleContainer.$element);
RevisionDeleteRequestDialog.prototype.getBodyHeight = function() {
return Math.max(this.content.$element.outerHeight(false), 450);
};
this.$body.append(this.content.$element);
};
RevisionDeleteRequestDialog.prototype.getActionProcess = function(action) {
var dialog = this;
if(action) {
if(RequestRationale) {
RequestRationale.items.forEach(function(Rationale) {
if(Rationale.fieldWidget.selected) {
RDRRationale = Rationale.fieldWidget.data;
}
});
}
if(RDRRationale) {
return new OO.ui.Process(function() {
if(VandalizedPage.value) {
VandalizedPageInput = '';
} else {
VandalizedPageInput = '';
}
if(revisionID.value) {
revId = '';
} else {
revId = '';
}
PreparedText = '{{subst:Vikipediya:Foydalanuvchilarni chetlashtirishga soʻrovlar/andoza |1= ' + mwConfig.wgPageName.replace(/_/g, " ").replace('Foydalanuvchi:', '').replace('Maxsus:Contributions/', '') + ' |2='.concat(RDRRationale) + '}}';
addReport(PreparedText);
console.log(PreparedText);
dialog.close({
action: action
});
});
} else {
OO.ui.alert('Iltimos, formada koʻrsatilgan sabablardan kamida bittasini tanlang.').done(function() {});
}
}
return RevisionDeleteRequestDialog.super.prototype.getActionProcess.call(this, action);
};
var windowManager = new OO.ui.WindowManager();
$(document.body).append(windowManager.$element);
var dialog = new RevisionDeleteRequestDialog();
windowManager.addWindows([dialog]);
windowManager.openWindow(dialog);
function addReport(PreparedText) {
api.postWithToken('csrf', {
action: 'edit',
title: 'Vikipediya:Foydalanuvchilarni chetlashtirishga soʻrovlar',
appendtext: "\n" + PreparedText + "\n",
summary: '[[Foydalanuvchi:' + mwConfig.wgPageName.replace(/_/g, " ").replace('Foydalanuvchi:', '').replace('Maxsus:Contributions/', '') + ']]ni chetlashtirishga soʻrov qoldirildi.',
tags: 'Adiutor',
format: 'json'
}).done(function() {
window.location = '/wiki/Vikipediya:Foydalanuvchilarni_chetlashtirishga_soʻrovlar';
});
}
});
/* </nowiki> */