]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/commitdiff
Strength field uses select tag
authorIan Coleman <coleman.ian@gmail.com>
Thu, 22 Oct 2015 22:41:49 +0000 (09:41 +1100)
committerIan Coleman <coleman.ian@gmail.com>
Thu, 22 Oct 2015 22:46:17 +0000 (09:46 +1100)
Closes #17

bip39-standalone.html
src/index.html
src/js/index.js

index 5ef69eacea5452a9bf741784ac912c3c60fcfd9d..28f0a556aa31ab23355b83ce7944421628a9d1e5 100644 (file)
                             <label for="strength" class="col-sm-2 control-label">Number of words</label>
                             <div class="col-sm-10">
                                 <div class="input-group">
-                                    <input type="number" class="strength form-control" id="strength" value="15">
+                                    <select id="strength" class="strength form-control">
+                                        <option val="3">3</option>
+                                        <option val="6">6</option>
+                                        <option val="9">9</option>
+                                        <option val="12">12</option>
+                                        <option val="15" selected>15</option>
+                                        <option val="18">18</option>
+                                        <option val="21">21</option>
+                                        <option val="24">24</option>
+                                    </select>
                                     <span class="input-group-btn">
                                         <button class="btn generate">Generate Random Mnemonic</button>
                                     </span>
@@ -14753,21 +14762,6 @@ var Mnemonic = function(language) {
             return;
         }
         var numWords = parseInt(DOM.strength.val());
-        // Check strength is an integer
-        if (isNaN(numWords)) {
-            DOM.strength.val("12");
-            numWords = 12;
-        }
-        // Check strength is a multiple of 32, if not round it down
-        if (numWords % 3 != 0) {
-            numWords = Math.floor(numWords / 3) * 3;
-            DOM.strength.val(numWords);
-        }
-        // Check strength is at least 32
-        if (numWords == 0) {
-            numWords = 3;
-            DOM.strength.val(numWords);
-        }
         var strength = numWords / 3 * 32;
         var words = mnemonic.generate(strength);
         DOM.phrase.val(words);
index 34b4248de61b4acd2f6e6256954bf7d67a81f89c..1699b39c5fb25c55680c54b0afcf6a5e0f328340 100644 (file)
                             <label for="strength" class="col-sm-2 control-label">Number of words</label>
                             <div class="col-sm-10">
                                 <div class="input-group">
-                                    <input type="number" class="strength form-control" id="strength" value="15">
+                                    <select id="strength" class="strength form-control">
+                                        <option val="3">3</option>
+                                        <option val="6">6</option>
+                                        <option val="9">9</option>
+                                        <option val="12">12</option>
+                                        <option val="15" selected>15</option>
+                                        <option val="18">18</option>
+                                        <option val="21">21</option>
+                                        <option val="24">24</option>
+                                    </select>
                                     <span class="input-group-btn">
                                         <button class="btn generate">Generate Random Mnemonic</button>
                                     </span>
index 0a662a81e8e69d05e961fb04e72a32ef452101b8..9dabe9534677e37c56985a6bfc43366f2c289695 100644 (file)
             return;
         }
         var numWords = parseInt(DOM.strength.val());
-        // Check strength is an integer
-        if (isNaN(numWords)) {
-            DOM.strength.val("12");
-            numWords = 12;
-        }
-        // Check strength is a multiple of 32, if not round it down
-        if (numWords % 3 != 0) {
-            numWords = Math.floor(numWords / 3) * 3;
-            DOM.strength.val(numWords);
-        }
-        // Check strength is at least 32
-        if (numWords == 0) {
-            numWords = 3;
-            DOM.strength.val(numWords);
-        }
         var strength = numWords / 3 * 32;
         var words = mnemonic.generate(strength);
         DOM.phrase.val(words);