mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-21 07:15:15 +03:00
Chrome Apps don't get window.localStorage
This commit is contained in:
parent
a156ebd31e
commit
9fa5cca011
3 changed files with 43 additions and 18 deletions
|
@ -5,6 +5,9 @@
|
|||
var ConfigStorage = {
|
||||
// key can be one string, or array of strings
|
||||
get: function(key, callback) {
|
||||
if (GUI.isChromeApp()) {
|
||||
chrome.storage.local.get(key,callback);
|
||||
} else {
|
||||
//console.log('Abstraction.get',key);
|
||||
if (Array.isArray(key)) {
|
||||
var obj = {};
|
||||
|
@ -30,12 +33,17 @@ var ConfigStorage = {
|
|||
callback({});
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
// set takes an object like {'userLanguageSelect':'DEFAULT'}
|
||||
set: function(input) {
|
||||
if (GUI.isChromeApp()) {
|
||||
chrome.storage.local.set(input);
|
||||
} else {
|
||||
//console.log('Abstraction.set',input);
|
||||
Object.keys(input).forEach(function (element) {
|
||||
window.localStorage.setItem(element, JSON.stringify(input));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue