sumorobot-web/assets/js/utils.js

25 lines
659 B
JavaScript
Raw Normal View History

2018-07-08 18:52:44 +00:00
// Function to get data from localStorage
function getLocalStorageItem(item) {
// When cookies are disabled
if (!cookiesEnabled) return "";
// Try to get data from localStorage
try {
return localStorage.getItem(item);
// Failed to access localStorage
2018-10-11 08:21:25 +00:00
} catch(err) {
2018-07-08 18:52:44 +00:00
// Return empty result
return "";
}
}
// Function to set data to local storage
function setLocalStorageItem(item, value) {
// When cookies are disabled
if (!cookiesEnabled) return;
// Try to save data to localStorage
try {
localStorage.setItem(item, value)
// Failed to access localStorage
2018-10-11 08:21:25 +00:00
} catch(err) {}
2018-07-08 18:52:44 +00:00
}