summaryrefslogtreecommitdiff
path: root/resources/src/mediawiki/mediawiki.user.js
diff options
context:
space:
mode:
Diffstat (limited to 'resources/src/mediawiki/mediawiki.user.js')
-rw-r--r--resources/src/mediawiki/mediawiki.user.js34
1 files changed, 17 insertions, 17 deletions
diff --git a/resources/src/mediawiki/mediawiki.user.js b/resources/src/mediawiki/mediawiki.user.js
index 817c856c..b4baa66c 100644
--- a/resources/src/mediawiki/mediawiki.user.js
+++ b/resources/src/mediawiki/mediawiki.user.js
@@ -16,7 +16,7 @@
*/
function getUserInfo( info ) {
var api;
- if ( !deferreds[info] ) {
+ if ( !deferreds[ info ] ) {
deferreds.rights = $.Deferred();
deferreds.groups = $.Deferred();
@@ -38,13 +38,13 @@
}
- return deferreds[info].promise();
+ return deferreds[ info ].promise();
}
// Map from numbers 0-255 to a hex string (with padding)
for ( i = 0; i < 256; i++ ) {
// Padding: Add a full byte (0x100, 256) and strip the extra character
- byteToHex[i] = ( i + 256 ).toString( 16 ).slice( 1 );
+ byteToHex[ i ] = ( i + 256 ).toString( 16 ).slice( 1 );
}
// mw.user with the properties options and tokens gets defined in mediawiki.js.
@@ -89,12 +89,12 @@
if ( ( i & 3 ) === 0 ) {
r = Math.random() * 0x100000000;
}
- rnds[i] = r >>> ( ( i & 3 ) << 3 ) & 255;
+ rnds[ i ] = r >>> ( ( i & 3 ) << 3 ) & 255;
}
}
// Convert from number to hex
for ( i = 0; i < 8; i++ ) {
- hexRnds[i] = byteToHex[rnds[i]];
+ hexRnds[ i ] = byteToHex[ rnds[ i ] ];
}
// Concatenation of two random integers with entrophy n and m
@@ -159,10 +159,10 @@
* @return {string} Random session ID
*/
sessionId: function () {
- var sessionId = $.cookie( 'mediaWiki.user.sessionId' );
- if ( sessionId === undefined || sessionId === null ) {
+ var sessionId = mw.cookie.get( 'mwuser-sessionId' );
+ if ( sessionId === null ) {
sessionId = mw.user.generateRandomSessionId();
- $.cookie( 'mediaWiki.user.sessionId', sessionId, { expires: null, path: '/' } );
+ mw.cookie.set( 'mwuser-sessionId', sessionId, { expires: null } );
}
return sessionId;
},
@@ -208,14 +208,14 @@
expires: 30
}, options || {} );
- cookie = $.cookie( 'mediaWiki.user.bucket:' + key );
+ cookie = mw.cookie.get( 'mwuser-bucket:' + key );
// Bucket information is stored as 2 integers, together as version:bucket like: "1:2"
if ( typeof cookie === 'string' && cookie.length > 2 && cookie.indexOf( ':' ) !== -1 ) {
parts = cookie.split( ':' );
- if ( parts.length > 1 && Number( parts[0] ) === options.version ) {
- version = Number( parts[0] );
- bucket = String( parts[1] );
+ if ( parts.length > 1 && Number( parts[ 0 ] ) === options.version ) {
+ version = Number( parts[ 0 ] );
+ bucket = String( parts[ 1 ] );
}
}
@@ -229,7 +229,7 @@
// Find range
range = 0;
for ( k in options.buckets ) {
- range += options.buckets[k];
+ range += options.buckets[ k ];
}
// Select random value within range
@@ -239,16 +239,16 @@
total = 0;
for ( k in options.buckets ) {
bucket = k;
- total += options.buckets[k];
+ total += options.buckets[ k ];
if ( total >= rand ) {
break;
}
}
- $.cookie(
- 'mediaWiki.user.bucket:' + key,
+ mw.cookie.set(
+ 'mwuser-bucket:' + key,
version + ':' + bucket,
- { path: '/', expires: Number( options.expires ) }
+ { expires: Number( options.expires ) * 86400 }
);
}