1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-07-05 11:37:01 +02:00

Safari: new storage now works; closes #985

This commit is contained in:
Chris 2015-03-11 00:03:54 -06:00
parent 4720ecdf58
commit 10f656f8fe

View File

@ -137,42 +137,34 @@
}
for(var i = 0; i < n; i++) {
var key = keys[i];
localforage.getItem(key, function(err, value) {
var func = function(err, value) {
toSatisfy--;
if(typeof value === "string") {
result[key] = JSON.parse(value);
result[arguments.callee.myKey] = JSON.parse(value);
}
if(toSatisfy === 0) {
callback(result);
}
});
};
func.myKey = key;
localforage.getItem(key, func);
}
}
else if(typeof keys === "object") {
var toSatisfy = 0;
for(var key in keys) {
if(!keys.hasOwnProperty(key)) {
continue;
}
toSatisfy++;
result[key] = keys[key];
}
for(var key in keys) {
if(!keys.hasOwnProperty(key)) {
continue;
localforage.iterate(function(value, key) {
if(!keys[key]) return;
if(typeof value === "string") {
result[key] = JSON.parse(value);
}
var i = key;
localforage.getItem(i, function(err, value) {
if(typeof value === "string") {
result[i] = JSON.parse(value);
}
else {
result[i] = keys[i];
}
if(--toSatisfy === 0) {
callback(result);
}
});
}
}, function() {
callback(result);
});
}
},