diff options
author | Ian Coleman <ian@iancoleman.io> | 2017-11-21 12:06:56 +1100 |
---|---|---|
committer | Ian Coleman <ian@iancoleman.io> | 2017-11-21 12:06:56 +1100 |
commit | 9183f9f658222dc3a24c8b4794887b6ecd80ba1e (patch) | |
tree | 6c3fdc47c20562bed4bdc297f4e96d610ba9f3d0 /src | |
parent | f487fea9b8b37642a3940be63129d9835eb77229 (diff) | |
download | BIP39-9183f9f658222dc3a24c8b4794887b6ecd80ba1e.tar.gz BIP39-9183f9f658222dc3a24c8b4794887b6ecd80ba1e.tar.zst BIP39-9183f9f658222dc3a24c8b4794887b6ecd80ba1e.zip |
Allow more rows to be generated at a custom index
Diffstat (limited to 'src')
-rw-r--r-- | src/index.html | 7 | ||||
-rw-r--r-- | src/js/index.js | 18 |
2 files changed, 22 insertions, 3 deletions
diff --git a/src/index.html b/src/index.html index cdd2ab2..63533a9 100644 --- a/src/index.html +++ b/src/index.html | |||
@@ -622,9 +622,12 @@ | |||
622 | </table> | 622 | </table> |
623 | </div> | 623 | </div> |
624 | </div> | 624 | </div> |
625 | <span>Show more rows</span>: | 625 | <span>Show</span> |
626 | <input type="number" class="rows-to-add" value="20"> | 626 | <input type="number" class="rows-to-add" value="20"> |
627 | <button class="more">Show</button> | 627 | <button class="more">more rows</button> |
628 | <span>starting from index</span> | ||
629 | <input type="number" class="more-rows-start-index"> | ||
630 | <span>(leave blank to generate from next index)</span> | ||
628 | 631 | ||
629 | <hr> | 632 | <hr> |
630 | 633 | ||
diff --git a/src/js/index.js b/src/js/index.js index 739dc01..38a7efd 100644 --- a/src/js/index.js +++ b/src/js/index.js | |||
@@ -80,6 +80,7 @@ | |||
80 | DOM.addresses = $(".addresses"); | 80 | DOM.addresses = $(".addresses"); |
81 | DOM.rowsToAdd = $(".rows-to-add"); | 81 | DOM.rowsToAdd = $(".rows-to-add"); |
82 | DOM.more = $(".more"); | 82 | DOM.more = $(".more"); |
83 | DOM.moreRowsStartIndex = $(".more-rows-start-index"); | ||
83 | DOM.feedback = $(".feedback"); | 84 | DOM.feedback = $(".feedback"); |
84 | DOM.tab = $(".derivation-type a"); | 85 | DOM.tab = $(".derivation-type a"); |
85 | DOM.indexToggle = $(".index-toggle"); | 86 | DOM.indexToggle = $(".index-toggle"); |
@@ -750,12 +751,19 @@ | |||
750 | } | 751 | } |
751 | 752 | ||
752 | function showMore() { | 753 | function showMore() { |
753 | var start = DOM.addresses.children().length; | ||
754 | var rowsToAdd = parseInt(DOM.rowsToAdd.val()); | 754 | var rowsToAdd = parseInt(DOM.rowsToAdd.val()); |
755 | if (isNaN(rowsToAdd)) { | 755 | if (isNaN(rowsToAdd)) { |
756 | rowsToAdd = 20; | 756 | rowsToAdd = 20; |
757 | DOM.rowsToAdd.val("20"); | 757 | DOM.rowsToAdd.val("20"); |
758 | } | 758 | } |
759 | var start = parseInt(DOM.moreRowsStartIndex.val()) | ||
760 | if (isNaN(start)) { | ||
761 | start = lastIndexInTable() + 1; | ||
762 | } | ||
763 | else { | ||
764 | var newStart = start + rowsToAdd; | ||
765 | DOM.moreRowsStartIndex.val(newStart); | ||
766 | } | ||
759 | if (rowsToAdd > 200) { | 767 | if (rowsToAdd > 200) { |
760 | var msg = "Generating " + rowsToAdd + " rows could take a while. "; | 768 | var msg = "Generating " + rowsToAdd + " rows could take a while. "; |
761 | msg += "Do you want to continue?"; | 769 | msg += "Do you want to continue?"; |
@@ -1291,6 +1299,14 @@ | |||
1291 | } | 1299 | } |
1292 | } | 1300 | } |
1293 | 1301 | ||
1302 | function lastIndexInTable() { | ||
1303 | var pathText = DOM.addresses.find(".index").last().text(); | ||
1304 | var pathBits = pathText.split("/"); | ||
1305 | var lastBit = pathBits[pathBits.length-1]; | ||
1306 | var lastBitClean = lastBit.replace("'", ""); | ||
1307 | return parseInt(lastBitClean); | ||
1308 | } | ||
1309 | |||
1294 | var networks = [ | 1310 | var networks = [ |
1295 | { | 1311 | { |
1296 | name: "BCH - Bitcoin Cash", | 1312 | name: "BCH - Bitcoin Cash", |