From bd508e5937050a61ef3cb913b5f8f318fba9805b Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Tue, 7 Oct 2014 13:52:27 +0400 Subject: [PATCH] Added disabled local storage workaround --- app/js/lib/config.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/app/js/lib/config.js b/app/js/lib/config.js index 45eb7f10..6f52f8e3 100644 --- a/app/js/lib/config.js +++ b/app/js/lib/config.js @@ -125,6 +125,7 @@ Config.LangCountries = {"es": "ES", "ru": "RU", "en": "US", "de": "DE", "it": "I callback = keys.pop(), result = [], single = keys.length == 1, + value, allFound = true, prefix = storageGetPrefix(), i, key; @@ -135,7 +136,11 @@ Config.LangCountries = {"es": "ES", "ru": "RU", "en": "US", "de": "DE", "it": "I result.push(cache[key]); } else if (useLs) { - var value = localStorage.getItem(key); + try { + value = localStorage.getItem(key); + } catch (e) { + useLs = false; + } try { value = (value === undefined || value === null) ? false : JSON.parse(value); } catch (e) { @@ -181,7 +186,11 @@ Config.LangCountries = {"es": "ES", "ru": "RU", "en": "US", "de": "DE", "it": "I cache[key] = value; value = JSON.stringify(value); if (useLs) { - localStorage.setItem(key, value); + try { + localStorage.setItem(key, value); + } catch (e) { + useLs = false; + } } else { keyValues[key] = value; } @@ -211,7 +220,11 @@ Config.LangCountries = {"es": "ES", "ru": "RU", "en": "US", "de": "DE", "it": "I key = keys[i] = prefix + keys[i]; delete cache[key]; if (useLs) { - localStorage.removeItem(key); + try { + localStorage.removeItem(key); + } catch (e) { + useLs = false; + } } } if (useCs) {