Clean up ULS localstorage preference saving system

These changes affect anonymous users:
* Old code to restore preferences from jStorage removed
* No cookie used anymore

Bug: T100639
Change-Id: I3cfec447703d9c67cd2310ec4acc5692ad76be8e
This commit is contained in:
Santhosh Thottingal
2016-04-11 10:24:59 +05:30
committed by Niklas Laxström
parent 6733a951c1
commit 3e58259ca7

View File

@@ -41,12 +41,10 @@
if ( typeof value === 'object' ) {
value = JSON.stringify( value );
}
// Set the store
try {
localStorage.setItem( key, value );
} catch ( e ) { // Use cookie
$.cookie( key, value, { path: '/' } );
}
} catch ( e ) {}
},
/*
* Returns the value of the given key
@@ -56,29 +54,9 @@
get: function ( key ) {
var data;
// No value supplied, return value
try {
data = localStorage.getItem( key );
if ( !data ) {
// Try to restore the old preferences, if any, if possible.
try {
data = JSON.parse( localStorage.getItem( 'jStorage' ) )[ 'uls-preferences' ];
// And try to remove it.
localStorage.removeItem( 'jStorage' );
} catch ( e ) {
// Don't bother about it.
}
}
} catch ( e ) { // Use cookie
data = $.cookie( key );
}
// Try to parse JSON
try {
data = JSON.parse( data );
} catch ( e ) {
data = data;
}
data = JSON.parse( localStorage.getItem( key ) );
} catch ( e ) {}
return data;
}