[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/extensions/ConfirmEdit/resources/ -> ext.confirmEdit.fancyCaptcha.js (source)

   1  ( function ( $, mw ) {
   2      var api = new mw.Api();
   3      $( document ).on( 'click', '.fancycaptcha-reload', function () {
   4          var $this = $( this ), $captchaImage;
   5  
   6          $this.addClass( 'fancycaptcha-reload-loading' );
   7  
   8          $captchaImage = $( '.fancycaptcha-image' );
   9  
  10          // AJAX request to get captcha index key
  11          api.post( {
  12              action: 'fancycaptchareload',
  13              format: 'xml'
  14          }, {
  15              dataType: 'xml'
  16          } )
  17          .done( function ( xmldata ) {
  18              var imgSrc, captchaIndex;
  19              captchaIndex = $( xmldata ).find( 'fancycaptchareload' ).attr( 'index' );
  20              if ( typeof captchaIndex === 'string' ) {
  21                  // replace index key with a new one for captcha image
  22                  imgSrc = $captchaImage.attr( 'src' )
  23                  .replace( /(wpCaptchaId=)\w+/, '$1' + captchaIndex );
  24                  $captchaImage.attr( 'src', imgSrc );
  25  
  26                  // replace index key with a new one for hidden tag
  27                  $( '#wpCaptchaId' ).val( captchaIndex );
  28                  $( '#wpCaptchaWord' ).val( '' ).focus();
  29              }
  30          } )
  31          .always( function () {
  32              $this.removeClass( 'fancycaptcha-reload-loading' );
  33          } );
  34  
  35          return false;
  36      } );
  37  } )( jQuery, mediaWiki );


Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1