SillyTavern/public/scripts/f-localStorage.js

28 lines
919 B
JavaScript
Raw Normal View History

2023-07-20 19:32:15 +02:00
////////////////// LOCAL STORAGE HANDLING /////////////////////
export function SaveLocal(target, val) {
2023-12-02 20:56:16 +01:00
localStorage.setItem(target, val);
console.debug('SaveLocal -- ' + target + ' : ' + val);
2023-07-20 19:32:15 +02:00
}
export function LoadLocal(target) {
2023-12-02 20:56:16 +01:00
console.debug('LoadLocal -- ' + target);
return localStorage.getItem(target);
2023-07-20 19:32:15 +02:00
}
export function LoadLocalBool(target) {
2023-12-02 20:56:16 +01:00
let result = localStorage.getItem(target) === 'true';
return result;
2023-07-20 19:32:15 +02:00
}
export function CheckLocal() {
2023-12-02 20:56:16 +01:00
console.log('----------local storage---------');
var i;
for (i = 0; i < localStorage.length; i++) {
console.log(localStorage.key(i) + ' : ' + localStorage.getItem(localStorage.key(i)));
}
console.log('------------------------------');
2023-07-20 19:32:15 +02:00
}
export function ClearLocal() { localStorage.clear(); console.log('Removed All Local Storage'); }
/////////////////////////////////////////////////////////////////////////