dont try to access localStorage directly

This commit is contained in:
j 2013-03-22 09:54:49 +00:00
parent 8bcb904a08
commit 4c8b628584

View file

@ -30,17 +30,23 @@ appPanel
}); });
} catch(e) {} } catch(e) {}
}; };
function getLocalStorage(key) {
//fails if localStorage does not exist or
//if third party cookies are disabled
try {
return localStorage['pandora.enableDebugMode'];
} catch(e) {}
}
var animationInterval, var animationInterval,
enableDebugMode = localStorage && localStorage['pandora.enableDebugMode'], enableDebugMode = getLocalStorage('pandora.enableDebugMode'),
enableEventLogging = localStorage && localStorage['pandora.enableEventLogging'], enableEventLogging = getLocalStorage('pandora.enableEventLogging'),
isEmbed = /^#\?/.test(document.location.hash) isEmbed = /^#\?/.test(document.location.hash)
&& /embed=true/.test(document.location.hash), && /embed=true/.test(document.location.hash),
isMSIE = /MSIE/.test(navigator.userAgent), isMSIE = /MSIE/.test(navigator.userAgent),
isPrint = /^#\?/.test(document.location.hash) isPrint = /^#\?/.test(document.location.hash)
&& /print=true/.test(document.location.hash), && /print=true/.test(document.location.hash),
legacyThemes = {classic: 'oxlight', modern: 'oxdark'}, legacyThemes = {classic: 'oxlight', modern: 'oxdark'},
theme = localStorage && localStorage['Ox.theme'] theme = getLocalStorage('Ox.theme')
&& JSON.parse(localStorage['Ox.theme']) || 'oxmedium'; && JSON.parse(localStorage['Ox.theme']) || 'oxmedium';
theme = legacyThemes[theme] || theme; theme = legacyThemes[theme] || theme;
@ -347,7 +353,7 @@ appPanel
} }
}); });
pandora.site.sectionButtonsWidth = pandora.$ui.sectionButtons.width() + 8; pandora.site.sectionButtonsWidth = pandora.$ui.sectionButtons.width() + 8;
if (localStorage && localStorage['pandora.onload']) { if (getLocalStorage('pandora.onload')) {
try { try {
eval(localStorage['pandora.onload']) eval(localStorage['pandora.onload'])
} catch(e) {} } catch(e) {}