mirror of
https://github.com/seigler/govobject-proposal
synced 2025-07-27 06:46:10 +00:00
implement transaction listener progress bar
This commit is contained in:
parent
4b4c5dd273
commit
90ad462be0
2 changed files with 23 additions and 4 deletions
22
index.html
22
index.html
|
@ -23,7 +23,8 @@
|
||||||
<link rel="stylesheet" href="css/master.css">
|
<link rel="stylesheet" href="css/master.css">
|
||||||
<script src="js/proposalGenerator.js"></script>
|
<script src="js/proposalGenerator.js"></script>
|
||||||
<script src="js/paymentCycle.js"></script>
|
<script src="js/paymentCycle.js"></script>
|
||||||
<script src="js/transactionListener.js"></script>
|
<!-- <script src="js/transactionListener.js"></script> -->
|
||||||
|
<script src="js/txListener.js"></script>
|
||||||
<script src="js/formHandler.js"></script>
|
<script src="js/formHandler.js"></script>
|
||||||
|
|
||||||
<script src="https://dev-test.dash.org/socket.io/socket.io.js"></script>
|
<script src="https://dev-test.dash.org/socket.io/socket.io.js"></script>
|
||||||
|
@ -85,7 +86,7 @@
|
||||||
|
|
||||||
proposal.walletCommands();
|
proposal.walletCommands();
|
||||||
|
|
||||||
transactionListener(proposal);
|
// transactionListener(proposal);
|
||||||
|
|
||||||
$('#btnEdit').click(function() {
|
$('#btnEdit').click(function() {
|
||||||
proposal.createProposal();
|
proposal.createProposal();
|
||||||
|
@ -107,9 +108,24 @@
|
||||||
if(err) console.log(err);
|
if(err) console.log(err);
|
||||||
if(res) {
|
if(res) {
|
||||||
console.log(res);
|
console.log(res);
|
||||||
|
|
||||||
|
// transaction exists, proceed to step three
|
||||||
|
document.getElementById('step_three').click();
|
||||||
|
document.getElementsByClassName('progress-bar')[0].style.width = "75%";
|
||||||
|
document.getElementsByClassName('progress-bar')[0].innerText = "Awaiting transaction confirmation";
|
||||||
|
|
||||||
|
$('#walletCommandsProgress').removeClass('hidden'); // probably a better way to do this....
|
||||||
|
$("#progressbar").progressbar({value: 0}); // TXListener will bump this along as confirmations occur
|
||||||
|
|
||||||
txListener.blockheight = res.blockheight;
|
txListener.blockheight = res.blockheight;
|
||||||
txListener.confirmations = res.confirmations;
|
txListener.confirmations = res.confirmations;
|
||||||
txListener.initSocket();
|
|
||||||
|
txListener.initSocket(function() {
|
||||||
|
document.getElementById('step_four').click();
|
||||||
|
document.getElementsByClassName('progress-bar')[0].style.width = "100%";
|
||||||
|
document.getElementsByClassName('progress-bar')[0].innerText = "Proposal ready for submission";
|
||||||
|
}); // callback issued after tx confirmations >= 6
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,7 +9,7 @@ function TXListener(socket, provider, transaction) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TXListener.prototype.initSocket = function() {
|
TXListener.prototype.initSocket = function(cb) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var socket = this.socket;
|
var socket = this.socket;
|
||||||
|
|
||||||
|
@ -21,6 +21,9 @@ TXListener.prototype.initSocket = function() {
|
||||||
if (err) console.log("error fetching block: " + data);
|
if (err) console.log("error fetching block: " + data);
|
||||||
self.confirmations = (res.height - self.blockheight) + 1; // compare blockHeight against transaction blockHeight
|
self.confirmations = (res.height - self.blockheight) + 1; // compare blockHeight against transaction blockHeight
|
||||||
|
|
||||||
|
if (self.confirmations >= 6) cb();
|
||||||
|
$("#progressbar").progressbar({value: ((100 / 6) * self.confirmations)});
|
||||||
|
|
||||||
console.log('confirmations: ' + self.confirmations);
|
console.log('confirmations: ' + self.confirmations);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue