diff options
author | iancoleman <coleman.ian@gmail.com> | 2017-02-19 11:23:41 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-19 11:23:41 +1100 |
commit | 5de5781ad732f71ba62d8a1640eb946e853e3c8a (patch) | |
tree | f4d2853ce988201ff32bf731d670c22fdf9d43a1 /src/js/index.js | |
parent | 49b21f122a232330f7efc499095d8d80f7895a20 (diff) | |
parent | b4fd763cebfb7f9497e12ca09b6271e1b39ac145 (diff) | |
download | BIP39-5de5781ad732f71ba62d8a1640eb946e853e3c8a.tar.gz BIP39-5de5781ad732f71ba62d8a1640eb946e853e3c8a.tar.zst BIP39-5de5781ad732f71ba62d8a1640eb946e853e3c8a.zip |
Merge pull request #55 from galeksandrp/patch-1
Add client select
Diffstat (limited to 'src/js/index.js')
-rw-r--r-- | src/js/index.js | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/js/index.js b/src/js/index.js index 4c947a4..8c54cab 100644 --- a/src/js/index.js +++ b/src/js/index.js | |||
@@ -23,7 +23,9 @@ | |||
23 | 23 | ||
24 | var DOM = {}; | 24 | var DOM = {}; |
25 | DOM.network = $(".network"); | 25 | DOM.network = $(".network"); |
26 | DOM.client = $(".client"); | ||
26 | DOM.phraseNetwork = $("#network-phrase"); | 27 | DOM.phraseNetwork = $("#network-phrase"); |
28 | DOM.phraseClient = $("#client-phrase"); | ||
27 | DOM.useEntropy = $(".use-entropy"); | 29 | DOM.useEntropy = $(".use-entropy"); |
28 | DOM.entropyContainer = $(".entropy-container"); | 30 | DOM.entropyContainer = $(".entropy-container"); |
29 | DOM.entropy = $(".entropy"); | 31 | DOM.entropy = $(".entropy"); |
@@ -77,6 +79,7 @@ | |||
77 | function init() { | 79 | function init() { |
78 | // Events | 80 | // Events |
79 | DOM.network.on("change", networkChanged); | 81 | DOM.network.on("change", networkChanged); |
82 | DOM.client.on("change", clientChanged); | ||
80 | DOM.useEntropy.on("change", setEntropyVisibility); | 83 | DOM.useEntropy.on("change", setEntropyVisibility); |
81 | DOM.entropy.on("input", delayedEntropyChanged); | 84 | DOM.entropy.on("input", delayedEntropyChanged); |
82 | DOM.entropyMnemonicLength.on("change", entropyChanged); | 85 | DOM.entropyMnemonicLength.on("change", entropyChanged); |
@@ -102,6 +105,7 @@ | |||
102 | hidePending(); | 105 | hidePending(); |
103 | hideValidationError(); | 106 | hideValidationError(); |
104 | populateNetworkSelect(); | 107 | populateNetworkSelect(); |
108 | populateClientSelect(); | ||
105 | } | 109 | } |
106 | 110 | ||
107 | // Event handlers | 111 | // Event handlers |
@@ -116,6 +120,17 @@ | |||
116 | rootKeyChanged(); | 120 | rootKeyChanged(); |
117 | } | 121 | } |
118 | } | 122 | } |
123 | |||
124 | function clientChanged(e) { | ||
125 | var clientIndex = e.target.value; | ||
126 | clients[clientIndex].onSelect(); | ||
127 | if (seed != null) { | ||
128 | phraseChanged(); | ||
129 | } | ||
130 | else { | ||
131 | rootKeyChanged(); | ||
132 | } | ||
133 | } | ||
119 | 134 | ||
120 | function setEntropyVisibility() { | 135 | function setEntropyVisibility() { |
121 | if (isUsingOwnEntropy()) { | 136 | if (isUsingOwnEntropy()) { |
@@ -710,6 +725,16 @@ | |||
710 | DOM.phraseNetwork.append(option); | 725 | DOM.phraseNetwork.append(option); |
711 | } | 726 | } |
712 | } | 727 | } |
728 | |||
729 | function populateClientSelect() { | ||
730 | for (var i=0; i<clients.length; i++) { | ||
731 | var client = clients[i]; | ||
732 | var option = $("<option>"); | ||
733 | option.attr("value", i); | ||
734 | option.text(client.name); | ||
735 | DOM.phraseClient.append(option); | ||
736 | } | ||
737 | } | ||
713 | 738 | ||
714 | function getLanguage() { | 739 | function getLanguage() { |
715 | var defaultLanguage = "english"; | 740 | var defaultLanguage = "english"; |
@@ -1140,6 +1165,30 @@ | |||
1140 | }, | 1165 | }, |
1141 | }, | 1166 | }, |
1142 | ] | 1167 | ] |
1168 | |||
1169 | var clients = [ | ||
1170 | { | ||
1171 | name: "Bitcoin Core", | ||
1172 | onSelect: function() { | ||
1173 | DOM.bip32path.val("m/0'/0'"); | ||
1174 | DOM.hardenedAddresses.prop('checked', true); | ||
1175 | }, | ||
1176 | }, | ||
1177 | { | ||
1178 | name: "blockchain.info", | ||
1179 | onSelect: function() { | ||
1180 | DOM.bip32path.val("m/44'/0'/0'"); | ||
1181 | DOM.hardenedAddresses.prop('checked', false); | ||
1182 | }, | ||
1183 | }, | ||
1184 | { | ||
1185 | name: "MultiBit HD", | ||
1186 | onSelect: function() { | ||
1187 | DOM.bip32path.val("m/0'/0"); | ||
1188 | DOM.hardenedAddresses.prop('checked', false); | ||
1189 | }, | ||
1190 | } | ||
1191 | ] | ||
1143 | 1192 | ||
1144 | init(); | 1193 | init(); |
1145 | 1194 | ||