User:Aidan9382/scripts/defaultSummaries.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
Documentation for this user script can be added at User:Aidan9382/scripts/defaultSummaries. |
//Inspired by [[MediaWiki:Gadget-defaultsummaries.js]]
$.when( $.ready, mw.loader.using( 'oojs-ui' ) ).then( function() {
var
// <nowiki>
moveSummaries = [
"Correct archive indexing for simplicity and template functionality",
"Move subpage left behind during move of parent page",
"Standardise/fix archive name",
],
editSummaries = [
"Correct archive indexing for simplicity and template functionality",
"Merging content unreasonably split due to poor auto-archive management",
"[[Category:Pages which use a template in place of a magic word]]",
"Fix {{[[Template:Center|center]]}} args",
"Do not use 2 archiving bots at once. Archives unified into one consistent format",
"Fix [[WP:Linter|Lint]] Errors",
"Page protection has expired",
"Fix auto-archive location",
"Fix excerpt target",
];
// </nowiki>
var dropdown = new OO.ui.DropdownWidget({
label: 'Edit summaries'
});
var dropdownElement = dropdown.$element[0];
function addOptions(options) {
dropdown.menu.addItems( options.map( function ( optionText ) {
return new OO.ui.MenuOptionWidget( { label: optionText } );
} ) );
}
var inputBox;
if (mw.config.get("wgCanonicalSpecialPageName") == "Movepage") {
addOptions(moveSummaries);
dropdown.menu.on("select",function(option) {
inputBox = document.getElementById("wpReason"); //Fetching inside the select function is intentional here
inputBox.firstElementChild.value = option.getLabel();
});
dropdownElement.style = "margin-top:12px";
var moveButton = document.getElementsByClassName("oo-ui-flaggedElement-primary")[0];
moveButton.after(dropdownElement);
} else if (document.getElementById("wpTextbox1")) {
addOptions(editSummaries);
inputBox = document.getElementById("wpSummary");
minorEditBox = document.getElementById('wpMinoredit');
dropdown.menu.on("select",function(option) {
inputBox.value = option.getLabel();
minorEditBox.checked = true;
});
dropdownElement.style = "margin-bottom:0";
var watchDropdown = document.getElementById("mw-editpage-watchlist-expiry");
if (watchDropdown) {
watchDropdown.after(dropdownElement);
}
} else {
//nothing
}
});