Use localstorage instead of cookie for previous language autonym

Change-Id: I1025a8bbb9fad0cfd326547a09c982925a55e55d
This commit is contained in:
Santhosh Thottingal
2016-04-12 11:33:36 +05:30
committed by Niklas Laxström
parent 4ff9e44529
commit 7d90ecef1d
2 changed files with 14 additions and 10 deletions

View File

@@ -20,6 +20,8 @@
( function ( $, mw ) {
'use strict';
var previousLanguageAutonymStorageKey = 'uls-previous-language-autonym';
/**
* Construct the display settings link
*
@@ -176,9 +178,12 @@
* @return {jQuery.Promise}
*/
function getUndoAutonym( code ) {
var
deferred = $.Deferred(),
autonym = $.cookie( mw.uls.previousLanguageAutonymCookie );
var autonym,
deferred = $.Deferred();
try {
autonym = localStorage.getItem( previousLanguageAutonymStorageKey );
} catch ( e ) {}
if ( autonym ) {
mw.loader.using( 'jquery.tipsy', function () {
@@ -313,14 +318,14 @@
} );
// Now that we set the previous languages,
// we can set the cookie of the previous autonym.
// we can store the previous autonym.
// TODO: Refactor this, because it doesn't directly belong
// to the tooltip.
$.cookie( mw.uls.previousLanguageAutonymCookie,
mw.config.get( 'wgULSCurrentAutonym' ), {
path: '/'
}
);
try {
localStorage.setItem(
previousLanguageAutonymStorageKey, mw.config.get( 'wgULSCurrentAutonym' )
);
} catch ( e ) {}
}
function initInterface() {