diff options
-rw-r--r-- | src/js/index.js | 55 |
1 files changed, 38 insertions, 17 deletions
diff --git a/src/js/index.js b/src/js/index.js index 20fa000..e5e4593 100644 --- a/src/js/index.js +++ b/src/js/index.js | |||
@@ -68,24 +68,12 @@ | |||
68 | // Event handlers | 68 | // Event handlers |
69 | 69 | ||
70 | function networkChanged(e) { | 70 | function networkChanged(e) { |
71 | var n = e.target.value; | 71 | var network = e.target.value; |
72 | if (n == "bitcoin") { | 72 | if (network in networks) { |
73 | network = Bitcoin.networks.bitcoin; | 73 | networks[network].onSelect(); |
74 | DOM.bip44coin.val(0); | ||
75 | DOM.myceliumPath.val("m/44'/0'/0'/0"); | ||
76 | } | 74 | } |
77 | else if (n == "bitcoin-testnet") { | 75 | else { |
78 | network = Bitcoin.networks.testnet; | 76 | // TODO |
79 | DOM.bip44coin.val(1); | ||
80 | DOM.myceliumPath.val("m/44'/1'/0'/0"); | ||
81 | } | ||
82 | else if (n == "litecoin") { | ||
83 | network = Bitcoin.networks.litecoin; | ||
84 | DOM.bip44coin.val(2); | ||
85 | } | ||
86 | else if (n == "dogecoin") { | ||
87 | network = Bitcoin.networks.dogecoin; | ||
88 | DOM.bip44coin.val(3); | ||
89 | } | 77 | } |
90 | setBip44DerivationPath(); | 78 | setBip44DerivationPath(); |
91 | delayedPhraseChanged(); | 79 | delayedPhraseChanged(); |
@@ -401,6 +389,39 @@ | |||
401 | .hide(); | 389 | .hide(); |
402 | } | 390 | } |
403 | 391 | ||
392 | var networks = { | ||
393 | "bitcoin": { | ||
394 | name: "Bitcoin", | ||
395 | onSelect: function() { | ||
396 | network = Bitcoin.networks.bitcoin; | ||
397 | DOM.bip44coin.val(0); | ||
398 | DOM.myceliumPath.val("m/44'/0'/0'/0"); | ||
399 | }, | ||
400 | }, | ||
401 | "bitcoin-testnet": { | ||
402 | name: "Bitcoin Testnet", | ||
403 | onSelect: function() { | ||
404 | network = Bitcoin.networks.testnet; | ||
405 | DOM.bip44coin.val(1); | ||
406 | DOM.myceliumPath.val("m/44'/1'/0'/0"); | ||
407 | }, | ||
408 | }, | ||
409 | "litecoin": { | ||
410 | name: "Litecoin", | ||
411 | onSelect: function() { | ||
412 | network = Bitcoin.networks.litecoin; | ||
413 | DOM.bip44coin.val(2); | ||
414 | }, | ||
415 | }, | ||
416 | "dogecoin": { | ||
417 | name: "Dogecoin", | ||
418 | onSelect: function() { | ||
419 | network = Bitcoin.networks.dogecoin; | ||
420 | DOM.bip44coin.val(3); | ||
421 | }, | ||
422 | }, | ||
423 | } | ||
424 | |||
404 | init(); | 425 | init(); |
405 | 426 | ||
406 | })(); | 427 | })(); |