cache_added["TS:" + id] = ts;
if (has_local_storage())
- localStorage.setItem(id, JSON.stringify(cache_obj));
+ sessionStorage.setItem(id, JSON.stringify(cache_obj));
else
article_cache.push(cache_obj);
function cache_find(id) {
if (has_local_storage()) {
- var cache_obj = localStorage.getItem(id);
+ var cache_obj = sessionStorage.getItem(id);
if (cache_obj) {
cache_obj = JSON.parse(cache_obj);
if (param) id = id + ":" + param;
- var cache_obj = localStorage.getItem(id);
+ var cache_obj = sessionStorage.getItem(id);
if (cache_obj) {
cache_obj = JSON.parse(cache_obj);
function cache_check(id) {
if (has_local_storage()) {
- if (localStorage.getItem(id))
+ if (sessionStorage.getItem(id))
return true;
} else {
for (var i = 0; i < article_cache.length; i++) {
if (param) id = id + ":" + param;
- if (localStorage.getItem(id))
+ if (sessionStorage.getItem(id))
return true;
} else {
var date = new Date();
var timestamp = Math.round(date.getTime() / 1000);
- for (var i = 0; i < localStorage.length; i++) {
+ for (var i = 0; i < sessionStorage.length; i++) {
- var id = localStorage.key(i);
+ var id = sessionStorage.key(i);
if (timestamp - cache_added["TS:" + id] > 180) {
- localStorage.removeItem(id);
+ sessionStorage.removeItem(id);
}
}
function cache_flush() {
if (has_local_storage()) {
- localStorage.clear();
+ sessionStorage.clear();
} else {
article_cache = new Array();
}
var found = false;
- for (var i = 0; i < localStorage.length; i++) {
- var key = localStorage.key(i);
+ for (var i = 0; i < sessionStorage.length; i++) {
+ var key = sessionStorage.key(i);
// console.warn("cache_invalidate: " + key_id + " cmp " + id);
if (key == id || key.indexOf(id + ":") == 0) {
- localStorage.removeItem(key);
+ sessionStorage.removeItem(key);
found = true;
break;
}