MediaWiki:Gadget-StandardEditSummaries.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
// Standard edit summaries, evolved from "Gadget-predefined-summaries"
// Lists interactive common edit reasons below "Summary"
mw.loader.using(['mediawiki.util']).then(function () {
'use strict';
if (window.resumeDeluxe === undefined &&
['edit', 'submit'].includes(mw.config.get('wgAction')) &&
mw.util.getParamValue('section') !== 'new') {
var resumeDeluxe = {
titles: ["normalization", "general fixes", "information added", "information update", "categorization", "template fixes", "template update", "+template", "+ references(s)", "+ internal link(s)", "+ external link(s)", "- external link(s)"],
inputs: ["normalization", "general fixes", "information added", "information update", "categorization", "template fixes", "template update", "+template", "+ references(s)", "+ internal link(s)", "+ external link(s)", "- external link(s)"],
addToSummary: function (str) {
var summaryField = document.getElementById('wpSummary');
if (summaryField) {
summaryField.value = summaryField.value ? summaryField.value + '; ' + str : str;
}
return false;
}
};
window.resumeDeluxe = resumeDeluxe;
var DeluxeSummary = function() {
var summaryLabel = document.getElementById('wpSummaryLabel');
var summaryField = document.getElementById('wpSummary');
if (summaryLabel && summaryField) {
// Prevent duplicate bars by checking for an existing one
if (summaryLabel.querySelector('.predefined-summaries-bar')) {
return;
}
// Create container with a unique class name
var container = document.createElement('span');
container.className = 'predefined-summaries-bar';
container.innerHTML = '<b>Predefined summaries</b>: ';
resumeDeluxe.titles.forEach((title, index) => {
if (index > 0) {
container.appendChild(document.createTextNode(' / '));
}
var link = document.createElement('a');
link.href = '#';
link.className = 'sumLink';
link.title = 'Add to edit summary';
link.textContent = title;
link.addEventListener('click', function (event) {
event.preventDefault();
resumeDeluxe.addToSummary(resumeDeluxe.inputs[index]);
});
container.appendChild(link);
});
container.appendChild(document.createElement('br'));
summaryLabel.prepend(container);
// Adjust width as in original script
summaryField.style.width = '95%';
}
};
mw.hook('wikipage.content').add(DeluxeSummary);
}
});