MediaWiki:Gadget-rollback.js: Difference between revisions

From Path of Exile 2 Wiki
Jump to navigation Jump to search
(Created page with "→‎global mw: →‎jshint strict:true, jquery:true, esversion:5, bitwise:true, curly:true, eqeqeq:true, undef:true, latedef:true, trailingcomma:true: ( function () { 'use strict'; →‎Translation strings: var i18n = { msg: 'Are you sure you want to revert all consecutive edits made by the most recent editor? This should only be used to revert vandalism or erroneous bot edits.', }; →‎* Confirm rollback with prompt: function rollbackPrompt(e) { if ( ! co...")
 
m (1 revision imported)
 
(No difference)

Latest revision as of 17:03, 24 September 2024

/* global mw */
/* jshint strict:true, jquery:true, esversion:5, bitwise:true, curly:true, eqeqeq:true, undef:true, latedef:true, trailingcomma:true */

( function () {
'use strict';

/* Translation strings */
var i18n = {
    msg: 'Are you sure you want to revert all consecutive edits made by the most recent editor? This should only be used to revert vandalism or erroneous bot edits.',
};

/*
 * Confirm rollback with prompt
 */
function rollbackPrompt(e) {
    if ( ! confirm(i18n.msg) ) {
        e.preventDefault();
    }
}

/* Fires when wiki content is added. */
mw.hook('wikipage.content').add( function ($wikipageContent) {

    var links = document.querySelectorAll('.mw-rollback-link a');
    if ( links.length > 0 ) {
        for ( var i = 0; i < links.length; i++ ) {
            var link = links[i];
            link.addEventListener('click', rollbackPrompt);
        }
    }

} );

}() );