* Html-escaping unescaped message in summaryHolder
* Check for errors in the API response
* Pass true for existence of redirect origin and value of 'exists' for target (instead of backwards)
* Comment fixes
'ajax-category-already-present' => 'This page already belongs to the category "$1"',
'ajax-category-hook-error' => 'A local function prevented the changes from being saved.',
'ajax-api-error' => 'The API returned an error: $1: $2.',
'ajax-category-already-present' => 'This page already belongs to the category "$1"',
'ajax-category-hook-error' => 'A local function prevented the changes from being saved.',
'ajax-api-error' => 'The API returned an error: $1: $2.',
+'ajax-api-unknown-error' => 'The API returned an unknown error.',
'ajax-category-already-present',
'ajax-category-hook-error',
'ajax-api-error',
'ajax-category-already-present',
'ajax-category-hook-error',
'ajax-api-error',
+ 'ajax-api-unknown-error',
'ajax-category-already-present',
'ajax-category-hook-error',
'ajax-api-error',
'ajax-category-already-present',
'ajax-category-hook-error',
'ajax-api-error',
+ 'ajax-api-unknown-error',
),
),
'mediawiki.page.ajaxCategories.init' => array(
),
),
'mediawiki.page.ajaxCategories.init' => array(
var redirect = json.query.redirects,
exists = !json.query.pages[-1];
var redirect = json.query.redirects,
exists = !json.query.pages[-1];
- // Register existence
- mw.Title.exist.set( catTitle.toString(), exists );
-
+ // If it's a redirect 'exists' is for the target, not the origin
- catTitle = new mw.Title( redirect[0].to ).getMainText();
- // Redirect existence as well (non-existant pages can't be redirects)
+ // Register existance of redirect origin as well,
+ // a non-existent page can't be a redirect.
mw.Title.exist.set( catTitle.toString(), true );
mw.Title.exist.set( catTitle.toString(), true );
+
+ // Override title with the redirect target
+ catTitle = new mw.Title( redirect[0].to ).getMainText();
+
+ // Register existence
+ mw.Title.exist.set( catTitle.toString(), exists );
+
callback( catTitle );
} );
},
callback( catTitle );
} );
},
$link.data( {
saveButton: data.saveButton,
deleteButton: data.deleteButton,
$link.data( {
saveButton: data.saveButton,
deleteButton: data.deleteButton,
$.post(
mw.util.wikiScript( 'api' ),
getTokenVars,
$.post(
mw.util.wikiScript( 'api' ),
getTokenVars,
- function( reply ) {
- var infos = reply.query.pages;
+ function( json ) {
+ if ( 'error' in json ) {
+ ajaxcat.showError( mw.msg( 'ajax-api-error', json.error.code, json.error.info ) );
+ return;
+ } else if ( json.query && json.query.pages ) {
+ var infos = json.query.pages;
+ } else {
+ ajaxcat.showError( mw.msg( 'ajax-api-unknown-error' ) );
+ return;
+ }
+
$.each( infos, function( pageid, data ) {
var token = data.edittoken,
timestamp = data.revisions[0].timestamp,
$.each( infos, function( pageid, data ) {
var token = data.edittoken,
timestamp = data.revisions[0].timestamp,
*
* @param props {Object}:
* - modFn {Function} text-modifying function
*
* @param props {Object}:
* - modFn {Function} text-modifying function
- * - dialogDescription {String} Changes done (HTML in the dialog)
- * - editSummary {String} Changes done (text for edit summary)
+ * - dialogDescription {String} Changes done (HTML for in the dialog, escape before hand if needed)
+ * - editSummary {String} Changes done (text for the edit summary)
* - doneFn {Function} callback after everything is done
* - $link {jQuery}
* - action
* - doneFn {Function} callback after everything is done
* - $link {jQuery}
* - action
// Summary of the action to be taken
summaryHolder = $( '<p>' )
// Summary of the action to be taken
summaryHolder = $( '<p>' )
- .html( '<strong>' + mw.msg( 'ajax-category-question' ) + '</strong><br/>' + props.dialogDescription );
+ .html( '<strong>' + mw.message( 'ajax-category-question' ).escaped() + '</strong><br/>' + props.dialogDescription );
// Reason textbox.
reasonBox = $( '<input type="text" size="45"></input>' )
// Reason textbox.
reasonBox = $( '<input type="text" size="45"></input>' )