diff options
author | Ian Coleman <coleman.ian@gmail.com> | 2015-08-16 14:32:25 +1000 |
---|---|---|
committer | Ian Coleman <coleman.ian@gmail.com> | 2015-08-16 14:32:25 +1000 |
commit | 7f15cb6eb98d29aeb64ec4a4ad37b81a66eb6103 (patch) | |
tree | 61d6b70dd5693c317ea749a3f2b3b5a6b1776ff5 /src | |
parent | 7a995731ad7c43db248080d075fee751a09cadba (diff) | |
download | BIP39-7f15cb6eb98d29aeb64ec4a4ad37b81a66eb6103.tar.gz BIP39-7f15cb6eb98d29aeb64ec4a4ad37b81a66eb6103.tar.zst BIP39-7f15cb6eb98d29aeb64ec4a4ad37b81a66eb6103.zip |
Network select populated automatically by js
Diffstat (limited to 'src')
-rw-r--r-- | src/index.html | 5 | ||||
-rw-r--r-- | src/js/index.js | 30 |
2 files changed, 19 insertions, 16 deletions
diff --git a/src/index.html b/src/index.html index f43c505..9ab7f6d 100644 --- a/src/index.html +++ b/src/index.html | |||
@@ -78,10 +78,7 @@ | |||
78 | <label for="network-phrase" class="col-sm-2 control-label">Coin</label> | 78 | <label for="network-phrase" class="col-sm-2 control-label">Coin</label> |
79 | <div class="col-sm-10"> | 79 | <div class="col-sm-10"> |
80 | <select id="network-phrase" class="network form-control"> | 80 | <select id="network-phrase" class="network form-control"> |
81 | <option value="bitcoin">Bitcoin</option> | 81 | <!-- populated by javascript --> |
82 | <option value="bitcoin-testnet">Bitcoin Testnet</option> | ||
83 | <option value="litecoin">Litecoin</option> | ||
84 | <option value="dogecoin">Dogecoin</option> | ||
85 | </select> | 82 | </select> |
86 | </div> | 83 | </div> |
87 | </div> | 84 | </div> |
diff --git a/src/js/index.js b/src/js/index.js index e5e4593..9ea5bb5 100644 --- a/src/js/index.js +++ b/src/js/index.js | |||
@@ -63,18 +63,14 @@ | |||
63 | disableForms(); | 63 | disableForms(); |
64 | hidePending(); | 64 | hidePending(); |
65 | hideValidationError(); | 65 | hideValidationError(); |
66 | populateNetworkSelect(); | ||
66 | } | 67 | } |
67 | 68 | ||
68 | // Event handlers | 69 | // Event handlers |
69 | 70 | ||
70 | function networkChanged(e) { | 71 | function networkChanged(e) { |
71 | var network = e.target.value; | 72 | var network = e.target.value; |
72 | if (network in networks) { | 73 | networks[network].onSelect(); |
73 | networks[network].onSelect(); | ||
74 | } | ||
75 | else { | ||
76 | // TODO | ||
77 | } | ||
78 | setBip44DerivationPath(); | 74 | setBip44DerivationPath(); |
79 | delayedPhraseChanged(); | 75 | delayedPhraseChanged(); |
80 | } | 76 | } |
@@ -389,8 +385,18 @@ | |||
389 | .hide(); | 385 | .hide(); |
390 | } | 386 | } |
391 | 387 | ||
392 | var networks = { | 388 | function populateNetworkSelect() { |
393 | "bitcoin": { | 389 | for (var i=0; i<networks.length; i++) { |
390 | var network = networks[i]; | ||
391 | var option = $("<option>"); | ||
392 | option.attr("value", i); | ||
393 | option.text(network.name); | ||
394 | DOM.phraseNetwork.append(option); | ||
395 | } | ||
396 | } | ||
397 | |||
398 | var networks = [ | ||
399 | { | ||
394 | name: "Bitcoin", | 400 | name: "Bitcoin", |
395 | onSelect: function() { | 401 | onSelect: function() { |
396 | network = Bitcoin.networks.bitcoin; | 402 | network = Bitcoin.networks.bitcoin; |
@@ -398,7 +404,7 @@ | |||
398 | DOM.myceliumPath.val("m/44'/0'/0'/0"); | 404 | DOM.myceliumPath.val("m/44'/0'/0'/0"); |
399 | }, | 405 | }, |
400 | }, | 406 | }, |
401 | "bitcoin-testnet": { | 407 | { |
402 | name: "Bitcoin Testnet", | 408 | name: "Bitcoin Testnet", |
403 | onSelect: function() { | 409 | onSelect: function() { |
404 | network = Bitcoin.networks.testnet; | 410 | network = Bitcoin.networks.testnet; |
@@ -406,21 +412,21 @@ | |||
406 | DOM.myceliumPath.val("m/44'/1'/0'/0"); | 412 | DOM.myceliumPath.val("m/44'/1'/0'/0"); |
407 | }, | 413 | }, |
408 | }, | 414 | }, |
409 | "litecoin": { | 415 | { |
410 | name: "Litecoin", | 416 | name: "Litecoin", |
411 | onSelect: function() { | 417 | onSelect: function() { |
412 | network = Bitcoin.networks.litecoin; | 418 | network = Bitcoin.networks.litecoin; |
413 | DOM.bip44coin.val(2); | 419 | DOM.bip44coin.val(2); |
414 | }, | 420 | }, |
415 | }, | 421 | }, |
416 | "dogecoin": { | 422 | { |
417 | name: "Dogecoin", | 423 | name: "Dogecoin", |
418 | onSelect: function() { | 424 | onSelect: function() { |
419 | network = Bitcoin.networks.dogecoin; | 425 | network = Bitcoin.networks.dogecoin; |
420 | DOM.bip44coin.val(3); | 426 | DOM.bip44coin.val(3); |
421 | }, | 427 | }, |
422 | }, | 428 | }, |
423 | } | 429 | ] |
424 | 430 | ||
425 | init(); | 431 | init(); |
426 | 432 | ||