/*
* Adiutor: A gadget to assist various user actions
* Author: User:Vikipolimer
* Licencing and attribution: [[VP:Adiutor#Lisanslama ve atıf]]
* Module: Requests for page protection
/* <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"]);
var RPPText, RPPSummary;
function PageProtectionDialog(config) {
PageProtectionDialog.super.call(this, config);
}
OO.inheritClass(PageProtectionDialog, OO.ui.ProcessDialog);
PageProtectionDialog.static.name = 'PageProtectionDialog';
PageProtectionDialog.static.title = 'Adiutor (Beta) - RPP';
PageProtectionDialog.static.actions = [{
action: 'save',
label: 'Create Request',
flags: ['primary', 'progressive']
}, {
label: 'Cancel',
flags: 'safe'
}];
PageProtectionDialog.prototype.initialize = function() {
PageProtectionDialog.super.prototype.initialize.apply(this, arguments);
var headerTitle = new OO.ui.MessageWidget({
type: 'notice',
inline: true,
label: new OO.ui.HtmlSnippet('<strong>Requests for page protection</strong><br><small>This page is for requesting that a page, file or template be protected. Please read up on the protection policy.</small>')
});
TypeOfAction = new OO.ui.FieldsetLayout({
label: 'Protection Type'
});
TypeOfAction.addItems([
new OO.ui.DropdownWidget({
menu: {
items: [
new OO.ui.MenuSectionOptionWidget({
label: 'Full protection'
}),
new OO.ui.MenuOptionWidget({
data: "1",
label: 'Generic (full)'
}),
new OO.ui.MenuOptionWidget({
data: "2",
label: 'Content dispute/edit warring (full)'
}),
new OO.ui.MenuOptionWidget({
data: "3",
label: 'Persistent vandalism (full)'
}),
new OO.ui.MenuOptionWidget({
data: "4",
label: 'User talk of blocked user (full)'
}),
//Extended confirmed protection
new OO.ui.MenuSectionOptionWidget({
label: 'Extended confirmed protection'
}),
new OO.ui.MenuOptionWidget({
data: "1",
label: 'Arbitration enforcement (ECP)'
}),
new OO.ui.MenuOptionWidget({
data: "2",
label: 'Persistent vandalism (ECP)'
}),
new OO.ui.MenuOptionWidget({
data: "3",
label: 'Disruptive editing (ECP)'
}),
new OO.ui.MenuOptionWidget({
data: "4",
label: 'BLP policy violations (ECP)'
}),
new OO.ui.MenuOptionWidget({
data: "4",
label: 'Sockpuppetry (ECP)'
}),
//Semi-protection
new OO.ui.MenuSectionOptionWidget({
label: 'Semi-protection'
}),
new OO.ui.MenuOptionWidget({
data: "1",
label: 'Generic (semi)'
}),
new OO.ui.MenuOptionWidget({
data: "2",
label: 'Persistent vandalism (semi)'
}),
new OO.ui.MenuOptionWidget({
data: "3",
label: 'Disruptive editing (semi)'
}),
new OO.ui.MenuOptionWidget({
data: "4",
label: 'Adding unsourced content (semi)'
}),
new OO.ui.MenuOptionWidget({
data: "4",
label: 'BLP policy violations (semi)'
}),
new OO.ui.MenuOptionWidget({
data: "4",
label: 'Sockpuppetry (semi)'
}),
new OO.ui.MenuOptionWidget({
data: "4",
label: 'User talk of blocked user (semi)'
}),
//Pending changes
new OO.ui.MenuSectionOptionWidget({
label: 'Pending changes'
}),
new OO.ui.MenuOptionWidget({
data: "1",
label: 'Generic (PC)'
}),
new OO.ui.MenuOptionWidget({
data: "2",
label: 'Persistent vandalism (PC)'
}),
new OO.ui.MenuOptionWidget({
data: "3",
label: 'Disruptive editing (PC)'
}),
new OO.ui.MenuOptionWidget({
data: "4",
label: 'Adding unsourced content (PC)'
}),
new OO.ui.MenuOptionWidget({
data: "4",
label: 'BLP policy violations (PC)'
}),
//Move protection
new OO.ui.MenuSectionOptionWidget({
label: 'Move protection'
}),
new OO.ui.MenuOptionWidget({
data: "1",
label: 'Generic (move)'
}),
new OO.ui.MenuOptionWidget({
data: "2",
label: 'Dispute/move warring (move)'
}),
new OO.ui.MenuOptionWidget({
data: "3",
label: 'Page-move vandalism (move)'
}),
new OO.ui.MenuOptionWidget({
data: "4",
label: 'Highly visible page (move)'
}),
]
},
label: "Select protection type"
}),
DurationOfProtection = new OO.ui.DropdownWidget({
menu: {
items: [
new OO.ui.MenuOptionWidget({
data: 1,
label: 'Temporary'
}),
new OO.ui.MenuOptionWidget({
data: 2,
label: 'Indefinite'
}),
]
},
label: "Duration"
}),
rationaleField = new OO.ui.FieldLayout(rationaleInput = new OO.ui.MultilineTextInputWidget({
placeholder: 'Reason for protection:',
indicator: 'required',
value: '',
}), {
label: 'Reason',
align: 'inline',
}),
]);
rationaleInput.on('change', function() {
if (rationaleInput.value != "") {
InputFilled = false;
} else {
InputFilled = true;
}
});
this.content = new OO.ui.PanelLayout({
padded: true,
expanded: false
});
this.content.$element.append(headerTitle.$element, '<br><hr><br>', TypeOfAction.$element);
this.$body.append(this.content.$element);
};
PageProtectionDialog.prototype.getActionProcess = function(action) {
var dialog = this;
if (action) {
return new OO.ui.Process(function() {
RPPText = "=== [[" + mwConfig.wgPageName + "]] === * {{pagelinks|" + mwConfig.wgPageName + "}} '''Reason:''' " + rationaleInput.value + ". ~~~~";
RPPSummary = 'Requesting page protection for [[' + mwConfig.wgPageName + ']]';
addProtectionRequests(RPPText);
dialog.close({
action: action
});
});
}
return PageProtectionDialog.super.prototype.getActionProcess.call(this, action);
};
var windowManager = new OO.ui.WindowManager();
$(document.body).append(windowManager.$element);
var dialog = new PageProtectionDialog();
windowManager.addWindows([dialog]);
windowManager.openWindow(dialog);
function addProtectionRequests(RPPText) {
api.postWithToken('csrf', {
action: 'edit',
title: 'Wikipedia:Requests for page protection/Increase',
appendtext: RPPText + "\n",
summary: RPPSummary,
//tags: 'Adiutor',
format: 'json'
}).done(function() {
window.location = '/wiki/Wikipedia:Requests for page protection';
});
}
});
/* </nowiki> */