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
1 changed files with 13 additions and 21 deletions

View File

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