* Implementation for mediaWiki.user
*/
-( function ( $ ) {
+( function ( mw, $ ) {
/**
* User object
id = generateId();
}
// Set cookie if not set, or renew it if already set
- $.cookie( 'mediaWiki.user.id', id, { 'expires': 365, 'path': '/' } );
+ $.cookie( 'mediaWiki.user.id', id, {
+ expires: 365,
+ path: '/'
+ } );
return id;
};
* 'expires': 7
* } );
*/
- this.bucket = function( key, options ) {
+ this.bucket = function ( key, options ) {
options = $.extend( {
'buckets': {},
'version': 0,
// Bucket information is stored as 2 integers, together as version:bucket like: "1:2"
if ( typeof cookie === 'string' && cookie.length > 2 && cookie.indexOf( ':' ) > 0 ) {
var parts = cookie.split( ':' );
- if ( parts.length > 1 && parts[0] == options.version ) {
+ if ( parts.length > 1 && Number( parts[0] ) === options.version ) {
version = Number( parts[0] );
bucket = String( parts[1] );
}
}
}
if ( options.tracked ) {
- mw.loader.using( 'jquery.clickTracking', function() {
+ mw.loader.using( 'jquery.clickTracking', function () {
$.trackAction(
'mediaWiki.user.bucket:' + key + '@' + version + ':' + bucket
);
// This is kind of ugly but we're stuck with this for b/c reasons
mw.user = new User( mw.user.options, mw.user.tokens );
-}( jQuery ) );
+}( mediaWiki, jQuery ) );