]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/commitdiff
Network select populated automatically by js
authorIan Coleman <coleman.ian@gmail.com>
Sun, 16 Aug 2015 04:32:25 +0000 (14:32 +1000)
committerIan Coleman <coleman.ian@gmail.com>
Sun, 16 Aug 2015 04:32:25 +0000 (14:32 +1000)
src/index.html
src/js/index.js

index f43c505f9df530124df3212ed737066ee535a44f..9ab7f6d54ffcee597a6837f3f951399f38fc191c 100644 (file)
                             <label for="network-phrase" class="col-sm-2 control-label">Coin</label>
                             <div class="col-sm-10">
                                 <select id="network-phrase" class="network form-control">
-                                    <option value="bitcoin">Bitcoin</option>
-                                    <option value="bitcoin-testnet">Bitcoin Testnet</option>
-                                    <option value="litecoin">Litecoin</option>
-                                    <option value="dogecoin">Dogecoin</option>
+                                    <!-- populated by javascript -->
                                 </select>
                             </div>
                         </div>
index e5e45937ab05a602ec30c39722f1ad77c95cb131..9ea5bb56fcc613d2c63f0bf62410896c29cb11b2 100644 (file)
         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();
     }
             .hide();
     }
 
-    var networks = {
-        "bitcoin": {
+    function populateNetworkSelect() {
+        for (var i=0; i<networks.length; i++) {
+            var network = networks[i];
+            var option = $("<option>");
+            option.attr("value", i);
+            option.text(network.name);
+            DOM.phraseNetwork.append(option);
+        }
+    }
+
+    var networks = [
+        {
             name: "Bitcoin",
             onSelect: function() {
                 network = Bitcoin.networks.bitcoin;
                 DOM.myceliumPath.val("m/44'/0'/0'/0");
             },
         },
-        "bitcoin-testnet": {
+        {
             name: "Bitcoin Testnet",
             onSelect: function() {
                 network = Bitcoin.networks.testnet;
                 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();