diff options
-rw-r--r-- | src/css/app.css | 8 | ||||
-rw-r--r-- | src/index.html | 89 | ||||
-rw-r--r-- | src/js/index.js | 25 | ||||
-rw-r--r-- | tests/spec/tests.js | 18 |
4 files changed, 104 insertions, 36 deletions
diff --git a/src/css/app.css b/src/css/app.css index 897746b..71109ef 100644 --- a/src/css/app.css +++ b/src/css/app.css | |||
@@ -95,3 +95,11 @@ body { | |||
95 | top: 5px; | 95 | top: 5px; |
96 | right: 5px; | 96 | right: 5px; |
97 | } | 97 | } |
98 | .csv { | ||
99 | margin-top: 20px; | ||
100 | margin-bottom: 20px; | ||
101 | white-space: pre; | ||
102 | overflow-wrap: normal; | ||
103 | overflow-x: scroll; | ||
104 | font-family: monospace; | ||
105 | } | ||
diff --git a/src/index.html b/src/index.html index 0d1a2c6..0f47c38 100644 --- a/src/index.html +++ b/src/index.html | |||
@@ -603,42 +603,59 @@ | |||
603 | </label> | 603 | </label> |
604 | </div> | 604 | </div> |
605 | </div> | 605 | </div> |
606 | <div class="col-md-12"> | 606 | <ul class="addresses-type nav nav-tabs" role="tablist"> |
607 | <table class="table table-striped"> | 607 | <li id="table-tab" class="active"> |
608 | <thead> | 608 | <a href="#table" role="tab" data-toggle="tab">Table</a> |
609 | <th> | 609 | </li> |
610 | <div class="input-group"> | 610 | <li id="csv-tab"> |
611 | <span>Path</span> | 611 | <a href="#csv" role="tab" data-toggle="tab">CSV</a> |
612 | <button class="index-toggle">Toggle</button> | 612 | </li> |
613 | </div> | 613 | </ul> |
614 | </th> | 614 | <div class="addresses-type tab-content"> |
615 | <th> | 615 | <div id="table" class="tab-pane active"> |
616 | <div class="input-group"> | 616 | <div class="col-md-12"> |
617 | <span>Address</span> | 617 | <table class="table table-striped"> |
618 | <button class="address-toggle">Toggle</button> | 618 | <thead> |
619 | </div> | 619 | <th> |
620 | </th> | 620 | <div class="input-group"> |
621 | <th> | 621 | <span>Path</span> |
622 | <div class="input-group"> | 622 | <button class="index-toggle">Toggle</button> |
623 | <span>Public Key</span> | 623 | </div> |
624 | <button class="public-key-toggle">Toggle</button> | 624 | </th> |
625 | </div> | 625 | <th> |
626 | </th> | 626 | <div class="input-group"> |
627 | <th> | 627 | <span>Address</span> |
628 | <div class="input-group"> | 628 | <button class="address-toggle">Toggle</button> |
629 | <span>Private Key</span> | 629 | </div> |
630 | <button class="private-key-toggle">Toggle</button> | 630 | </th> |
631 | </div> | 631 | <th> |
632 | </th> | 632 | <div class="input-group"> |
633 | </thead> | 633 | <span>Public Key</span> |
634 | <tbody class="addresses monospace"> | 634 | <button class="public-key-toggle">Toggle</button> |
635 | <tr><td> </td><td> </td><td> </td><td> </td></tr> | 635 | </div> |
636 | <tr><td> </td><td> </td><td> </td><td> </td></tr> | 636 | </th> |
637 | <tr><td> </td><td> </td><td> </td><td> </td></tr> | 637 | <th> |
638 | <tr><td> </td><td> </td><td> </td><td> </td></tr> | 638 | <div class="input-group"> |
639 | <tr><td> </td><td> </td><td> </td><td> </td></tr> | 639 | <span>Private Key</span> |
640 | </tbody> | 640 | <button class="private-key-toggle">Toggle</button> |
641 | </table> | 641 | </div> |
642 | </th> | ||
643 | </thead> | ||
644 | <tbody class="addresses monospace"> | ||
645 | <tr><td> </td><td> </td><td> </td><td> </td></tr> | ||
646 | <tr><td> </td><td> </td><td> </td><td> </td></tr> | ||
647 | <tr><td> </td><td> </td><td> </td><td> </td></tr> | ||
648 | <tr><td> </td><td> </td><td> </td><td> </td></tr> | ||
649 | <tr><td> </td><td> </td><td> </td><td> </td></tr> | ||
650 | </tbody> | ||
651 | </table> | ||
652 | </div> | ||
653 | </div> | ||
654 | <div id="csv" class="tab-pane"> | ||
655 | <div class="col-md-12"> | ||
656 | <textarea class="csv form-control" rows="25" readonly></textarea> | ||
657 | </div> | ||
658 | </div> | ||
642 | </div> | 659 | </div> |
643 | </div> | 660 | </div> |
644 | <span>Show</span> | 661 | <span>Show</span> |
diff --git a/src/js/index.js b/src/js/index.js index e63c65f..01543f9 100644 --- a/src/js/index.js +++ b/src/js/index.js | |||
@@ -91,6 +91,8 @@ | |||
91 | DOM.useBitpayAddressesContainer = $(".use-bitpay-addresses-container"); | 91 | DOM.useBitpayAddressesContainer = $(".use-bitpay-addresses-container"); |
92 | DOM.useBitpayAddresses = $(".use-bitpay-addresses"); | 92 | DOM.useBitpayAddresses = $(".use-bitpay-addresses"); |
93 | DOM.addresses = $(".addresses"); | 93 | DOM.addresses = $(".addresses"); |
94 | DOM.csvTab = $("#csv-tab a"); | ||
95 | DOM.csv = $(".csv"); | ||
94 | DOM.rowsToAdd = $(".rows-to-add"); | 96 | DOM.rowsToAdd = $(".rows-to-add"); |
95 | DOM.more = $(".more"); | 97 | DOM.more = $(".more"); |
96 | DOM.moreRowsStartIndex = $(".more-rows-start-index"); | 98 | DOM.moreRowsStartIndex = $(".more-rows-start-index"); |
@@ -135,6 +137,7 @@ | |||
135 | DOM.addressToggle.on("click", toggleAddresses); | 137 | DOM.addressToggle.on("click", toggleAddresses); |
136 | DOM.publicKeyToggle.on("click", togglePublicKeys); | 138 | DOM.publicKeyToggle.on("click", togglePublicKeys); |
137 | DOM.privateKeyToggle.on("click", togglePrivateKeys); | 139 | DOM.privateKeyToggle.on("click", togglePrivateKeys); |
140 | DOM.csvTab.on("click", updateCsv); | ||
138 | DOM.languages.on("click", languageChanged); | 141 | DOM.languages.on("click", languageChanged); |
139 | DOM.useBitpayAddresses.on("change", useBitpayAddressesChange); | 142 | DOM.useBitpayAddresses.on("change", useBitpayAddressesChange); |
140 | setQrEvents(DOM.showQrEls); | 143 | setQrEvents(DOM.showQrEls); |
@@ -831,6 +834,7 @@ | |||
831 | addAddressToList(indexText, address, pubkey, privkey); | 834 | addAddressToList(indexText, address, pubkey, privkey); |
832 | if (isLast) { | 835 | if (isLast) { |
833 | hidePending(); | 836 | hidePending(); |
837 | updateCsv(); | ||
834 | } | 838 | } |
835 | }, 50) | 839 | }, 50) |
836 | } | 840 | } |
@@ -871,6 +875,7 @@ | |||
871 | 875 | ||
872 | function clearAddressesList() { | 876 | function clearAddressesList() { |
873 | DOM.addresses.empty(); | 877 | DOM.addresses.empty(); |
878 | DOM.csv.val(""); | ||
874 | stopGenerating(); | 879 | stopGenerating(); |
875 | } | 880 | } |
876 | 881 | ||
@@ -1426,6 +1431,26 @@ | |||
1426 | DOM.entropyWordIndexes.text(wordIndexesStr); | 1431 | DOM.entropyWordIndexes.text(wordIndexesStr); |
1427 | } | 1432 | } |
1428 | 1433 | ||
1434 | function updateCsv() { | ||
1435 | var tableCsv = "path,address,public key,private key\n"; | ||
1436 | var rows = DOM.addresses.find("tr"); | ||
1437 | for (var i=0; i<rows.length; i++) { | ||
1438 | var row = $(rows[i]); | ||
1439 | var cells = row.find("td"); | ||
1440 | for (var j=0; j<cells.length; j++) { | ||
1441 | var cell = $(cells[j]); | ||
1442 | if (!cell.children().hasClass("invisible")) { | ||
1443 | tableCsv = tableCsv + cell.text(); | ||
1444 | } | ||
1445 | if (j != cells.length - 1) { | ||
1446 | tableCsv = tableCsv + ","; | ||
1447 | } | ||
1448 | } | ||
1449 | tableCsv = tableCsv + "\n"; | ||
1450 | } | ||
1451 | DOM.csv.val(tableCsv); | ||
1452 | } | ||
1453 | |||
1429 | var networks = [ | 1454 | var networks = [ |
1430 | { | 1455 | { |
1431 | name: "BCH - Bitcoin Cash", | 1456 | name: "BCH - Bitcoin Cash", |
diff --git a/tests/spec/tests.js b/tests/spec/tests.js index 07b7b1a..c3cfdbe 100644 --- a/tests/spec/tests.js +++ b/tests/spec/tests.js | |||
@@ -2832,4 +2832,22 @@ it('Passes the official BIP84 test spec for account 0 first change address', fun | |||
2832 | }); | 2832 | }); |
2833 | }); | 2833 | }); |
2834 | 2834 | ||
2835 | it('Can display the table as csv', function(done) { | ||
2836 | var headings = "path,address,public key,private key"; | ||
2837 | var row1 = "m/44'/0'/0'/0/0,1Di3Vp7tBWtyQaDABLAjfWtF6V7hYKJtug,033f5aed5f6cfbafaf223188095b5980814897295f723815fea5d3f4b648d0d0b3,L26cVSpWFkJ6aQkPkKmTzLqTdLJ923e6CzrVh9cmx21QHsoUmrEE"; | ||
2838 | var row20 = "m/44'/0'/0'/0/19,1KhBy28XLAciXnnRvm71PvQJaETyrxGV55,02b4b3e396434d8cdd20c03ac4aaa07387784d5d867b75987f516f5705ee68cb3a,L4GrDrjReMsCAu5DkLXn79jSb95qR7Zfx7eshybCQZ1qL32MXJab"; | ||
2839 | driver.findElement(By.css('.phrase')) | ||
2840 | .sendKeys('abandon abandon ability'); | ||
2841 | driver.sleep(generateDelay).then(function() { | ||
2842 | driver.findElement(By.css('.csv')) | ||
2843 | .getAttribute("value") | ||
2844 | .then(function(csv) { | ||
2845 | expect(csv).toContain(headings); | ||
2846 | expect(csv).toContain(row1); | ||
2847 | expect(csv).toContain(row20); | ||
2848 | done(); | ||
2849 | }); | ||
2850 | }); | ||
2851 | }); | ||
2852 | |||
2835 | }); | 2853 | }); |