aboutsummaryrefslogtreecommitdiff
path: root/src/js
diff options
context:
space:
mode:
authorIan Coleman <coleman.ian@gmail.com>2014-09-30 10:03:53 +1000
committerIan Coleman <coleman.ian@gmail.com>2014-09-30 10:15:51 +1000
commitd6cedc9405e5f5751c8635f59ed3ff6876460776 (patch)
tree00c15e7dcd79b044508564ed3d070339677af1bf /src/js
parent3b40653ff11985c5b31d300ade711b3f7fd03459 (diff)
downloadBIP39-d6cedc9405e5f5751c8635f59ed3ff6876460776.tar.gz
BIP39-d6cedc9405e5f5751c8635f59ed3ff6876460776.tar.zst
BIP39-d6cedc9405e5f5751c8635f59ed3ff6876460776.zip
Derivation path tabs display by network selection
Diffstat (limited to 'src/js')
-rw-r--r--src/js/index.js59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/js/index.js b/src/js/index.js
index 81958fc..09bcdd9 100644
--- a/src/js/index.js
+++ b/src/js/index.js
@@ -13,12 +13,19 @@
13 var phraseChangeTimeoutEvent = null; 13 var phraseChangeTimeoutEvent = null;
14 14
15 var DOM = {}; 15 var DOM = {};
16 DOM.network = $(".network");
17 DOM.phraseNetwork = $("#network-phrase");
18 DOM.bip44Network = $("#network-bip44");
16 DOM.phrase = $(".phrase"); 19 DOM.phrase = $(".phrase");
17 DOM.passphrase = $(".passphrase"); 20 DOM.passphrase = $(".passphrase");
18 DOM.generate = $(".generate"); 21 DOM.generate = $(".generate");
19 DOM.rootKey = $(".root-key"); 22 DOM.rootKey = $(".root-key");
20 DOM.extendedPrivKey = $(".extended-priv-key"); 23 DOM.extendedPrivKey = $(".extended-priv-key");
21 DOM.extendedPubKey = $(".extended-pub-key"); 24 DOM.extendedPubKey = $(".extended-pub-key");
25 DOM.bip32tab = $("#bip32-tab");
26 DOM.bip44tab = $("#bip44-tab");
27 DOM.bip32panel = $("#bip32");
28 DOM.bip44panel = $("#bip44");
22 DOM.bip32path = $("#bip32-path"); 29 DOM.bip32path = $("#bip32-path");
23 DOM.bip44path = $("#bip44-path"); 30 DOM.bip44path = $("#bip44-path");
24 DOM.bip44purpose = $("#bip44 .purpose"); 31 DOM.bip44purpose = $("#bip44 .purpose");
@@ -39,6 +46,7 @@
39 46
40 function init() { 47 function init() {
41 // Events 48 // Events
49 DOM.network.on("change", networkChanged);
42 DOM.phrase.on("input", delayedPhraseChanged); 50 DOM.phrase.on("input", delayedPhraseChanged);
43 DOM.passphrase.on("input", delayedPhraseChanged); 51 DOM.passphrase.on("input", delayedPhraseChanged);
44 DOM.generate.on("click", generateClicked); 52 DOM.generate.on("click", generateClicked);
@@ -59,6 +67,35 @@
59 67
60 // Event handlers 68 // Event handlers
61 69
70 function networkChanged(e) {
71 var n = e.target.value;
72 if (n == "bitcoin") {
73 network = Bitcoin.networks.bitcoin;
74 DOM.bip44coin.val(0);
75 setBip44DerivationPath();
76 enableBip44Tab();
77 }
78 else if (n == "bitcoin-testnet") {
79 network = Bitcoin.networks.testnet;
80 DOM.bip44coin.val(1);
81 setBip44DerivationPath();
82 enableBip44Tab();
83 }
84 else if (n == "litecoin") {
85 network = Bitcoin.networks.litecoin;
86 DOM.bip44coin.val(2);
87 setBip44DerivationPath();
88 enableBip44Tab();
89 }
90 else if (n == "dogecoin") {
91 network = Bitcoin.networks.dogecoin;
92 disableBip44Tab();
93 }
94 DOM.phraseNetwork.val(n);
95 DOM.bip44Network.val(n);
96 delayedPhraseChanged();
97 }
98
62 function delayedPhraseChanged() { 99 function delayedPhraseChanged() {
63 hideValidationError(); 100 hideValidationError();
64 showPending(); 101 showPending();
@@ -369,6 +406,28 @@
369 .hide(); 406 .hide();
370 } 407 }
371 408
409 function enableBip44Tab() {
410 // show bip44 tab (but don't select it)
411 DOM.bip44tab.removeClass("hidden");
412 DOM.bip44panel.removeClass("hidden");
413 }
414
415 function disableBip44Tab() {
416 // hide bip44 tab
417 DOM.bip44tab.addClass("hidden");
418 DOM.bip44tab.removeClass("active");
419 // hide bip44 panel
420 DOM.bip44panel.addClass("hidden");
421 DOM.bip44panel.removeClass("active");
422 // show bip32 tab
423 DOM.bip32tab.addClass("active");
424 // show bip32 panel
425 DOM.bip32panel.addClass("active");
426 // set the derivation path
427 var activePath = $("#bip32 .path");
428 derivationPath = activePath.val();
429 }
430
372 init(); 431 init();
373 432
374})(); 433})();