( function () { /** * Attempt to execute a thank operation for a given edit * * @param {string} name The username of the user who made the edit * @param {string} revision The revision the user created * @param {string} recipientGender The gender of the user who made the edit * @return {Promise} The thank operation's status. */ function thankUser( name, revision, recipientGender ) { return ( new mw.Api() ).postWithToken( 'csrf', { action: 'thank', rev: revision, source: 'mobilediff' } ).then( function () { mw.notify( mw.msg( 'thanks-thanked-notice', name, recipientGender, mw.user ) ); }, function ( errorCode ) { // FIXME: What is "popup" and where is it defined? /* eslint-disable no-undef */ switch ( errorCode ) { case 'invalidrevision': popup.show( mw.msg( 'thanks-error-invalidrevision' ) ); break; case 'ratelimited': popup.show( mw.msg( 'thanks-error-ratelimited', recipientGender ) ); break; default: popup.show( mw.msg( 'thanks-error-undefined', errorCode ) ); } /* eslint-enable no-undef */ } ); } /** * Disables the thank button marking the user as thanked * * @param {jQuery} $button used for thanking * @param {string} gender The gender of the user who made the edit * @return {jQuery} $button now disabled */ function disableThanks( $button, gender ) { return $button .addClass( 'thanked' ) .prop( 'disabled', true ) .text( mw.message( 'thanks-button-thanked', mw.user, gender ).text() ); } /** * Create a thank button for a given edit * * @param {string} name The username of the user who made the edit * @param {string} rev The revision the user created * @param {string} gender The gender of the user who made the edit * @return {jQuery|null} The HTML of the button. */ function createThankLink( name, rev, gender ) { var $button = $( '