summaryrefslogtreecommitdiff
path: root/js/ArticleCache.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/ArticleCache.js')
-rw-r--r--js/ArticleCache.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/js/ArticleCache.js b/js/ArticleCache.js
new file mode 100644
index 000000000..fbba1f679
--- /dev/null
+++ b/js/ArticleCache.js
@@ -0,0 +1,25 @@
+define(["dojo/_base/declare"], function (declare) {
+ return declare("fox.ArticleCache", null, {
+ 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);
+ },
+ });
+});