From 97b41dc065374083680d3dcb8e1bdc8895ee2f6b Mon Sep 17 00:00:00 2001 From: hunterlester Date: Sun, 11 Dec 2016 22:19:05 -0800 Subject: [PATCH] confirmations counted, transitions to final step --- index.html | 1 - js/txListener.js | 14 ++++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/index.html b/index.html index ec3e9ee..429061a 100755 --- a/index.html +++ b/index.html @@ -123,7 +123,6 @@ txListener.confirmations = res.confirmations; txListener.initSocket(function() { - console.log("callback called, step 4"); $('#walletCommandsSubmit').removeClass('hidden'); document.getElementById('step_four').click(); document.getElementsByClassName('progress-bar')[0].style.width = "100%"; diff --git a/js/txListener.js b/js/txListener.js index 3cdd7be..7ef1bb9 100755 --- a/js/txListener.js +++ b/js/txListener.js @@ -12,6 +12,7 @@ function TXListener(socket, provider, transaction) { TXListener.prototype.initSocket = function(cb) { var self = this; var socket = this.socket; + var confirmations = 0; socket.on('block', function(data) { console.log('block: '+ data); @@ -19,18 +20,15 @@ TXListener.prototype.initSocket = function(cb) { self.getBlock(data, function(err, res) { if (err) console.log("error fetching block: " + data); - self.confirmations = (res.height - self.blockheight) + 1; // compare blockHeight against transaction blockHeight - var confirmation_count = (res.height - self.confirmations) + 1; - console.log("res: ", res); - console.log("self: ", self); - console.log(confirmation_count); + //self.confirmations = (res.height - self.blockheight) + 1; // compare blockHeight against transaction blockHeight + confirmations++; - if (confirmation_count >= 6) { + if (confirmations >= 6) { cb(); }; - $("#progressbar").progressbar({value: ((100 / 6) * self.confirmations)}); + $("#progressbar").progressbar({value: ((100 / 6) * confirmations)}); - console.log('confirmations: ' + self.confirmations); + console.log('confirmations: ' + confirmations); }); });