MediaWiki:Gadget-wikibugs-core.js: Różnice pomiędzy wersjami
Usunięta treść Dodana treść
Uproszczenie kodu, atrybut "placeholder" działa na <textarea> w dzisiejszych czasach :) |
obsluga CAPTCHA (zob. dyskusje podlinkowana wczesniej) |
||
Linia 282:
};
buttons[mw.msg( 'wikibugs-submit-report-button' )] = function() {
that.submitForm( this );
};
Linia 302:
*/
suppressSubmit: false,
api: null,
/**
* Sends the contents of the form.
*/
submitForm: function( dialog ) {
if ( this.suppressSubmit ) {
return;
Linia 313 ⟶ 315:
var form = document.forms.WikibugForm;
var content = form.wbText.value;
var that = this;
if (
Linia 330 ⟶ 333:
} else {
content += mw.msg( 'wikibugs-reported-by', form.wbAuthor.value + ' ~~' + '~~' );
}▼
}
Linia 364 ⟶ 358:
//initialise the API
var reportPage = this.reportPage.replace( / /g, '_' );
this.api.get({
action: 'query',
prop: 'revisions',
Linia 403 ⟶ 397:
basetimestamp: page.query.pages[pageid].revisions[0].timestamp,
starttimestamp: page.curtimestamp
};
api.postWithEditToken(request).always(function(res){▼
if ( res && res.edit && res.edit.result && res.edit.result === 'Success' ) {▼
//saved successfully - go to the report page▼
window.location = mw.util.getUrl(reportPage) + '#' + encodeURIComponent(▼
encodeURI( reportedPage ).replace( /%/g, '.' ) )▼
.replace( /%/g, '.' )▼
.replace( /\.3A/g, ':' )▼
.replace( /\.20/g, '_' )▼
.replace( /\(/g, '.28' )▼
.replace( /\)/g, '.29' );▼
that.reportBug( dialog, reportedPage, request );
if ( mw.config.get( 'wgPageName' ) === reportPage ) {▼
//we're already there▼
window.location.reload();▼
}▼
} else {▼
//handle the error▼
alert( mw.msg( 'wikibugs-ajax-error' ) );▼
this.suppressSubmit = false;▼
$loadingIcon.hide();▼
}▼
});▼
});
},
reportBug: function( dialog, reportedPage, editRequest ) {
var that = this;
var reportPage = this.reportPage.replace( / /g, '_' );
var $loadingIcon = jQuery( '#wikibugs-loading-icon' );
$loadingIcon.show();
this.suppressSubmit = true;
▲ }
} else if ( res && res.edit && res.edit.result && res.edit.result === 'Failure' && res.edit.captcha ) {
mw.loader.using( 'ext.confirmEdit.CaptchaInputWidget' ).done( function() {
that.solveCaptcha( dialog, reportedPage, editRequest, res.edit.captcha );
▲ }
}).always( function() {
},
solveCaptcha: function( dialog, reportedPage, editRequest, captchaData ) {
var that = this;
var captchaInput = new mw.libs.confirmEdit.CaptchaInputWidget( captchaData );
jQuery( '#dialogContent' ).empty().append(
captchaInput.$element[ 0 ],
'<img id="wikibugs-loading-icon" src="//upload.wikimedia.org/wikipedia/commons/4/49/Linux_Ubuntu_Loader.gif" style="display:none;"/>'
);
captchaInput.on( 'load', function() {
captchaInput.focus();
captchaInput.scrollElementIntoView();
} );
var buttons = {};
buttons[mw.msg( 'wikibugs-cancel-button' )] = function() {
jQuery( this ).dialog( 'close' );
buttons[mw.msg( 'wikibugs-submit-report-button' )] = function() {
that.reportBug( dialog, reportedPage, jQuery.extend( editRequest, {
captchaid: captchaInput.getCaptchaId(),
captchaword: captchaInput.getCaptchaWord()
} ) );
};
jQuery( dialog ).dialog( 'option', 'buttons', buttons );
captchaInput.emit( 'load' );
}
};
|