1
0
mirror of https://tt-rss.org/git/tt-rss.git synced 2024-06-26 11:59:02 +02:00
ttrss/js/ArticleCache.js

30 lines
663 B
JavaScript
Raw Permalink Normal View History

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