add wallets nicknames, handle error messages
This commit is contained in:
parent
ca56071453
commit
5d30a6abea
8 changed files with 98 additions and 48 deletions
|
|
@ -25,9 +25,9 @@ Storage.prototype._getWalletKeys = function(walletId) {
|
|||
for (var i = 0; i < localStorage.length; i++) {
|
||||
var key = localStorage.key(i);
|
||||
var split = key.split('::');
|
||||
if (split.length == 2) {
|
||||
if (split.length == 3) {
|
||||
if (walletId = split[0])
|
||||
keys.push(split[1]);
|
||||
keys.push(split[2]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -69,30 +69,54 @@ Storage.prototype.remove = function(walletId, k) {
|
|||
this.removeGlobal(this._key(walletId,k));
|
||||
};
|
||||
|
||||
Storage.prototype.setName = function(walletId, name) {
|
||||
this.setGlobal('nameFor::'+walletId, name);
|
||||
};
|
||||
|
||||
Storage.prototype.getName = function(walletId) {
|
||||
return this.getGlobal('nameFor::'+walletId);
|
||||
};
|
||||
|
||||
Storage.prototype.getWalletIds = function() {
|
||||
var walletIds = [];
|
||||
var uniq = {};
|
||||
|
||||
for (var i = 0; i < localStorage.length; i++) {
|
||||
var key = localStorage.key(i);
|
||||
var split = key.split('::');
|
||||
if (split.length == 2) {
|
||||
var key = localStorage.key(i);
|
||||
var split = key.split('::');
|
||||
if (split.length == 2) {
|
||||
var walletId = split[0];
|
||||
|
||||
if (walletId === 'nameFor') continue;
|
||||
|
||||
if (typeof uniq[walletId] === 'undefined' ) {
|
||||
walletIds.push(walletId);
|
||||
uniq[walletId] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return walletIds;
|
||||
};
|
||||
|
||||
Storage.prototype.getWallets = function() {
|
||||
var wallets = [];
|
||||
var uniq = {};
|
||||
var ids = this.getWalletIds();
|
||||
|
||||
for (var i in ids){
|
||||
wallets.push({
|
||||
id:ids[i],
|
||||
name: this.getName(ids[i]),
|
||||
});
|
||||
}
|
||||
return wallets;
|
||||
};
|
||||
|
||||
//obj contains keys to be set
|
||||
Storage.prototype.setFromObj = function(walletId, obj) {
|
||||
for (var k in obj) {
|
||||
this.set(walletId, k, obj[k]);
|
||||
}
|
||||
this.setName(walletId, obj.opts.name);
|
||||
};
|
||||
|
||||
// remove all values
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue