diff options
author | Ian Coleman <coleman.ian@gmail.com> | 2014-09-25 10:32:50 +1000 |
---|---|---|
committer | Ian Coleman <coleman.ian@gmail.com> | 2014-09-25 10:32:50 +1000 |
commit | 04f789cdbdb8e50511efdf97c900f7f83662eedb (patch) | |
tree | 86e485edc43a2dfca8a4d1db2ef77b6927fa2fde /src/js/index.js | |
parent | d198865f7552237188659c778c0456988c6619df (diff) | |
download | BIP39-04f789cdbdb8e50511efdf97c900f7f83662eedb.tar.gz BIP39-04f789cdbdb8e50511efdf97c900f7f83662eedb.tar.zst BIP39-04f789cdbdb8e50511efdf97c900f7f83662eedb.zip |
Update only happens when phrase is changed
ie not on keyup where the key is ctrl or arrow-key etc.
Diffstat (limited to 'src/js/index.js')
-rw-r--r-- | src/js/index.js | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/js/index.js b/src/js/index.js index cee8ffb..5bdb7ab 100644 --- a/src/js/index.js +++ b/src/js/index.js | |||
@@ -32,6 +32,8 @@ | |||
32 | DOM.privateKeyToggle = $(".private-key-toggle"); | 32 | DOM.privateKeyToggle = $(".private-key-toggle"); |
33 | 33 | ||
34 | var derivationPath = DOM.bip44path.val(); | 34 | var derivationPath = DOM.bip44path.val(); |
35 | var currentPhrase = DOM.phrase.val(); | ||
36 | var currentPassphrase = DOM.passphrase.val(); | ||
35 | 37 | ||
36 | function init() { | 38 | function init() { |
37 | // Events | 39 | // Events |
@@ -56,6 +58,9 @@ | |||
56 | // Event handlers | 58 | // Event handlers |
57 | 59 | ||
58 | function delayedPhraseChanged() { | 60 | function delayedPhraseChanged() { |
61 | if (!hasChanged()) { | ||
62 | return; | ||
63 | } | ||
59 | hideValidationError(); | 64 | hideValidationError(); |
60 | showPending(); | 65 | showPending(); |
61 | if (phraseChangeTimeoutEvent != null) { | 66 | if (phraseChangeTimeoutEvent != null) { |
@@ -85,6 +90,9 @@ | |||
85 | calcBip32Seed(phrase, passphrase, derivationPath); | 90 | calcBip32Seed(phrase, passphrase, derivationPath); |
86 | displayBip32Info(); | 91 | displayBip32Info(); |
87 | hidePending(); | 92 | hidePending(); |
93 | // Set current state so we only update as needed | ||
94 | currentPhrase = phrase; | ||
95 | currentPassphrase = passphrase; | ||
88 | } | 96 | } |
89 | 97 | ||
90 | function generateClicked() { | 98 | function generateClicked() { |
@@ -106,7 +114,9 @@ | |||
106 | } | 114 | } |
107 | 115 | ||
108 | function derivationChanged() { | 116 | function derivationChanged() { |
109 | delayedPhraseChanged(); | 117 | hideValidationError(); |
118 | showPending(); | ||
119 | setTimeout(phraseChanged, 50); | ||
110 | } | 120 | } |
111 | 121 | ||
112 | function bip32Changed() { | 122 | function bip32Changed() { |
@@ -335,6 +345,12 @@ | |||
335 | .hide(); | 345 | .hide(); |
336 | } | 346 | } |
337 | 347 | ||
348 | function hasChanged() { | ||
349 | var phraseChanged = DOM.phrase.val() != currentPhrase; | ||
350 | var passphraseChanged = DOM.passphrase.val() != currentPassphrase; | ||
351 | return phraseChanged || passphraseChanged; | ||
352 | } | ||
353 | |||
338 | init(); | 354 | init(); |
339 | 355 | ||
340 | })(); | 356 | })(); |