diff options
author | Ian Coleman <coleman.ian@gmail.com> | 2014-09-30 10:03:53 +1000 |
---|---|---|
committer | Ian Coleman <coleman.ian@gmail.com> | 2014-09-30 10:15:51 +1000 |
commit | d6cedc9405e5f5751c8635f59ed3ff6876460776 (patch) | |
tree | 00c15e7dcd79b044508564ed3d070339677af1bf | |
parent | 3b40653ff11985c5b31d300ade711b3f7fd03459 (diff) | |
download | BIP39-d6cedc9405e5f5751c8635f59ed3ff6876460776.tar.gz BIP39-d6cedc9405e5f5751c8635f59ed3ff6876460776.tar.zst BIP39-d6cedc9405e5f5751c8635f59ed3ff6876460776.zip |
Derivation path tabs display by network selection
-rw-r--r-- | bip39-standalone.html | 59 | ||||
-rw-r--r-- | src/js/index.js | 59 |
2 files changed, 118 insertions, 0 deletions
diff --git a/bip39-standalone.html b/bip39-standalone.html index ec15984..ce82c30 100644 --- a/bip39-standalone.html +++ b/bip39-standalone.html | |||
@@ -33842,12 +33842,19 @@ var Mnemonic = function(language) { | |||
33842 | var phraseChangeTimeoutEvent = null; | 33842 | var phraseChangeTimeoutEvent = null; |
33843 | 33843 | ||
33844 | var DOM = {}; | 33844 | var DOM = {}; |
33845 | DOM.network = $(".network"); | ||
33846 | DOM.phraseNetwork = $("#network-phrase"); | ||
33847 | DOM.bip44Network = $("#network-bip44"); | ||
33845 | DOM.phrase = $(".phrase"); | 33848 | DOM.phrase = $(".phrase"); |
33846 | DOM.passphrase = $(".passphrase"); | 33849 | DOM.passphrase = $(".passphrase"); |
33847 | DOM.generate = $(".generate"); | 33850 | DOM.generate = $(".generate"); |
33848 | DOM.rootKey = $(".root-key"); | 33851 | DOM.rootKey = $(".root-key"); |
33849 | DOM.extendedPrivKey = $(".extended-priv-key"); | 33852 | DOM.extendedPrivKey = $(".extended-priv-key"); |
33850 | DOM.extendedPubKey = $(".extended-pub-key"); | 33853 | DOM.extendedPubKey = $(".extended-pub-key"); |
33854 | DOM.bip32tab = $("#bip32-tab"); | ||
33855 | DOM.bip44tab = $("#bip44-tab"); | ||
33856 | DOM.bip32panel = $("#bip32"); | ||
33857 | DOM.bip44panel = $("#bip44"); | ||
33851 | DOM.bip32path = $("#bip32-path"); | 33858 | DOM.bip32path = $("#bip32-path"); |
33852 | DOM.bip44path = $("#bip44-path"); | 33859 | DOM.bip44path = $("#bip44-path"); |
33853 | DOM.bip44purpose = $("#bip44 .purpose"); | 33860 | DOM.bip44purpose = $("#bip44 .purpose"); |
@@ -33868,6 +33875,7 @@ var Mnemonic = function(language) { | |||
33868 | 33875 | ||
33869 | function init() { | 33876 | function init() { |
33870 | // Events | 33877 | // Events |
33878 | DOM.network.on("change", networkChanged); | ||
33871 | DOM.phrase.on("input", delayedPhraseChanged); | 33879 | DOM.phrase.on("input", delayedPhraseChanged); |
33872 | DOM.passphrase.on("input", delayedPhraseChanged); | 33880 | DOM.passphrase.on("input", delayedPhraseChanged); |
33873 | DOM.generate.on("click", generateClicked); | 33881 | DOM.generate.on("click", generateClicked); |
@@ -33888,6 +33896,35 @@ var Mnemonic = function(language) { | |||
33888 | 33896 | ||
33889 | // Event handlers | 33897 | // Event handlers |
33890 | 33898 | ||
33899 | function networkChanged(e) { | ||
33900 | var n = e.target.value; | ||
33901 | if (n == "bitcoin") { | ||
33902 | network = Bitcoin.networks.bitcoin; | ||
33903 | DOM.bip44coin.val(0); | ||
33904 | setBip44DerivationPath(); | ||
33905 | enableBip44Tab(); | ||
33906 | } | ||
33907 | else if (n == "bitcoin-testnet") { | ||
33908 | network = Bitcoin.networks.testnet; | ||
33909 | DOM.bip44coin.val(1); | ||
33910 | setBip44DerivationPath(); | ||
33911 | enableBip44Tab(); | ||
33912 | } | ||
33913 | else if (n == "litecoin") { | ||
33914 | network = Bitcoin.networks.litecoin; | ||
33915 | DOM.bip44coin.val(2); | ||
33916 | setBip44DerivationPath(); | ||
33917 | enableBip44Tab(); | ||
33918 | } | ||
33919 | else if (n == "dogecoin") { | ||
33920 | network = Bitcoin.networks.dogecoin; | ||
33921 | disableBip44Tab(); | ||
33922 | } | ||
33923 | DOM.phraseNetwork.val(n); | ||
33924 | DOM.bip44Network.val(n); | ||
33925 | delayedPhraseChanged(); | ||
33926 | } | ||
33927 | |||
33891 | function delayedPhraseChanged() { | 33928 | function delayedPhraseChanged() { |
33892 | hideValidationError(); | 33929 | hideValidationError(); |
33893 | showPending(); | 33930 | showPending(); |
@@ -34198,6 +34235,28 @@ var Mnemonic = function(language) { | |||
34198 | .hide(); | 34235 | .hide(); |
34199 | } | 34236 | } |
34200 | 34237 | ||
34238 | function enableBip44Tab() { | ||
34239 | // show bip44 tab (but don't select it) | ||
34240 | DOM.bip44tab.removeClass("hidden"); | ||
34241 | DOM.bip44panel.removeClass("hidden"); | ||
34242 | } | ||
34243 | |||
34244 | function disableBip44Tab() { | ||
34245 | // hide bip44 tab | ||
34246 | DOM.bip44tab.addClass("hidden"); | ||
34247 | DOM.bip44tab.removeClass("active"); | ||
34248 | // hide bip44 panel | ||
34249 | DOM.bip44panel.addClass("hidden"); | ||
34250 | DOM.bip44panel.removeClass("active"); | ||
34251 | // show bip32 tab | ||
34252 | DOM.bip32tab.addClass("active"); | ||
34253 | // show bip32 panel | ||
34254 | DOM.bip32panel.addClass("active"); | ||
34255 | // set the derivation path | ||
34256 | var activePath = $("#bip32 .path"); | ||
34257 | derivationPath = activePath.val(); | ||
34258 | } | ||
34259 | |||
34201 | init(); | 34260 | init(); |
34202 | 34261 | ||
34203 | })(); | 34262 | })(); |
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 | })(); |