User:TheJJJunk/Gadget-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:TheJJJunk/Gadget-defaultsummaries. |
(function ($) { // Wrap with anonymous function
// The original value of the edit summary field is stored here
var editsummOriginalSummary = "";
function editsummAddOptionToDropdown(dropdown, optionText) {
var option = document.createElement("option");
var optionTextNode = document.createTextNode(optionText);
option.appendChild(optionTextNode);
dropdown.appendChild(option);
}
function editsummAddCatToDropdown(dropdown, catText) {
var option = document.createElement("option");
option.disabled = true;
option.selected = true;
var optionTextNode = document.createTextNode(catText);
option.appendChild(optionTextNode);
dropdown.appendChild(option);
}
function editsummOnCannedSummarySelected() {
// Save the original value of the edit summary field
editsummOriginalSummary = document.getElementById("wpSummary");
if (editsummOriginalSummary) {
editsummOriginalSummary = editsummOriginalSummary.value;
} else {
editsummOriginalSummary = "";
}
var idx = this.selectedIndex;
var canned = this.options[idx].text;
var newSummary = editsummOriginalSummary;
// Append old edit summary with space, if exists,
// and last character != space
if (newSummary.length !== 0 && newSummary.charAt(newSummary.length - 1) !== " ") {
newSummary += " ";
}
newSummary += canned;
document.getElementById("wpSummary").value = newSummary;
}
$(function () {
var insertBeforeThis = document.getElementById("wpSummary");
// Loop through siblings, looking for editCheckboxes class
while (insertBeforeThis) {
if (insertBeforeThis.className === "editCheckboxes") {
break;
}
insertBeforeThis = insertBeforeThis.nextSibling;
}
// If we failed to find the editCheckboxes class, or insertBeforeThis is null
if (!insertBeforeThis || insertBeforeThis.className !== "editCheckboxes") {
return;
}
editsummOriginalSummary = editsummOriginalSummary.value;
// For convenience, add a dropdown box with some canned edit
// summaries to the form.
var dropdown = document.createElement("select");
dropdown.style.width = "38%";
dropdown.style.margin = "0 4px 0 0";
dropdown.onchange = editsummOnCannedSummarySelected;
var minorDropdown = document.createElement("select");
minorDropdown.style.width = "38%";
minorDropdown.onchange = editsummOnCannedSummarySelected;
editsummAddCatToDropdown(minorDropdown, "Common edit summaries – click to use");
editsummAddCatToDropdown(dropdown, "Common citation/cite error summaries – click to use");
editsummAddOptionToDropdown(minorDropdown, "Spelling/grammar correction");
editsummAddOptionToDropdown(minorDropdown, "Fixing style/layout errors");
editsummAddOptionToDropdown(minorDropdown, "[[Help:Reverting|Reverting]] [[Wikipedia:Vandalism|vandalism]] or test edit");
editsummAddOptionToDropdown(minorDropdown, "[[Help:Reverting|Reverting]] unexplained content removal");
editsummAddOptionToDropdown(minorDropdown, "Copyedit (minor)");
editsummAddOptionToDropdown(minorDropdown, "Adding/improving reference(s)");
editsummAddOptionToDropdown(minorDropdown, "Adding/removing category/ies");
editsummAddOptionToDropdown(minorDropdown, "Adding/removing external link(s)");
editsummAddOptionToDropdown(minorDropdown, "Adding/removing wikilink(s)");
editsummAddOptionToDropdown(minorDropdown, "Removing unsourced content");
editsummAddOptionToDropdown(minorDropdown, "Removing [[WP:SPAM|linkspam]] per [[WP:EL]]");
editsummAddOptionToDropdown(minorDropdown, "[[Help:Reverting|Reverting]] possible [[Wikipedia:Vandalism|vandalism]] by [[WP:IP|IP]]");
editsummAddOptionToDropdown(minorDropdown, "Clean up");
editsummAddOptionToDropdown(minorDropdown, "Copyedit (major)");
if (mw.config.get('wgNamespaceNumber') === 0) {
editsummAddOptionToDropdown(dropdown, "fixed [[Help:Cite errors/Cite error refs without references#Overview|cite error]] → added {{Reflist}} using [[User:TheJJJunk/ARA|ARA]]");
editsummAddOptionToDropdown(dropdown, "fixed [[Help:Cite errors/Cite error refs without references#Overview|cite error]] → added {{Reflist}}");
editsummAddOptionToDropdown(dropdown, "fixed [[Help:Cite errors/Cite error group refs without references#Overview|cite error]] → added {{Reflist|group}}");
editsummAddOptionToDropdown(dropdown, "fixed [[Help:Cite errors/Cite error refs without references#Overview|cite error]] → references were cited below {{Reflist}}");
editsummAddOptionToDropdown(dropdown, "fixed [[Help:Cite errors/Cite error included ref#Overview|cite error]] → missing closing </ref> tag");
editsummAddOptionToDropdown(dropdown, "fixed [[Help:Cite errors/Cite error ref no input#Overview|cite error]] → removed empty citation(s)");
editsummAddOptionToDropdown(dropdown, "fixed cite error → removed unnecessary ref group(s) (see [[WP:REFGROUP]])");
} else {
editsummAddOptionToDropdown(dropdown, "Reply");
editsummAddOptionToDropdown(dropdown, "Comment");
editsummAddOptionToDropdown(dropdown, "Suggestion");
if ((mw.config.get('wgNamespaceNumber') % 2 !== 0) & (mw.config.get('wgNamespaceNumber') !== 3)) {
editsummAddOptionToDropdown(dropdown, "[[Wikipedia:WikiProject|WikiProject]] tagging");
editsummAddOptionToDropdown(dropdown, "[[Wikipedia:WikiProject|WikiProject]] assessment");
}
}
var theParent = insertBeforeThis.parentNode;
theParent.insertBefore(dropdown, insertBeforeThis);
theParent.insertBefore(minorDropdown, insertBeforeThis);
theParent.insertBefore(document.createElement("br"), dropdown);
});
}(jQuery)); // End wrap with anonymous function