|
|
|
@ -17,6 +17,11 @@ function setStorage(key, value, nochangeupdate) {
|
|
|
|
|
nochangeupdate = false;
|
|
|
|
|
}
|
|
|
|
|
localStorage.setItem(key, value);
|
|
|
|
|
try {
|
|
|
|
|
NativeStorage.setItem(key, value);
|
|
|
|
|
} catch (ex) {
|
|
|
|
|
// skip
|
|
|
|
|
}
|
|
|
|
|
if (!nochangeupdate && !SETTINGS.synckeyblacklist.includes(key)) {
|
|
|
|
|
var version = getStorage("syncstateversion") == null ? 0 : getStorage("syncstateversion");
|
|
|
|
|
localStorage.setItem("syncstateversion", Number(version) + 1);
|
|
|
|
@ -41,6 +46,15 @@ function inStorage(key) {
|
|
|
|
|
return localStorage.getItem(key) != null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Erase the key and its value from the persistent storage.
|
|
|
|
|
* @param {string} key
|
|
|
|
|
* @returns {undefined}
|
|
|
|
|
*/
|
|
|
|
|
function removeStorage(key) {
|
|
|
|
|
localStorage.removeItem(key);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get all item from persistent storage.
|
|
|
|
|
* @returns {Array} [{key: "", value: ""},...]
|
|
|
|
@ -56,4 +70,22 @@ function getAllStorage() {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return all;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function copyLocalStorageToNativeStorage() {
|
|
|
|
|
for (var key in localStorage) {
|
|
|
|
|
if (localStorage.hasOwnProperty(key)) {
|
|
|
|
|
NativeStorage.setItem(key, localStorage.getItem(key));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function copyNativeStorageToLocalStorage() {
|
|
|
|
|
NativeStorage.keys(function (keys) {
|
|
|
|
|
for (var key in keys) {
|
|
|
|
|
NativeStorage.getItem(key, function (val) {
|
|
|
|
|
localStorage.setItem(key, val);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|