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

106 lines
2.8 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 categories.
*/
[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
$.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
* Determine if a category exists.
* @param title {mw.Title}
* @param success {Function} callback to pass boolean of category's existence
* @param err {Function} optional callback to run if api error
* @return ajax call object
*/
[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
isCategory: function( title, success, err ) {
var params = {
[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
prop: 'categoryinfo',
titles: title.toString()
},
ok = function( data ) {
var exists = false;
if ( data.query && data.query.pages ) {
$.each( data.query.pages, function( id, page ) {
if ( page.categoryinfo ) {
exists = true;
}
} );
}
success( exists );
};
return this.get( params, { ok: ok, err: 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
* Get a list of categories that match a certain prefix.
* e.g. given "Foo", return "Food", "Foolish people", "Foosball tables" ...
[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 prefix {String} prefix to match
* @param success {Function} callback to pass matched categories to
* @param err {Function} optional callback to run if api error
* @return {jqXHR}
*/
[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
getCategoriesByPrefix: function( prefix, success, err ) {
// fetch with allpages to only get categories that have a corresponding description page.
var params = {
'list': 'allpages',
'apprefix': prefix,
'apnamespace': mw.config.get('wgNamespaceIds').category
};
var ok = function( data ) {
var texts = [];
[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
if ( data.query && data.query.allpages ) {
$.each( data.query.allpages, function( i, category ) {
[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
texts.push( new mw.Title( category.title ).getNameText() );
} );
}
[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
success( texts );
};
return this.get( params, { ok: ok, err: err } );
},
/**
* Get the categories that a particular page on the wiki belongs to
[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}
* @param success {Function} callback to pass categories to (or false, if title not found)
* @param err {Function} optional callback to run if api error
* @param async {Boolean} optional asynchronousness (default = true = async)
* @return {jqXHR}
*/
[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
getCategories: function( title, success, err, async ) {
var params, ok;
params = {
prop: 'categories',
titles: title.toString()
};
if ( async === undefined ) {
async = true;
}
[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
ok = function( data ) {
var ret = false;
if ( data.query && data.query.pages ) {
$.each( data.query.pages, function( id, page ) {
if ( page.categories ) {
[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
if ( typeof ret !== 'object' ) {
ret = [];
}
[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
$.each( page.categories, function( i, cat ) {
ret.push( new mw.Title( cat.title ) );
} );
}
} );
}
[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
success( ret );
};
return this.get( params, { ok: ok, err: err, async: async } );
}
} );
[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 );