summaryrefslogtreecommitdiff
path: root/js/ArticleCache.js
blob: ce34d00d9a498865c15b41614ebc1ead98373c9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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;
});