Documentation may be created at User:Eduaddad/Gadget-SummaryButtonsCore.js/doc.
Note: After saving, you have to bypass your browser's cache to see the changes.
Google Chrome, Firefox, Microsoft Edge, and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button.
For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// Buttons for editing summaries
if (typeof pointSummaryButtonsA == 'undefined') {
window.pointSummaryButtonsA = ',';
}
function insertSummary ( txt ) {
if ( typeof txt !== 'string' ) {
txt = this.title;
}
var vv = $( 'input[name="wpSummary"]' ).val();
if ( vv.indexOf( txt ) !== -1 ) {
return;
}
if ( /[^,; \(\/]$/.test( vv ) && !/talk\.?\]\]\)$/.test(vv) && !/discussion\]\]\)$/.test(vv) ) {
vv += pointSummaryButtonsA;
}
if ( /[^ \(]$/.test( vv ) ) {
vv += ' ';
}
$( 'input[name="wpSummary"]' ).val( vv + txt );
}
function SumButton ( btn, txt ) {
$( '<a title="' + txt + '">' + btn + '</a>' )
.appendTo( '#userSummaryButtonsA' )
.click( insertSummary );
}
function sumButtons() {
var frm = document.getElementById( 'editform' );
if ( !mw.config.get( 'wgArticleId' ) || !frm || $( frm.wpSection ).val() === 'new' ) {
return;
}
mw.util.addCSS( '\
#wpSummary { margin-bottom: 0 }\
#userSummaryButtonsA a { background:#cef; border:1px solid #adf; padding:0 2px;\
margin:0 2px;cursor:pointer; font-size:86%; color:#666 }\
#userSummaryButtonsA a:hover { background:#bdf; color:black; text-decoration:none }' );
$( '<div id="userSummaryButtonsA">' ).insertAfter( '#wpSummary' );
$.each(
[
'Wikification', 'Style guide', 'Punctuation correction', 'Organizing', 'Updating',
'Problem', 'Category', 'Template', 'Documentation', 'Elimination',
'Illustration', 'Addition', 'New page', 'Official name changed', 'Unifying categories', 'References', 'Corrections', 'Updated documentation', 'Correcting automated text', 'Interwiki', 'New category', 'Update to 1.17', 'Vandalism removal'
],
function ( i, s ) {
SumButton( s.replace( /\|.*/, '' ), s.replace( /\|/, '' ) );
}
);
}
$.when(
mw.loader.using( 'ext.wikiEditor' ),
$.ready
).then( sumButtons );