Offer AFCH.consts.mockItUp for mocking requests, useful for development
This commit is contained in:
parent
be2da65d1e
commit
7e9538848f
@ -19,6 +19,8 @@ Your contributions are welcome! Please add feature requests and bug reports as n
|
||||
|
||||
If you'd like to contribute directly to the code, that's great too! In order to maintain great code quality, please submit significant changes using pull requests so that a consistent code style can be maintained throughout the project.
|
||||
|
||||
**Protip for developers**: Set `AFCH.consts.mockItUp = true;` using your browser console and instead of making API requests which modify wiki content, the script will log what it *would have done* instead.
|
||||
|
||||
### Version history
|
||||
|
||||
* 0.2 Egalitarian Elephant
|
||||
|
@ -41,6 +41,9 @@
|
||||
|
||||
// Add more constants
|
||||
$.extend( AFCH.consts, {
|
||||
// If true, the script will NOT modify actual wiki content and
|
||||
// will instead mock all such API requests (success assumed)
|
||||
mockItUp: false,
|
||||
// Edit token used in api requests
|
||||
editToken: mw.user.tokens.get( 'editToken' ),
|
||||
// Full page name, "Wikipedia talk:Articles for creation/sandbox"
|
||||
@ -363,6 +366,12 @@
|
||||
request[options.mode] = options.contents;
|
||||
}
|
||||
|
||||
if ( AFCH.consts.mockItUp ) {
|
||||
AFCH.log( request );
|
||||
deferred.resolve();
|
||||
return deferred;
|
||||
}
|
||||
|
||||
AFCH.api.post( request )
|
||||
.done( function ( data ) {
|
||||
if ( data && data.edit && data.edit.result && data.edit.result === 'Success' ) {
|
||||
@ -422,6 +431,12 @@
|
||||
token: AFCH.consts.editToken // Move token === edit token
|
||||
}, additionalParameters );
|
||||
|
||||
if ( AFCH.consts.mockItUp ) {
|
||||
AFCH.log( request );
|
||||
deferred.resolve( { to: newTitle } );
|
||||
return deferred;
|
||||
}
|
||||
|
||||
AFCH.api.post( request )
|
||||
.done( function ( data ) {
|
||||
if ( data && data.move ) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user