aboutsummaryrefslogtreecommitdiff
path: root/src/js/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/js/index.js')
-rw-r--r--src/js/index.js36
1 files changed, 32 insertions, 4 deletions
diff --git a/src/js/index.js b/src/js/index.js
index cd7f281..1cc77d3 100644
--- a/src/js/index.js
+++ b/src/js/index.js
@@ -109,6 +109,7 @@
109 DOM.entropyContainer.addClass("hidden"); 109 DOM.entropyContainer.addClass("hidden");
110 DOM.generateContainer.removeClass("hidden"); 110 DOM.generateContainer.removeClass("hidden");
111 DOM.phrase.prop("readonly", false); 111 DOM.phrase.prop("readonly", false);
112 hidePending();
112 } 113 }
113 } 114 }
114 115
@@ -149,8 +150,31 @@
149 } 150 }
150 151
151 function entropyChanged() { 152 function entropyChanged() {
153 // If blank entropy, clear mnemonic, addresses, errors
154 if (DOM.entropy.val().trim().length == 0) {
155 clearDisplay();
156 hideEntropyError();
157 DOM.phrase.val("");
158 showValidationError("Blank entropy");
159 return;
160 }
161 // Get the current phrase to detect changes
162 var phrase = DOM.phrase.val();
163 // Set the phrase from the entropy
152 setMnemonicFromEntropy(); 164 setMnemonicFromEntropy();
153 phraseChanged(); 165 // Recalc addresses if the phrase has changed
166 var newPhrase = DOM.phrase.val();
167 if (newPhrase != phrase) {
168 if (newPhrase.length == 0) {
169 clearDisplay();
170 }
171 else {
172 phraseChanged();
173 }
174 }
175 else {
176 hidePending();
177 }
154 } 178 }
155 179
156 function delayedRootKeyChanged() { 180 function delayedRootKeyChanged() {
@@ -311,10 +335,13 @@
311 } 335 }
312 336
313 function findPhraseErrors(phrase) { 337 function findPhraseErrors(phrase) {
314 // TODO make this right
315 // Preprocess the words 338 // Preprocess the words
316 phrase = mnemonic.normalizeString(phrase); 339 phrase = mnemonic.normalizeString(phrase);
317 var words = phraseToWordArray(phrase); 340 var words = phraseToWordArray(phrase);
341 // Detect blank phrase
342 if (words.length == 0) {
343 return "Blank mnemonic";
344 }
318 // Check each word 345 // Check each word
319 for (var i=0; i<words.length; i++) { 346 for (var i=0; i<words.length; i++) {
320 var word = words[i]; 347 var word = words[i];
@@ -701,10 +728,11 @@
701 728
702 function setMnemonicFromEntropy() { 729 function setMnemonicFromEntropy() {
703 hideEntropyError(); 730 hideEntropyError();
704 // Work out minimum base for entropy 731 // Get entropy value
705 var entropyStr = DOM.entropy.val(); 732 var entropyStr = DOM.entropy.val();
733 // Work out minimum base for entropy
706 var entropy = Entropy.fromString(entropyStr); 734 var entropy = Entropy.fromString(entropyStr);
707 if (entropy.hexStr.length == 0) { 735 if (entropy.binaryStr.length == 0) {
708 return; 736 return;
709 } 737 }
710 // Show entropy details 738 // Show entropy details