From 807ff074540575e6ef8f99ad32b098a816091171 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 2 Dec 2018 17:18:59 +0300 Subject: split main objects to dojo modules --- js/ArticleCache.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 js/ArticleCache.js (limited to 'js/ArticleCache.js') 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); + }, + }); +}); -- cgit v1.2.3