diff options
author | Thomas Bruederli <thomas@roundcube.net> | 2013-11-23 16:59:32 +0100 |
---|---|---|
committer | Thomas Bruederli <thomas@roundcube.net> | 2013-11-23 16:59:32 +0100 |
commit | 078679843852e8531f907bafbab275a521dbb5e5 (patch) | |
tree | 9db66f9d98ece802f5810896716f6fce614b00f3 /program/js/app.js | |
parent | 8c5f4055873e171bd4abcd0dfe56a7b3a01f733a (diff) |
Make local storage functions work before rcmail.init() was called
Diffstat (limited to 'program/js/app.js')
-rw-r--r-- | program/js/app.js | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/program/js/app.js b/program/js/app.js index c9d0ab955..ac06df6d6 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -187,8 +187,6 @@ function rcube_webmail() if (this.env.permaurl) this.enable_command('permaurl', 'extwin', true); - this.local_storage_prefix = 'roundcube.' + (this.env.user_id || 'anonymous') + '.'; - switch (this.task) { case 'mail': @@ -7447,11 +7445,20 @@ function rcube_webmail() setCookie(name, value, expires, this.env.cookie_path, this.env.cookie_domain, this.env.cookie_secure); }; + this.get_local_storage_prefix = function() + { + if (!this.local_storage_prefix) + this.local_storage_prefix = 'roundcube.' + (this.env.user_id || 'anonymous') + '.'; + + return this.local_storage_prefix; + }; + // wrapper for localStorage.getItem(key) this.local_storage_get_item = function(key, deflt, encrypted) { + // TODO: add encryption - var item = localStorage.getItem(this.local_storage_prefix + key); + var item = localStorage.getItem(this.get_local_storage_prefix() + key); return item !== null ? JSON.parse(item) : (deflt || null); }; @@ -7459,13 +7466,13 @@ function rcube_webmail() this.local_storage_set_item = function(key, data, encrypted) { // TODO: add encryption - return localStorage.setItem(this.local_storage_prefix + key, JSON.stringify(data)); + return localStorage.setItem(this.get_local_storage_prefix() + key, JSON.stringify(data)); }; // wrapper for localStorage.removeItem(key) this.local_storage_remove_item = function(key) { - return localStorage.removeItem(this.local_storage_prefix + key); + return localStorage.removeItem(this.get_local_storage_prefix() + key); }; } // end object rcube_webmail |