Support QuestyCaptcha and (kind of) MathCaptcha

MathCaptcha just extends SimpleCaptcha, so its output is fine to show as
text. Doing that because I'm not sure how to render TeX and this is a
reasonable fallback

Also tidy up the order of some message entries in my last commit.

Bug: 64328
Change-Id: I98312f61471667e7c4dcf715295f85642c31a688
This commit is contained in:
Krenair 2014-04-24 20:17:21 +01:00
parent 62e07f8008
commit 94b5c8dfa5
3 changed files with 20 additions and 4 deletions

View file

@ -703,10 +703,12 @@ $wgResourceModules += array(
'toc',
'captcha-edit',
// Only used if FancyCaptcha is installed and triggered on save
'captcha-label',
'fancycaptcha-edit',
'colon-separator',
// Only used if FancyCaptcha is installed and triggered on save
'fancycaptcha-edit',
// Only used if QuestyCaptcha is installed and triggered on save
'questycaptcha-edit'
),
'targets' => array( 'desktop', 'mobile' ),
),

View file

@ -556,13 +556,22 @@ ve.init.mw.ViewPageTarget.prototype.onSaveErrorCaptcha = function ( editApi ) {
$captchaDiv.append(
$( '<img>' ).attr( 'src', editApi.captcha.url )
);
} else if ( editApi.captcha.type === 'simple' ) { // SimpleCaptcha
} else if ( editApi.captcha.type === 'simple' || editApi.captcha.type === 'math' ) {
// SimpleCaptcha and MathCaptcha
$captchaParagraph.append(
mw.message( 'captcha-edit' ).parse(),
'<br>',
document.createTextNode( editApi.captcha.question )
);
} else if ( editApi.captcha.type === 'question' ) {
// QuestyCaptcha
$captchaParagraph.append(
mw.message( 'questycaptcha-edit' ).parse(),
'<br>',
editApi.captcha.question
);
}
$captchaDiv.append( this.captcha.input.$element );
this.showSaveError( $captchaDiv, false );
this.events.trackSaveError( 'captcha' );

View file

@ -657,7 +657,12 @@ ve.init.mw.Target.prototype.onSaveError = function ( jqXHR, status, data ) {
// "question" or "fancy" type of captcha. They all expose differently named properties in the
// API for different things in the UI. At this point we only support the SimpleCaptcha and FancyCaptcha
// which we very intuitively detect by the presence of a "url" property.
if ( editApi && editApi.captcha && ( editApi.captcha.url || editApi.captcha.type === 'simple' ) ) {
if ( editApi && editApi.captcha && (
editApi.captcha.url ||
editApi.captcha.type === 'simple' ||
editApi.captcha.type === 'math' ||
editApi.captcha.type === 'question'
) ) {
this.emit( 'saveErrorCaptcha', editApi );
return;
}