*
* @private
* @param {string} info One of 'groups' or 'rights'
- * @param {Function} [callback]
* @return {jQuery.Promise}
*/
- function getUserInfo( info, callback ) {
+ function getUserInfo( info ) {
var api;
if ( !deferreds[info] ) {
}
- return deferreds[info].done( callback ).promise();
+ return deferreds[info].promise();
}
mw.user = user = {
seed = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
for ( i = 0; i < 32; i++ ) {
r = Math.floor( Math.random() * seed.length );
- id += seed.substring( r, r + 1 );
+ id += seed.charAt( r );
}
return id;
},
return mw.config.get( 'wgUserName' );
},
- /**
- * @inheritdoc #getName
- * @deprecated since 1.20 Use #getName instead
- */
- name: function () {
- return user.getName();
- },
-
/**
* Get date user registered, if available
*
return user.getName() === null;
},
- /**
- * @inheritdoc #isAnon
- * @deprecated since 1.20 Use #isAnon instead
- */
- anonymous: function () {
- return user.isAnon();
- },
-
/**
* Get an automatically generated random ID (stored in a session cookie)
*
* @return {jQuery.Promise}
*/
getGroups: function ( callback ) {
- return getUserInfo( 'groups', callback );
+ return getUserInfo( 'groups' ).done( callback );
},
/**
* @return {jQuery.Promise}
*/
getRights: function ( callback ) {
- return getUserInfo( 'rights', callback );
+ return getUserInfo( 'rights' ).done( callback );
}
};
+ /**
+ * @method name
+ * @inheritdoc #getName
+ * @deprecated since 1.20 Use #getName instead
+ */
+ mw.log.deprecate( user, 'name', user.getName, 'Use mw.user.getName instead.' );
+
+ /**
+ * @method anonymous
+ * @inheritdoc #isAnon
+ * @deprecated since 1.20 Use #isAnon instead
+ */
+ mw.log.deprecate( user, 'anonymous', user.isAnon, 'Use mw.user.isAnon instead.' );
+
}( mediaWiki, jQuery ) );