diff --git a/index.html b/index.html
index 4b15596..ca8d5e7 100755
--- a/index.html
+++ b/index.html
@@ -26,19 +26,26 @@
-
diff --git a/js/transactionListener.js b/js/transactionListener.js
index 32daf79..193fb9f 100755
--- a/js/transactionListener.js
+++ b/js/transactionListener.js
@@ -1,6 +1,9 @@
function transactionListener(proposal) {
$('#feeTxid').on('input', function() {
+
+ $('.walletCommands#walletCommandsSubmit').removeClass('hidden');
+
if ($(this).val().length > 0) {
var submitCommand = "gobject submit " + $('#parentHash').val() + " " + $('#revision').val() + " " + $('#time').val() + " " + proposal.gov.serialize() + " " + $(this).val();
@@ -28,9 +31,11 @@ function transactionListener(proposal) {
$.getJSON(provider + 'insight-api-dash/tx/' + txidfield.val(), function(data) {
txidfield.attr("disabled", true);
$('.walletCommands#walletCommandsProgress').removeClass('hidden');
+
document.getElementById('step_three').click();
document.getElementsByClassName('progress-bar')[0].style.width = "75%";
document.getElementsByClassName('progress-bar')[0].innerText = "Awaiting network confirmations...";
+
var txid = data.tx;
var confirmations = data.confirmations;
var conftxt;
@@ -129,6 +134,7 @@ function transactionListener(proposal) {
progbarval = 100;
$("#progresstxt").text("Your transaction has " + confirmations + " confirmations. You can now submit the proposal.");
$('.walletCommands#walletCommandsSubmit').removeClass('hidden');
+
document.getElementById('step_four').click();
document.getElementsByClassName('progress-bar')[0].style.width = "100%";
document.getElementsByClassName('progress-bar')[0].innerText = "Success";
diff --git a/js/txListener.js b/js/txListener.js
new file mode 100755
index 0000000..1f59124
--- /dev/null
+++ b/js/txListener.js
@@ -0,0 +1,83 @@
+function TXListener(socket, provider, transaction) {
+
+ this.socket = socket;
+ this.provider = provider;
+ this.transaction = transaction;
+
+ this.blockheight = null;
+ this.confirmations = null;
+
+}
+
+TXListener.prototype.initSocket = function() {
+ var self = this;
+ var socket = this.socket;
+
+ socket.on('block', function(data) {
+ console.log('block: '+ data);
+
+ 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
+
+ console.log('confirmations: ' + self.confirmations);
+
+ });
+ });
+
+};
+
+TXListener.prototype.getTx = function(cb) {
+ var txid = this.transaction;
+
+ var opts = {
+ type: "GET",
+ route: "insight-api-dash/tx/"+txid,
+ data: {
+ format: "json"
+ }
+ };
+
+ this._fetch(opts, cb);
+};
+
+TXListener.prototype.getBlock = function(hash, cb) {
+
+ var opts = {
+ type: "GET",
+ route: "insight-api-dash/block/"+hash,
+ data: {
+ format: "json"
+ }
+ };
+
+ this._fetch(opts, cb);
+};
+
+TXListener.prototype._fetch = function(opts,cb) {
+ var self = this;
+ var provider = opts.provider || self.provider;
+
+ if(opts.type && opts.route && opts.data) {
+
+ jQuery.ajax({
+ type: opts.type,
+ url: provider + opts.route,
+ data: JSON.stringify(opts.data),
+ contentType: "application/json; charset=utf-8",
+ crossDomain: true,
+ dataType: "json",
+ success: function (data, status, jqXHR) {
+ cb(null, data);
+ },
+ error: function (jqXHR, status, error) {
+ var err = eval("(" + jqXHR.responseText + ")");
+ cb(err, null);
+ }
+ });
+
+ } else {
+ cb('missing parameter',null);
+ }
+};
\ No newline at end of file