wiki.techinc.nl/resources/mediawiki.api/mediawiki.api.edit.js

120 lines
3.6 KiB
JavaScript
Raw Normal View History

[mediawiki.api] clean up * Adding return values to most of the ajax functions so that the jqXHR object (originally returned by jQuery.ajax) is available. Some functions documented they already did this, some don't. Now they all do and are also documented as such. * Renaming a few 'callback' arguments to 'success' to avoid confusion with 'error'. * Removed unused variables ** mw.Api's instance this.url was unused ** var cachedToken was unused in mediawiki.api.titleblacklist.js * Making closure argument order the same and referencing mediaWiki as a global (mw is something thought not to be a global but mediaWiki certainly is, no need to access window from the global scope and then the mediaWiki property of it). Also renamed any used of $j to $. Adding 'undefined' to the closure arguments where missing. * Re-written the mw.Api constructor's logic for options. Now keeping a defaultOptions privately "statically" cached outside the constructor and using that to build the options object. * Made all non-block comments the same comment style (some were /* */ or /* \n */) * Completed parameter documentation and wrote TODO as @todo and added an example use for mw.Api in the documentation. * Some other random whitespacing, line breaking, merged var statement, and moved them out of blocks (since JS doesn't have block scope) into the main function body for clarity. And some other random JS Lint/JS Hint stuff. * Added comment to api.titleblacklist module about the module not being in core but in the TitleBlacklist extension.
2011-12-21 23:52:37 +00:00
/**
* Additional mw.Api methods to assist with API calls related to editing wiki pages.
*/
[mediawiki.api] clean up * Adding return values to most of the ajax functions so that the jqXHR object (originally returned by jQuery.ajax) is available. Some functions documented they already did this, some don't. Now they all do and are also documented as such. * Renaming a few 'callback' arguments to 'success' to avoid confusion with 'error'. * Removed unused variables ** mw.Api's instance this.url was unused ** var cachedToken was unused in mediawiki.api.titleblacklist.js * Making closure argument order the same and referencing mediaWiki as a global (mw is something thought not to be a global but mediaWiki certainly is, no need to access window from the global scope and then the mediaWiki property of it). Also renamed any used of $j to $. Adding 'undefined' to the closure arguments where missing. * Re-written the mw.Api constructor's logic for options. Now keeping a defaultOptions privately "statically" cached outside the constructor and using that to build the options object. * Made all non-block comments the same comment style (some were /* */ or /* \n */) * Completed parameter documentation and wrote TODO as @todo and added an example use for mw.Api in the documentation. * Some other random whitespacing, line breaking, merged var statement, and moved them out of blocks (since JS doesn't have block scope) into the main function body for clarity. And some other random JS Lint/JS Hint stuff. * Added comment to api.titleblacklist module about the module not being in core but in the TitleBlacklist extension.
2011-12-21 23:52:37 +00:00
( function( $, mw, undefined ) {
[mediawiki.api] clean up * Adding return values to most of the ajax functions so that the jqXHR object (originally returned by jQuery.ajax) is available. Some functions documented they already did this, some don't. Now they all do and are also documented as such. * Renaming a few 'callback' arguments to 'success' to avoid confusion with 'error'. * Removed unused variables ** mw.Api's instance this.url was unused ** var cachedToken was unused in mediawiki.api.titleblacklist.js * Making closure argument order the same and referencing mediaWiki as a global (mw is something thought not to be a global but mediaWiki certainly is, no need to access window from the global scope and then the mediaWiki property of it). Also renamed any used of $j to $. Adding 'undefined' to the closure arguments where missing. * Re-written the mw.Api constructor's logic for options. Now keeping a defaultOptions privately "statically" cached outside the constructor and using that to build the options object. * Made all non-block comments the same comment style (some were /* */ or /* \n */) * Completed parameter documentation and wrote TODO as @todo and added an example use for mw.Api in the documentation. * Some other random whitespacing, line breaking, merged var statement, and moved them out of blocks (since JS doesn't have block scope) into the main function body for clarity. And some other random JS Lint/JS Hint stuff. * Added comment to api.titleblacklist module about the module not being in core but in the TitleBlacklist extension.
2011-12-21 23:52:37 +00:00
// Cache token so we don't have to keep fetching new ones for every single request.
var cachedToken = null;
[mediawiki.api] clean up * Adding return values to most of the ajax functions so that the jqXHR object (originally returned by jQuery.ajax) is available. Some functions documented they already did this, some don't. Now they all do and are also documented as such. * Renaming a few 'callback' arguments to 'success' to avoid confusion with 'error'. * Removed unused variables ** mw.Api's instance this.url was unused ** var cachedToken was unused in mediawiki.api.titleblacklist.js * Making closure argument order the same and referencing mediaWiki as a global (mw is something thought not to be a global but mediaWiki certainly is, no need to access window from the global scope and then the mediaWiki property of it). Also renamed any used of $j to $. Adding 'undefined' to the closure arguments where missing. * Re-written the mw.Api constructor's logic for options. Now keeping a defaultOptions privately "statically" cached outside the constructor and using that to build the options object. * Made all non-block comments the same comment style (some were /* */ or /* \n */) * Completed parameter documentation and wrote TODO as @todo and added an example use for mw.Api in the documentation. * Some other random whitespacing, line breaking, merged var statement, and moved them out of blocks (since JS doesn't have block scope) into the main function body for clarity. And some other random JS Lint/JS Hint stuff. * Added comment to api.titleblacklist module about the module not being in core but in the TitleBlacklist extension.
2011-12-21 23:52:37 +00:00
$.extend( mw.Api.prototype, {
[mediawiki.api] clean up * Adding return values to most of the ajax functions so that the jqXHR object (originally returned by jQuery.ajax) is available. Some functions documented they already did this, some don't. Now they all do and are also documented as such. * Renaming a few 'callback' arguments to 'success' to avoid confusion with 'error'. * Removed unused variables ** mw.Api's instance this.url was unused ** var cachedToken was unused in mediawiki.api.titleblacklist.js * Making closure argument order the same and referencing mediaWiki as a global (mw is something thought not to be a global but mediaWiki certainly is, no need to access window from the global scope and then the mediaWiki property of it). Also renamed any used of $j to $. Adding 'undefined' to the closure arguments where missing. * Re-written the mw.Api constructor's logic for options. Now keeping a defaultOptions privately "statically" cached outside the constructor and using that to build the options object. * Made all non-block comments the same comment style (some were /* */ or /* \n */) * Completed parameter documentation and wrote TODO as @todo and added an example use for mw.Api in the documentation. * Some other random whitespacing, line breaking, merged var statement, and moved them out of blocks (since JS doesn't have block scope) into the main function body for clarity. And some other random JS Lint/JS Hint stuff. * Added comment to api.titleblacklist module about the module not being in core but in the TitleBlacklist extension.
2011-12-21 23:52:37 +00:00
/**
* Post to API with edit token. If we have no token, get one and try to post.
* If we have a cached token try using that, and if it fails, blank out the
* cached token and start over.
*
* @param params {Object} API parameters
* @param ok {Function} callback for success
* @param err {Function} [optional] error callback
* @return {jqXHR}
*/
postWithEditToken: function( params, ok, err ) {
[mediawiki.api] clean up * Adding return values to most of the ajax functions so that the jqXHR object (originally returned by jQuery.ajax) is available. Some functions documented they already did this, some don't. Now they all do and are also documented as such. * Renaming a few 'callback' arguments to 'success' to avoid confusion with 'error'. * Removed unused variables ** mw.Api's instance this.url was unused ** var cachedToken was unused in mediawiki.api.titleblacklist.js * Making closure argument order the same and referencing mediaWiki as a global (mw is something thought not to be a global but mediaWiki certainly is, no need to access window from the global scope and then the mediaWiki property of it). Also renamed any used of $j to $. Adding 'undefined' to the closure arguments where missing. * Re-written the mw.Api constructor's logic for options. Now keeping a defaultOptions privately "statically" cached outside the constructor and using that to build the options object. * Made all non-block comments the same comment style (some were /* */ or /* \n */) * Completed parameter documentation and wrote TODO as @todo and added an example use for mw.Api in the documentation. * Some other random whitespacing, line breaking, merged var statement, and moved them out of blocks (since JS doesn't have block scope) into the main function body for clarity. And some other random JS Lint/JS Hint stuff. * Added comment to api.titleblacklist module about the module not being in core but in the TitleBlacklist extension.
2011-12-21 23:52:37 +00:00
var api = this, useTokenToPost, getTokenIfBad;
if ( cachedToken === null ) {
// We don't have a valid cached token, so get a fresh one and try posting.
// We do not trap any 'badtoken' or 'notoken' errors, because we don't want
// an infinite loop. If this fresh token is bad, something else is very wrong.
[mediawiki.api] clean up * Adding return values to most of the ajax functions so that the jqXHR object (originally returned by jQuery.ajax) is available. Some functions documented they already did this, some don't. Now they all do and are also documented as such. * Renaming a few 'callback' arguments to 'success' to avoid confusion with 'error'. * Removed unused variables ** mw.Api's instance this.url was unused ** var cachedToken was unused in mediawiki.api.titleblacklist.js * Making closure argument order the same and referencing mediaWiki as a global (mw is something thought not to be a global but mediaWiki certainly is, no need to access window from the global scope and then the mediaWiki property of it). Also renamed any used of $j to $. Adding 'undefined' to the closure arguments where missing. * Re-written the mw.Api constructor's logic for options. Now keeping a defaultOptions privately "statically" cached outside the constructor and using that to build the options object. * Made all non-block comments the same comment style (some were /* */ or /* \n */) * Completed parameter documentation and wrote TODO as @todo and added an example use for mw.Api in the documentation. * Some other random whitespacing, line breaking, merged var statement, and moved them out of blocks (since JS doesn't have block scope) into the main function body for clarity. And some other random JS Lint/JS Hint stuff. * Added comment to api.titleblacklist module about the module not being in core but in the TitleBlacklist extension.
2011-12-21 23:52:37 +00:00
useTokenToPost = function( token ) {
params.token = token;
api.post( params, ok, err );
};
[mediawiki.api] clean up * Adding return values to most of the ajax functions so that the jqXHR object (originally returned by jQuery.ajax) is available. Some functions documented they already did this, some don't. Now they all do and are also documented as such. * Renaming a few 'callback' arguments to 'success' to avoid confusion with 'error'. * Removed unused variables ** mw.Api's instance this.url was unused ** var cachedToken was unused in mediawiki.api.titleblacklist.js * Making closure argument order the same and referencing mediaWiki as a global (mw is something thought not to be a global but mediaWiki certainly is, no need to access window from the global scope and then the mediaWiki property of it). Also renamed any used of $j to $. Adding 'undefined' to the closure arguments where missing. * Re-written the mw.Api constructor's logic for options. Now keeping a defaultOptions privately "statically" cached outside the constructor and using that to build the options object. * Made all non-block comments the same comment style (some were /* */ or /* \n */) * Completed parameter documentation and wrote TODO as @todo and added an example use for mw.Api in the documentation. * Some other random whitespacing, line breaking, merged var statement, and moved them out of blocks (since JS doesn't have block scope) into the main function body for clarity. And some other random JS Lint/JS Hint stuff. * Added comment to api.titleblacklist module about the module not being in core but in the TitleBlacklist extension.
2011-12-21 23:52:37 +00:00
return api.getEditToken( useTokenToPost, err );
} else {
// We do have a token, but it might be expired. So if it is 'bad' then
// start over with a new token.
params.token = cachedToken;
[mediawiki.api] clean up * Adding return values to most of the ajax functions so that the jqXHR object (originally returned by jQuery.ajax) is available. Some functions documented they already did this, some don't. Now they all do and are also documented as such. * Renaming a few 'callback' arguments to 'success' to avoid confusion with 'error'. * Removed unused variables ** mw.Api's instance this.url was unused ** var cachedToken was unused in mediawiki.api.titleblacklist.js * Making closure argument order the same and referencing mediaWiki as a global (mw is something thought not to be a global but mediaWiki certainly is, no need to access window from the global scope and then the mediaWiki property of it). Also renamed any used of $j to $. Adding 'undefined' to the closure arguments where missing. * Re-written the mw.Api constructor's logic for options. Now keeping a defaultOptions privately "statically" cached outside the constructor and using that to build the options object. * Made all non-block comments the same comment style (some were /* */ or /* \n */) * Completed parameter documentation and wrote TODO as @todo and added an example use for mw.Api in the documentation. * Some other random whitespacing, line breaking, merged var statement, and moved them out of blocks (since JS doesn't have block scope) into the main function body for clarity. And some other random JS Lint/JS Hint stuff. * Added comment to api.titleblacklist module about the module not being in core but in the TitleBlacklist extension.
2011-12-21 23:52:37 +00:00
getTokenIfBad = function( code, result ) {
if ( code === 'badtoken' ) {
cachedToken = null; // force a new token
api.postWithEditToken( params, ok, err );
} else {
err( code, result );
}
};
return api.post( params, { ok : ok, err : getTokenIfBad });
}
},
[mediawiki.api] clean up * Adding return values to most of the ajax functions so that the jqXHR object (originally returned by jQuery.ajax) is available. Some functions documented they already did this, some don't. Now they all do and are also documented as such. * Renaming a few 'callback' arguments to 'success' to avoid confusion with 'error'. * Removed unused variables ** mw.Api's instance this.url was unused ** var cachedToken was unused in mediawiki.api.titleblacklist.js * Making closure argument order the same and referencing mediaWiki as a global (mw is something thought not to be a global but mediaWiki certainly is, no need to access window from the global scope and then the mediaWiki property of it). Also renamed any used of $j to $. Adding 'undefined' to the closure arguments where missing. * Re-written the mw.Api constructor's logic for options. Now keeping a defaultOptions privately "statically" cached outside the constructor and using that to build the options object. * Made all non-block comments the same comment style (some were /* */ or /* \n */) * Completed parameter documentation and wrote TODO as @todo and added an example use for mw.Api in the documentation. * Some other random whitespacing, line breaking, merged var statement, and moved them out of blocks (since JS doesn't have block scope) into the main function body for clarity. And some other random JS Lint/JS Hint stuff. * Added comment to api.titleblacklist module about the module not being in core but in the TitleBlacklist extension.
2011-12-21 23:52:37 +00:00
/**
* Api helper to grab an edit token
[mediawiki.api] clean up * Adding return values to most of the ajax functions so that the jqXHR object (originally returned by jQuery.ajax) is available. Some functions documented they already did this, some don't. Now they all do and are also documented as such. * Renaming a few 'callback' arguments to 'success' to avoid confusion with 'error'. * Removed unused variables ** mw.Api's instance this.url was unused ** var cachedToken was unused in mediawiki.api.titleblacklist.js * Making closure argument order the same and referencing mediaWiki as a global (mw is something thought not to be a global but mediaWiki certainly is, no need to access window from the global scope and then the mediaWiki property of it). Also renamed any used of $j to $. Adding 'undefined' to the closure arguments where missing. * Re-written the mw.Api constructor's logic for options. Now keeping a defaultOptions privately "statically" cached outside the constructor and using that to build the options object. * Made all non-block comments the same comment style (some were /* */ or /* \n */) * Completed parameter documentation and wrote TODO as @todo and added an example use for mw.Api in the documentation. * Some other random whitespacing, line breaking, merged var statement, and moved them out of blocks (since JS doesn't have block scope) into the main function body for clarity. And some other random JS Lint/JS Hint stuff. * Added comment to api.titleblacklist module about the module not being in core but in the TitleBlacklist extension.
2011-12-21 23:52:37 +00:00
*
* token callback has signature ( String token )
* error callback has signature ( String code, Object results, XmlHttpRequest xhr, Exception exception )
[mediawiki.api] clean up * Adding return values to most of the ajax functions so that the jqXHR object (originally returned by jQuery.ajax) is available. Some functions documented they already did this, some don't. Now they all do and are also documented as such. * Renaming a few 'callback' arguments to 'success' to avoid confusion with 'error'. * Removed unused variables ** mw.Api's instance this.url was unused ** var cachedToken was unused in mediawiki.api.titleblacklist.js * Making closure argument order the same and referencing mediaWiki as a global (mw is something thought not to be a global but mediaWiki certainly is, no need to access window from the global scope and then the mediaWiki property of it). Also renamed any used of $j to $. Adding 'undefined' to the closure arguments where missing. * Re-written the mw.Api constructor's logic for options. Now keeping a defaultOptions privately "statically" cached outside the constructor and using that to build the options object. * Made all non-block comments the same comment style (some were /* */ or /* \n */) * Completed parameter documentation and wrote TODO as @todo and added an example use for mw.Api in the documentation. * Some other random whitespacing, line breaking, merged var statement, and moved them out of blocks (since JS doesn't have block scope) into the main function body for clarity. And some other random JS Lint/JS Hint stuff. * Added comment to api.titleblacklist module about the module not being in core but in the TitleBlacklist extension.
2011-12-21 23:52:37 +00:00
* Note that xhr and exception are only available for 'http_*' errors
* code may be any http_* error code (see mw.Api), or 'token_missing'
*
[mediawiki.api] clean up * Adding return values to most of the ajax functions so that the jqXHR object (originally returned by jQuery.ajax) is available. Some functions documented they already did this, some don't. Now they all do and are also documented as such. * Renaming a few 'callback' arguments to 'success' to avoid confusion with 'error'. * Removed unused variables ** mw.Api's instance this.url was unused ** var cachedToken was unused in mediawiki.api.titleblacklist.js * Making closure argument order the same and referencing mediaWiki as a global (mw is something thought not to be a global but mediaWiki certainly is, no need to access window from the global scope and then the mediaWiki property of it). Also renamed any used of $j to $. Adding 'undefined' to the closure arguments where missing. * Re-written the mw.Api constructor's logic for options. Now keeping a defaultOptions privately "statically" cached outside the constructor and using that to build the options object. * Made all non-block comments the same comment style (some were /* */ or /* \n */) * Completed parameter documentation and wrote TODO as @todo and added an example use for mw.Api in the documentation. * Some other random whitespacing, line breaking, merged var statement, and moved them out of blocks (since JS doesn't have block scope) into the main function body for clarity. And some other random JS Lint/JS Hint stuff. * Added comment to api.titleblacklist module about the module not being in core but in the TitleBlacklist extension.
2011-12-21 23:52:37 +00:00
* @param tokenCallback {Function} received token callback
* @param err {Function} error callback
* @return {jqXHR}
*/
getEditToken: function( tokenCallback, err ) {
[mediawiki.api] clean up * Adding return values to most of the ajax functions so that the jqXHR object (originally returned by jQuery.ajax) is available. Some functions documented they already did this, some don't. Now they all do and are also documented as such. * Renaming a few 'callback' arguments to 'success' to avoid confusion with 'error'. * Removed unused variables ** mw.Api's instance this.url was unused ** var cachedToken was unused in mediawiki.api.titleblacklist.js * Making closure argument order the same and referencing mediaWiki as a global (mw is something thought not to be a global but mediaWiki certainly is, no need to access window from the global scope and then the mediaWiki property of it). Also renamed any used of $j to $. Adding 'undefined' to the closure arguments where missing. * Re-written the mw.Api constructor's logic for options. Now keeping a defaultOptions privately "statically" cached outside the constructor and using that to build the options object. * Made all non-block comments the same comment style (some were /* */ or /* \n */) * Completed parameter documentation and wrote TODO as @todo and added an example use for mw.Api in the documentation. * Some other random whitespacing, line breaking, merged var statement, and moved them out of blocks (since JS doesn't have block scope) into the main function body for clarity. And some other random JS Lint/JS Hint stuff. * Added comment to api.titleblacklist module about the module not being in core but in the TitleBlacklist extension.
2011-12-21 23:52:37 +00:00
var parameters = {
prop: 'info',
intoken: 'edit',
// we need some kind of dummy page to get a token from. This will return a response
// complaining that the page is missing, but we should also get an edit token
titles: 'DummyPageForEditToken'
},
ok = function( data ) {
var token;
$.each( data.query.pages, function( i, page ) {
if ( page.edittoken ) {
token = page.edittoken;
return false;
}
} );
if ( token !== undefined ) {
cachedToken = token;
tokenCallback( token );
} else {
err( 'token-missing', data );
}
[mediawiki.api] clean up * Adding return values to most of the ajax functions so that the jqXHR object (originally returned by jQuery.ajax) is available. Some functions documented they already did this, some don't. Now they all do and are also documented as such. * Renaming a few 'callback' arguments to 'success' to avoid confusion with 'error'. * Removed unused variables ** mw.Api's instance this.url was unused ** var cachedToken was unused in mediawiki.api.titleblacklist.js * Making closure argument order the same and referencing mediaWiki as a global (mw is something thought not to be a global but mediaWiki certainly is, no need to access window from the global scope and then the mediaWiki property of it). Also renamed any used of $j to $. Adding 'undefined' to the closure arguments where missing. * Re-written the mw.Api constructor's logic for options. Now keeping a defaultOptions privately "statically" cached outside the constructor and using that to build the options object. * Made all non-block comments the same comment style (some were /* */ or /* \n */) * Completed parameter documentation and wrote TODO as @todo and added an example use for mw.Api in the documentation. * Some other random whitespacing, line breaking, merged var statement, and moved them out of blocks (since JS doesn't have block scope) into the main function body for clarity. And some other random JS Lint/JS Hint stuff. * Added comment to api.titleblacklist module about the module not being in core but in the TitleBlacklist extension.
2011-12-21 23:52:37 +00:00
},
ajaxOptions = {
ok: ok,
err: err,
// Due to the API assuming we're logged out if we pass the callback-parameter,
// we have to disable jQuery's callback system, and instead parse JSON string,
// by setting 'jsonp' to false.
jsonp: false
};
[mediawiki.api] clean up * Adding return values to most of the ajax functions so that the jqXHR object (originally returned by jQuery.ajax) is available. Some functions documented they already did this, some don't. Now they all do and are also documented as such. * Renaming a few 'callback' arguments to 'success' to avoid confusion with 'error'. * Removed unused variables ** mw.Api's instance this.url was unused ** var cachedToken was unused in mediawiki.api.titleblacklist.js * Making closure argument order the same and referencing mediaWiki as a global (mw is something thought not to be a global but mediaWiki certainly is, no need to access window from the global scope and then the mediaWiki property of it). Also renamed any used of $j to $. Adding 'undefined' to the closure arguments where missing. * Re-written the mw.Api constructor's logic for options. Now keeping a defaultOptions privately "statically" cached outside the constructor and using that to build the options object. * Made all non-block comments the same comment style (some were /* */ or /* \n */) * Completed parameter documentation and wrote TODO as @todo and added an example use for mw.Api in the documentation. * Some other random whitespacing, line breaking, merged var statement, and moved them out of blocks (since JS doesn't have block scope) into the main function body for clarity. And some other random JS Lint/JS Hint stuff. * Added comment to api.titleblacklist module about the module not being in core but in the TitleBlacklist extension.
2011-12-21 23:52:37 +00:00
return this.get( parameters, ajaxOptions );
},
/**
* Create a new section of the page.
[mediawiki.api] clean up * Adding return values to most of the ajax functions so that the jqXHR object (originally returned by jQuery.ajax) is available. Some functions documented they already did this, some don't. Now they all do and are also documented as such. * Renaming a few 'callback' arguments to 'success' to avoid confusion with 'error'. * Removed unused variables ** mw.Api's instance this.url was unused ** var cachedToken was unused in mediawiki.api.titleblacklist.js * Making closure argument order the same and referencing mediaWiki as a global (mw is something thought not to be a global but mediaWiki certainly is, no need to access window from the global scope and then the mediaWiki property of it). Also renamed any used of $j to $. Adding 'undefined' to the closure arguments where missing. * Re-written the mw.Api constructor's logic for options. Now keeping a defaultOptions privately "statically" cached outside the constructor and using that to build the options object. * Made all non-block comments the same comment style (some were /* */ or /* \n */) * Completed parameter documentation and wrote TODO as @todo and added an example use for mw.Api in the documentation. * Some other random whitespacing, line breaking, merged var statement, and moved them out of blocks (since JS doesn't have block scope) into the main function body for clarity. And some other random JS Lint/JS Hint stuff. * Added comment to api.titleblacklist module about the module not being in core but in the TitleBlacklist extension.
2011-12-21 23:52:37 +00:00
* @param title {mw.Title|String} target page
* @param header {String}
* @param message {String} wikitext message
* @param ok {Function} success handler
* @param err {Function} error handler
* @return {jqXHR}
*/
newSection: function( title, header, message, ok, err ) {
var params = {
action: 'edit',
section: 'new',
format: 'json',
title: title.toString(),
summary: header,
text: message
};
[mediawiki.api] clean up * Adding return values to most of the ajax functions so that the jqXHR object (originally returned by jQuery.ajax) is available. Some functions documented they already did this, some don't. Now they all do and are also documented as such. * Renaming a few 'callback' arguments to 'success' to avoid confusion with 'error'. * Removed unused variables ** mw.Api's instance this.url was unused ** var cachedToken was unused in mediawiki.api.titleblacklist.js * Making closure argument order the same and referencing mediaWiki as a global (mw is something thought not to be a global but mediaWiki certainly is, no need to access window from the global scope and then the mediaWiki property of it). Also renamed any used of $j to $. Adding 'undefined' to the closure arguments where missing. * Re-written the mw.Api constructor's logic for options. Now keeping a defaultOptions privately "statically" cached outside the constructor and using that to build the options object. * Made all non-block comments the same comment style (some were /* */ or /* \n */) * Completed parameter documentation and wrote TODO as @todo and added an example use for mw.Api in the documentation. * Some other random whitespacing, line breaking, merged var statement, and moved them out of blocks (since JS doesn't have block scope) into the main function body for clarity. And some other random JS Lint/JS Hint stuff. * Added comment to api.titleblacklist module about the module not being in core but in the TitleBlacklist extension.
2011-12-21 23:52:37 +00:00
return this.postWithEditToken( params, ok, err );
}
[mediawiki.api] clean up * Adding return values to most of the ajax functions so that the jqXHR object (originally returned by jQuery.ajax) is available. Some functions documented they already did this, some don't. Now they all do and are also documented as such. * Renaming a few 'callback' arguments to 'success' to avoid confusion with 'error'. * Removed unused variables ** mw.Api's instance this.url was unused ** var cachedToken was unused in mediawiki.api.titleblacklist.js * Making closure argument order the same and referencing mediaWiki as a global (mw is something thought not to be a global but mediaWiki certainly is, no need to access window from the global scope and then the mediaWiki property of it). Also renamed any used of $j to $. Adding 'undefined' to the closure arguments where missing. * Re-written the mw.Api constructor's logic for options. Now keeping a defaultOptions privately "statically" cached outside the constructor and using that to build the options object. * Made all non-block comments the same comment style (some were /* */ or /* \n */) * Completed parameter documentation and wrote TODO as @todo and added an example use for mw.Api in the documentation. * Some other random whitespacing, line breaking, merged var statement, and moved them out of blocks (since JS doesn't have block scope) into the main function body for clarity. And some other random JS Lint/JS Hint stuff. * Added comment to api.titleblacklist module about the module not being in core but in the TitleBlacklist extension.
2011-12-21 23:52:37 +00:00
} );
[mediawiki.api] clean up * Adding return values to most of the ajax functions so that the jqXHR object (originally returned by jQuery.ajax) is available. Some functions documented they already did this, some don't. Now they all do and are also documented as such. * Renaming a few 'callback' arguments to 'success' to avoid confusion with 'error'. * Removed unused variables ** mw.Api's instance this.url was unused ** var cachedToken was unused in mediawiki.api.titleblacklist.js * Making closure argument order the same and referencing mediaWiki as a global (mw is something thought not to be a global but mediaWiki certainly is, no need to access window from the global scope and then the mediaWiki property of it). Also renamed any used of $j to $. Adding 'undefined' to the closure arguments where missing. * Re-written the mw.Api constructor's logic for options. Now keeping a defaultOptions privately "statically" cached outside the constructor and using that to build the options object. * Made all non-block comments the same comment style (some were /* */ or /* \n */) * Completed parameter documentation and wrote TODO as @todo and added an example use for mw.Api in the documentation. * Some other random whitespacing, line breaking, merged var statement, and moved them out of blocks (since JS doesn't have block scope) into the main function body for clarity. And some other random JS Lint/JS Hint stuff. * Added comment to api.titleblacklist module about the module not being in core but in the TitleBlacklist extension.
2011-12-21 23:52:37 +00:00
} )( jQuery, mediaWiki );