TTS Framework - JavaScript assets.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
tts_js/core/addons/local_storage.js

69 lines
1.9 KiB

/*
* Local Storage
*/
function store(temp) {
if (typeof temp === "undefined") {
this.temp = false;
} else {
this.temp = temp;
}
if (typeof (Storage) !== "undefined") {
return true;
} else {
return false;
}
}
store.prototype.set = function (name, data) {
try {
if (typeof (Storage) !== "undefined") {
var d = JSON.stringify(data);
if (this.temp === false) {
localStorage.setItem(name, d);
} else {
sessionStorage.setItem(name, d);
}
return true;
} else {
return false;
}
} catch (er) {
return false;
}
};
store.prototype.get = function (name) {
if (typeof (Storage) !== "undefined") {
if (this.temp === false) {
return JSON.parse(localStorage.getItem(name));
} else {
return JSON.parse(sessionStorage.getItem(name));
}
} else {
return false;
}
};
store.prototype.remove = function (name) {
if (typeof (Storage) !== "undefined") {
if (this.temp === false) {
localStorage.removeItem(name);
} else {
sessionStorage.removeItem(name);
}
return true;
} else {
return false;
}
};
store.prototype.clear = function () {
if (typeof (Storage) !== "undefined") {
if (this.temp === false) {
localStorage.clear();
} else {
sessionStorage.clear();
}
return true;
} else {
return false;
}
};
tts.store = store;
/* End of Local Storage */