diff options
author | Andrew Dolgov <[email protected]> | 2018-12-03 15:46:54 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2018-12-03 15:46:54 +0300 |
commit | 4cb3a601a0fbeb0bf98c932bd5af8a3cffa8ab64 (patch) | |
tree | ed3dae8894591be12287b3cce3ff5b4cc6d1ce0e /js/ArticleCache.js | |
parent | cd0a39ea4cb7137aef5b225bdc4472d207a48e62 (diff) | |
parent | 98986ce066764158c045c3e23b69e98183b94236 (diff) |
Merge branch 'js-objects' into weblate-integration
Diffstat (limited to 'js/ArticleCache.js')
-rw-r--r-- | js/ArticleCache.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/js/ArticleCache.js b/js/ArticleCache.js new file mode 100644 index 000000000..ce34d00d9 --- /dev/null +++ b/js/ArticleCache.js @@ -0,0 +1,29 @@ +'use strict' +/* global __, ngettext */ +define(["dojo/_base/declare"], function (declare) { + ArticleCache = { + has_storage: 'sessionStorage' in window && window['sessionStorage'] !== null, + set: function (id, obj) { + if (this.has_storage) + try { + sessionStorage["article:" + id] = obj; + } catch (e) { + sessionStorage.clear(); + } + }, + get: function (id) { + if (this.has_storage) + return sessionStorage["article:" + id]; + }, + clear: function () { + if (this.has_storage) + sessionStorage.clear(); + }, + del: function (id) { + if (this.has_storage) + sessionStorage.removeItem("article:" + id); + }, + } + + return ArticleCache; +}); |