Skip to content
This repository has been archived by the owner on Nov 2, 2018. It is now read-only.

Commit

Permalink
Merge pull request #67 from NebulousLabs/tweaks
Browse files Browse the repository at this point in the history
Wallet address list and v0.3.3.x loading
  • Loading branch information
DavidVorick committed Sep 3, 2015
2 parents 6d69417 + e4855ce commit 06b2c3e
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 5 deletions.
1 change: 0 additions & 1 deletion app/css/plugin-standard.css
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ html, body {
overflow: hidden;
}
.capsule .pod {
overflow: hidden;
display: inline-block;
padding: 8px;
padding-left: 16px;
Expand Down
16 changes: 13 additions & 3 deletions app/plugins/Wallet/css/wallet.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,33 @@
.popup {
position: absolute;
min-height: 100px;
min-width: 200px;
max-height: 50%;
min-width: 100px;
max-width: 75%;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-webkit-animation: fadein 0.5s;

background-color: #ffffff;
z-index: 2;

border: solid 1px #c5c5c5;
border-radius: 8px;
overflow: hidden;
text-align: center;
overflow: hidden;
}
.popup .title {
font-size: 24px;
display: block;
}
.popup .address-list {
font-family: monospace;
font-size: 12px;
max-height: 150px;
overflow: auto;
padding: 10px;
}
.password {
border-top: solid 1px #c5c5c5;
border-bottom: solid 1px #c5c5c5;
Expand All @@ -37,7 +48,6 @@
/* Information Box */
.row {
background:#f5f5f5;
min-width: 1000px;
display: block;
padding-top: 18px;
padding-bottom: 18px;
Expand Down
21 changes: 20 additions & 1 deletion app/plugins/Wallet/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@
<i class='fa fa-key' id='confirm-password'>I've recorded this in a safe place</i>
</div>
</div>
<div class='popup hidden' id='display-addresses'>
<div class='row'>
<div class='title'>
Address List
</div>
</div>
<p class='address-list'></p>
<div class='button' id='close-address-list'>
<i class='fa fa-close'>Close</i>
</div>
</div>

<!-- Transactions Box -->
<div class='box'>
Expand Down Expand Up @@ -103,6 +114,14 @@
<i class='fa fa-plus'></i>
Create Address
</div>
<div class='button' id='show-address-list'>
<i class='fa fa-list-ul'></i>
Address List
</div>
<div class='button' id='load-legacy-wallet'>
<i class='fa fa-folder-open-o'></i>
Load Legacy Wallet
</div>
</div>
</div>
<div class='list' id='address-list'>
Expand All @@ -112,7 +131,7 @@

<!-- JS -->
<script src='js/helpers.js'></script>
<script src='js/security.js'></script>
<script src='js/loaders.js'></script>
<script src='js/buttons.js'></script>
<script src='js/lifecycle.js'></script>
</body>
Expand Down
39 changes: 39 additions & 0 deletions app/plugins/Wallet/js/buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ eID('lock-pod').onclick = function() {
lock();
} else if (!wallet.unlocked && state === 'Locked'){
show('request-password');
eID('password-field').focus();
} else {
console.error('lock-pod disagrees with wallet variable!', wallet.unlocked, state);
}
Expand All @@ -127,9 +128,47 @@ eID('enter-password').onclick = function() {
unlock(field.value);
field.value = '';
};
// An 'Enter' keypress in the input field will submit it.
eID('password-field').addEventListener("keydown", function(e) {
e = e || window.event;
if (e.keyCode == 13) {
eID('enter-password').click();
}
}, false);

// Make sure the user read the password
eID('confirm-password').onclick = function() {
hide('show-password');
};


eID('show-address-list').onclick = function() {
listAddresses();
};
eID('close-address-list').onclick = function() {
hide('display-addresses');
};

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Load ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
eID('load-legacy-wallet').onclick = function() {
var loadPath = IPC.sendSync('dialog', 'open', {
title: 'Legacy Wallet File Path',
filters: [
{ name: 'Legacy wallet', extensions: ['dat'] }
],
properties: ['openFile'],
});
if (loadPath) {
// kind of a hack; we want to reuse the enter-password dialog, but in
// order to do so we must temporarily overwrite its onclick method.
var oldOnclick = eID('enter-password').onclick;
eID('enter-password').onclick = function() {
var field = eID('password-field');
loadLegacyWallet(loadPath[0], field.value);
field.value = '';
eID('enter-password').onclick = oldOnclick;
hide('request-password');
}
show('request-password');
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,36 @@ addResultListener('encrypted', function(result) {
update();
});

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Address List ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function listAddresses() {
IPC.sendToHost('api-call', {
url: '/wallet/addresses',
type: 'GET',
}, 'address-list');
}
addResultListener('address-list', function(result) {
// format address list
var list = '';
result.addresses.forEach(function(elem){
list += elem.address + '\n'
});
var popup = eID('display-addresses');
show(popup);
popup.querySelector('.address-list').innerHTML = list;
update();
});

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Load ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function loadLegacyWallet(filename, password) {
IPC.sendToHost('api-call', {
url: '/wallet/load/033x',
type: 'POST',
args: {
filepath: filename,
encryptionpassword: password,
},
}, 'load-wallet');
}
addResultListener('load-wallet', function(result) {
notify('Loaded Wallet', 'success');
});

0 comments on commit 06b2c3e

Please sign in to comment.