Skin: Only load jquery.makeCollapsible if needed
[lhc/web/wiklou.git] / resources / src / mediawiki / mediawiki.user.blockcookie.js
1 ( function ( mw ) {
2
3 // If a user has been autoblocked, a cookie is set.
4 // Its value is replicated here in localStorage to guard against cookie-removal.
5 // This module will only be loaded when $wgCookieSetOnAutoblock is true.
6 // Ref: https://phabricator.wikimedia.org/T5233
7
8 if ( !mw.cookie.get( 'BlockID' ) && mw.storage.get( 'blockID' ) ) {
9 // The block ID exists in storage, but not in the cookie.
10 mw.cookie.set( 'BlockID', mw.storage.get( 'blockID' ) );
11
12 } else if ( parseInt( mw.cookie.get( 'BlockID' ), 10 ) > 0 && !mw.storage.get( 'blockID' ) ) {
13 // The block ID exists in the cookie, but not in storage.
14 // (When a block expires the cookie remains but its value is '', hence the integer check above.)
15 mw.storage.set( 'blockID', mw.cookie.get( 'BlockID' ) );
16
17 } else if ( mw.cookie.get( 'BlockID' ) === '' && mw.storage.get( 'blockID' ) ) {
18 // If only the empty string is in the cookie, remove the storage value. The block is no longer valid.
19 mw.storage.remove( 'blockID' );
20
21 }
22
23 }( mediaWiki ) );