From 7f15cb6eb98d29aeb64ec4a4ad37b81a66eb6103 Mon Sep 17 00:00:00 2001 From: Ian Coleman Date: Sun, 16 Aug 2015 14:32:25 +1000 Subject: [PATCH] Network select populated automatically by js --- src/index.html | 5 +---- 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 @@
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 @@ disableForms(); hidePending(); hideValidationError(); + populateNetworkSelect(); } // Event handlers function networkChanged(e) { var network = e.target.value; - if (network in networks) { - networks[network].onSelect(); - } - else { - // TODO - } + networks[network].onSelect(); setBip44DerivationPath(); delayedPhraseChanged(); } @@ -389,8 +385,18 @@ .hide(); } - var networks = { - "bitcoin": { + function populateNetworkSelect() { + for (var i=0; i"); + option.attr("value", i); + option.text(network.name); + DOM.phraseNetwork.append(option); + } + } + + var networks = [ + { name: "Bitcoin", onSelect: function() { network = Bitcoin.networks.bitcoin; @@ -398,7 +404,7 @@ DOM.myceliumPath.val("m/44'/0'/0'/0"); }, }, - "bitcoin-testnet": { + { name: "Bitcoin Testnet", onSelect: function() { network = Bitcoin.networks.testnet; @@ -406,21 +412,21 @@ DOM.myceliumPath.val("m/44'/1'/0'/0"); }, }, - "litecoin": { + { name: "Litecoin", onSelect: function() { network = Bitcoin.networks.litecoin; DOM.bip44coin.val(2); }, }, - "dogecoin": { + { name: "Dogecoin", onSelect: function() { network = Bitcoin.networks.dogecoin; DOM.bip44coin.val(3); }, }, - } + ] init(); -- 2.41.0