Added WebDAV syncing
This commit is contained in:
parent
b9e8278689
commit
d5518a164e
13 changed files with 284 additions and 70 deletions
|
|
@ -1,19 +1,13 @@
|
|||
let Storage = {};
|
||||
Storage.save = function(object){
|
||||
return new Promise(function(succ, err){
|
||||
chrome.storage.sync.set(object, succ);
|
||||
});
|
||||
}
|
||||
Storage.load = function(objects){
|
||||
return new Promise(function(succ, err){
|
||||
chrome.storage.sync.get(objects, succ);
|
||||
});
|
||||
}
|
||||
Storage.remove = function(objects){
|
||||
return new Promise(function(succ, err){
|
||||
chrome.storage.sync.remove(objects, succ);
|
||||
});
|
||||
}
|
||||
|
||||
Storage.save = browser.storage.local.set;
|
||||
Storage.load = browser.storage.local.get;
|
||||
Storage.remove = browser.storage.local.remove;
|
||||
|
||||
Storage.saveSync = browser.storage.sync.set;
|
||||
Storage.loadSync = browser.storage.sync.get;
|
||||
Storage.removeSync = browser.storage.sync.remove;
|
||||
|
||||
Storage.callbacks = {};
|
||||
Storage.onChange = function(key, fn){
|
||||
if(!Storage.callbacks[key]) Storage.callbacks[key] = [];
|
||||
|
|
@ -26,9 +20,10 @@ Storage.emit = function(key, newValue){
|
|||
});
|
||||
}
|
||||
chrome.storage.onChanged.addListener(function(objects, area){
|
||||
if(area!="sync") return;
|
||||
if(area!="local") return;
|
||||
for(let id in objects){
|
||||
let newValue = objects[id].newValue;
|
||||
if(newValue) { Storage.emit(id, newValue); }
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue