X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=resources%2Fsrc%2Fmediawiki%2Fmediawiki.user.js;h=5fc19907588dd388d1f72449b5d84fb2dd09d2a3;hb=23d487ce81a479b44b95cb5ec5066e79fcd64978;hp=65e9e4168d5ced31473a18ea1ae816c046f3e1e9;hpb=54a7efa8abf133bf44e0b042ed12b4b8a68dc444;p=lhc%2Fweb%2Fwiklou.git diff --git a/resources/src/mediawiki/mediawiki.user.js b/resources/src/mediawiki/mediawiki.user.js index 65e9e4168d..5fc1990758 100644 --- a/resources/src/mediawiki/mediawiki.user.js +++ b/resources/src/mediawiki/mediawiki.user.js @@ -4,7 +4,7 @@ */ /* global Uint32Array */ ( function ( mw, $ ) { - var userInfoPromise; + var userInfoPromise, stickyRandomSessionId; /** * Get the current user's groups or rights @@ -48,7 +48,7 @@ // Support: IE 11 crypto = window.crypto || window.msCrypto; - if ( crypto && crypto.getRandomValues ) { + if ( crypto && crypto.getRandomValues && typeof Uint32Array === 'function' ) { // Fill an array with 2 random values, each of which is 32 bits. // Note that Uint32Array is array-like but does not implement Array. rnds = new Uint32Array( 2 ); @@ -71,6 +71,20 @@ return hexRnds.join( '' ); }, + /** + * A sticky generateRandomSessionId for the current JS execution context, + * cached within this class. + * + * @return {string} 64 bit integer in hex format, padded + */ + stickyRandomId: function () { + if ( !stickyRandomSessionId ) { + stickyRandomSessionId = mw.user.generateRandomSessionId(); + } + + return stickyRandomSessionId; + }, + /** * Get the current user's database id *