ttrss/js/ArticleCache.js

30 lines
663 B
JavaScript
Raw Normal View History

'use strict'
/* global __, ngettext */
2018-12-02 14:18:59 +00:00
define(["dojo/_base/declare"], function (declare) {
ArticleCache = {
2018-12-02 14:18:59 +00:00
has_storage: 'sessionStorage' in window && window['sessionStorage'] !== null,
set: function (id, obj) {
2018-12-02 14:18:59 +00:00
if (this.has_storage)
try {
sessionStorage["article:" + id] = obj;
} catch (e) {
sessionStorage.clear();
}
},
get: function (id) {
2018-12-02 14:18:59 +00:00
if (this.has_storage)
return sessionStorage["article:" + id];
},
clear: function () {
2018-12-02 14:18:59 +00:00
if (this.has_storage)
sessionStorage.clear();
},
del: function (id) {
2018-12-02 14:18:59 +00:00
if (this.has_storage)
sessionStorage.removeItem("article:" + id);
},
}
return ArticleCache;
2018-12-02 14:18:59 +00:00
});