]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/blobdiff - bip39-standalone.html
Generation process stopped when table rows cleared
[perso/Immae/Projets/Cryptomonnaies/BIP39.git] / bip39-standalone.html
index 5158b108ebed17ffe074807684de320592685a40..afef084e9264e880e2291807f148b7525cf021e9 100644 (file)
@@ -18664,6 +18664,8 @@ window.Entropy = new (function() {
     var phraseChangeTimeoutEvent = null;
     var rootKeyChangedTimeoutEvent = null;
 
+    var generationProcesses = [];
+
     var DOM = {};
     DOM.network = $(".network");
     DOM.phraseNetwork = $("#network-phrase");
@@ -19157,14 +19159,28 @@ window.Entropy = new (function() {
     }
 
     function displayAddresses(start, total) {
-        for (var i=0; i<total; i++) {
-            var index = i + start;
-            new TableRow(index);
-        }
+        generationProcesses.push(new (function() {
+
+            var rows = [];
+
+            this.stop = function() {
+                for (var i=0; i<rows.length; i++) {
+                    rows[i].shouldGenerate = false;
+                }
+            }
+
+            for (var i=0; i<total; i++) {
+                var index = i + start;
+                rows.push(new TableRow(index));
+            }
+
+        })());
     }
 
     function TableRow(index) {
 
+        var self = this;
+        this.shouldGenerate = true;
         var useHardenedAddresses = DOM.hardenedAddresses.prop("checked");
 
         function init() {
@@ -19173,6 +19189,9 @@ window.Entropy = new (function() {
 
         function calculateValues() {
             setTimeout(function() {
+                if (!self.shouldGenerate) {
+                    return;
+                }
                 var key = "";
                 if (useHardenedAddresses) {
                     key = bip32ExtendedKey.deriveHardened(index);
@@ -19223,6 +19242,14 @@ window.Entropy = new (function() {
 
     function clearAddressesList() {
         DOM.addresses.empty();
+        stopGenerating();
+    }
+
+    function stopGenerating() {
+        while (generationProcesses.length > 0) {
+            var generation = generationProcesses.shift();
+            generation.stop();
+        }
     }
 
     function clearKey() {