diff options
author | Jean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com> | 2014-07-02 11:41:02 +0200 |
---|---|---|
committer | Jean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com> | 2014-07-02 11:41:09 +0200 |
commit | 34307c05aaa740f2759152780cf9e735be32fa8a (patch) | |
tree | 8405aa75ca78e2c263c5f6033a07edac9d5cf64b /sonar-server/src | |
parent | 61d46832513df5ab8a5671e9c01d4c053448a997 (diff) | |
download | sonarqube-34307c05aaa740f2759152780cf9e735be32fa8a.tar.gz sonarqube-34307c05aaa740f2759152780cf9e735be32fa8a.zip |
SONAR-5334 Fix performance issue with localStorage on Safari
Diffstat (limited to 'sonar-server/src')
-rw-r--r-- | sonar-server/src/main/js/translate.js | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/sonar-server/src/main/js/translate.js b/sonar-server/src/main/js/translate.js index 8dc0ba93921..0681b727d46 100644 --- a/sonar-server/src/main/js/translate.js +++ b/sonar-server/src/main/js/translate.js @@ -94,22 +94,19 @@ dataType: 'json', statusCode: { 304: function() { - // NOP, use cached messages + window.messages = JSON.parse(localStorage.getItem('l10n.bundle')); } } }).done(function(bundle) { - bundleTimestamp = new Date().toISOString(); - bundleTimestamp = bundleTimestamp.substr(0, bundleTimestamp.indexOf('.')) + '+0000'; - localStorage.setItem('l10n.timestamp', bundleTimestamp); - localStorage.setItem('l10n.locale', currentLocale); + if(bundle !== undefined) { + bundleTimestamp = new Date().toISOString(); + bundleTimestamp = bundleTimestamp.substr(0, bundleTimestamp.indexOf('.')) + '+0000'; + localStorage.setItem('l10n.timestamp', bundleTimestamp); + localStorage.setItem('l10n.locale', currentLocale); - for (var message in bundle) { - if (bundle.hasOwnProperty(message)) { - var storageKey = 'l10n.' + message; - localStorage.setItem(storageKey, bundle[message]); - } + window.messages = bundle; + localStorage.setItem('l10n.bundle', JSON.stringify(bundle)); } }); }; - })(); |