diff options
author | Ian Coleman <coleman.ian@gmail.com> | 2015-10-23 09:41:49 +1100 |
---|---|---|
committer | Ian Coleman <coleman.ian@gmail.com> | 2015-10-23 09:46:17 +1100 |
commit | 18531979e830c8c094e8de0b3ee593eebd250807 (patch) | |
tree | 5dba2ea745fd05652d61ca6062b832a35a7e2c66 /src | |
parent | bffa8eda540af07f253259b155c5b23aa54d8d57 (diff) | |
download | BIP39-18531979e830c8c094e8de0b3ee593eebd250807.tar.gz BIP39-18531979e830c8c094e8de0b3ee593eebd250807.tar.zst BIP39-18531979e830c8c094e8de0b3ee593eebd250807.zip |
Strength field uses select tag
Closes #17
Diffstat (limited to 'src')
-rw-r--r-- | src/index.html | 11 | ||||
-rw-r--r-- | src/js/index.js | 15 |
2 files changed, 10 insertions, 16 deletions
diff --git a/src/index.html b/src/index.html index 34b4248..1699b39 100644 --- a/src/index.html +++ b/src/index.html | |||
@@ -66,7 +66,16 @@ | |||
66 | <label for="strength" class="col-sm-2 control-label">Number of words</label> | 66 | <label for="strength" class="col-sm-2 control-label">Number of words</label> |
67 | <div class="col-sm-10"> | 67 | <div class="col-sm-10"> |
68 | <div class="input-group"> | 68 | <div class="input-group"> |
69 | <input type="number" class="strength form-control" id="strength" value="15"> | 69 | <select id="strength" class="strength form-control"> |
70 | <option val="3">3</option> | ||
71 | <option val="6">6</option> | ||
72 | <option val="9">9</option> | ||
73 | <option val="12">12</option> | ||
74 | <option val="15" selected>15</option> | ||
75 | <option val="18">18</option> | ||
76 | <option val="21">21</option> | ||
77 | <option val="24">24</option> | ||
78 | </select> | ||
70 | <span class="input-group-btn"> | 79 | <span class="input-group-btn"> |
71 | <button class="btn generate">Generate Random Mnemonic</button> | 80 | <button class="btn generate">Generate Random Mnemonic</button> |
72 | </span> | 81 | </span> |
diff --git a/src/js/index.js b/src/js/index.js index 0a662a8..9dabe95 100644 --- a/src/js/index.js +++ b/src/js/index.js | |||
@@ -162,21 +162,6 @@ | |||
162 | return; | 162 | return; |
163 | } | 163 | } |
164 | var numWords = parseInt(DOM.strength.val()); | 164 | var numWords = parseInt(DOM.strength.val()); |
165 | // Check strength is an integer | ||
166 | if (isNaN(numWords)) { | ||
167 | DOM.strength.val("12"); | ||
168 | numWords = 12; | ||
169 | } | ||
170 | // Check strength is a multiple of 32, if not round it down | ||
171 | if (numWords % 3 != 0) { | ||
172 | numWords = Math.floor(numWords / 3) * 3; | ||
173 | DOM.strength.val(numWords); | ||
174 | } | ||
175 | // Check strength is at least 32 | ||
176 | if (numWords == 0) { | ||
177 | numWords = 3; | ||
178 | DOM.strength.val(numWords); | ||
179 | } | ||
180 | var strength = numWords / 3 * 32; | 165 | var strength = numWords / 3 * 32; |
181 | var words = mnemonic.generate(strength); | 166 | var words = mnemonic.generate(strength); |
182 | DOM.phrase.val(words); | 167 | DOM.phrase.val(words); |