progress bar while waiting for fee tx confirmations

This commit is contained in:
Cofresi 2016-11-22 21:12:16 -04:00
parent 5e3d2530aa
commit 532aecb75d

View file

@ -18,10 +18,12 @@
//number of days to have as buffer for proposal start date before jumping to next month //number of days to have as buffer for proposal start date before jumping to next month
var bufferdays = 3; var bufferdays = 3;
var blockheight; var blockheight;
var progresstxt = "As of yet your transaction has 0 confirmations. We'll wait for 6 confirmations until you can submit your proposal. Waiting for new blocks to confirm...";
var gov = new Bitcore.GovObject.Proposal(); var gov = new Bitcore.GovObject.Proposal();
$(document).ready(function() { $(document).ready(function() {
$("#progresstxt").text(progresstxt);
$.getJSON(apiserversocket + "insight-api-dash/status?q=getinfo", function( data ) { $.getJSON(apiserversocket + "insight-api-dash/status?q=getinfo", function( data ) {
var timefield = $("#time"); var timefield = $("#time");
timefield.val(Math.floor((new Date).getTime() / 1000)); timefield.val(Math.floor((new Date).getTime() / 1000));
@ -154,9 +156,15 @@
// first check if transactionid is already in api // first check if transactionid is already in api
$.getJSON(apiserversocket + 'insight-api-dash/tx/' + txidfield.val(), function(data) { $.getJSON(apiserversocket + 'insight-api-dash/tx/' + txidfield.val(), function(data) {
txidfield.attr("disabled", true); txidfield.attr("disabled", true);
$('.walletCommands#walletCommandsProgress').removeClass('hidden');
var txid = data.tx; var txid = data.tx;
var confirmations = data.confirmations; var confirmations = data.confirmations;
var conftxt;
var conftxt2;
console.log('Transaction has ' + confirmations + ' confirmation(s)'); console.log('Transaction has ' + confirmations + ' confirmation(s)');
$( "#progressbar" ).progressbar({
value: 100/6*confirmations
});
if (confirmations != 'undefined' && $.isNumeric(confirmations)) { if (confirmations != 'undefined' && $.isNumeric(confirmations)) {
var socket = io(apiserversocket); var socket = io(apiserversocket);
@ -189,6 +197,22 @@
if (found) { if (found) {
console.log('all good. Count up confirmations.'); console.log('all good. Count up confirmations.');
confirmations = confirmations + 1; confirmations = confirmations + 1;
$( "#progressbar" ).progressbar({
value: 100/6*confirmations
});
if (confirmations == 1) {
conftxt = 'confirmation';
conftxt2 = 'confirmations';
}
else if (confirmations == 5) {
conftxt = 'confirmations';
conftxt2 = 'confirmation';
}
else {
conftxt = 'confirmations';
conftxt2 = 'confirmations';
}
$("#progresstxt").text("Your transaction has " + confirmations + " " + conftxt + ". Waiting for " + (6 - confirmations) + " more " + conftxt2 + "...");
console.log('we have ' + confirmations + ' confirmations...'); console.log('we have ' + confirmations + ' confirmations...');
} }
else { else {
@ -206,10 +230,27 @@
else { else {
// for the time being just count up the confirmations without confirming everytime if the transaction is still inside the previous blocks // for the time being just count up the confirmations without confirming everytime if the transaction is still inside the previous blocks
confirmations = confirmations + 1; confirmations = confirmations + 1;
$( "#progressbar" ).progressbar({
value: 100/6*confirmations
});
if (confirmations == 1) {
conftxt = 'confirmation';
conftxt2 = 'confirmations';
}
else if (confirmations == 5) {
conftxt = 'confirmations';
conftxt2 = 'confirmation';
}
else {
conftxt = 'confirmations';
conftxt2 = 'confirmations';
}
$("#progresstxt").text("Your transaction has " + confirmations + " " + conftxt + ". Waiting for " + (6 - confirmations) + " more " + conftxt2 + "...");
console.log('we have ' + confirmations + ' confirmations...'); console.log('we have ' + confirmations + ' confirmations...');
} }
if (confirmations >= 6) { if (confirmations >= 6) {
$("#progresstxt").text("Your transaction has " + confirmations + " confirmations. You can now submit the proposal.");
$('.walletCommands#walletCommandsSubmit').removeClass('hidden'); $('.walletCommands#walletCommandsSubmit').removeClass('hidden');
} }
}); });
@ -229,15 +270,38 @@
var blockhash = data; var blockhash = data;
// for the time being just count up the confirmations without confirming everytime if the transaction is still inside the previous blocks // for the time being just count up the confirmations without confirming everytime if the transaction is still inside the previous blocks
confirmations = confirmations + 1; confirmations = confirmations + 1;
$("#progressbar").progressbar({
value: 100/6*confirmations
});
if (confirmations = 1) {
conftxt = 'confirmation';
conftxt2 = 'confirmations';
}
else if (confirmations = 5) {
conftxt = 'confirmations';
conftxt2 = 'confirmation';
}
else {
conftxt = 'confirmations';
conftxt2 = 'confirmations';
}
$("#progresstxt").text("Your transaction has " + confirmations + " " + conftxt + ". Waiting for " + (6 - confirmations) + " more " + conftxt2 + "...");
console.log('we have ' + confirmations + ' confirmations...'); console.log('we have ' + confirmations + ' confirmations...');
if (confirmations >= 6) { if (confirmations >= 6) {
$("#progressbar").progressbar({
value: 100
});
$('.walletCommands#walletCommandsSubmit').removeClass('hidden'); $('.walletCommands#walletCommandsSubmit').removeClass('hidden');
} }
}); });
} }
else { else {
// already reached 6 or more confirmations, so we can proceed // already reached 6 or more confirmations, so we can proceed
alert("already reached 6 or more confirmations, so we can proceed"); $( "#progressbar" ).progressbar({
value: 100
});
$("#progresstxt").text("Your transaction has " + confirmations + " confirmations. You can now submit the proposal.");
console.log("already reached 6 or more confirmations, so we can proceed");
$('.walletCommands#walletCommandsSubmit').removeClass('hidden'); $('.walletCommands#walletCommandsSubmit').removeClass('hidden');
} }
} }
@ -373,6 +437,7 @@
$('.walletCommands#walletCommandsHeader').removeClass('hidden'); $('.walletCommands#walletCommandsHeader').removeClass('hidden');
$('.walletCommands#walletCommandsPrepare').removeClass('hidden'); $('.walletCommands#walletCommandsPrepare').removeClass('hidden');
$('.walletCommands#walletCommandsTx').removeClass('hidden'); $('.walletCommands#walletCommandsTx').removeClass('hidden');
//$('.walletCommands#walletCommandsProgress').removeClass('hidden');
//$('.walletCommands#walletCommandsSubmit').removeClass('hidden'); //$('.walletCommands#walletCommandsSubmit').removeClass('hidden');
this._mode = 'command'; this._mode = 'command';
@ -389,6 +454,7 @@
$('.walletCommands#walletCommandsHeader').addClass('hidden'); $('.walletCommands#walletCommandsHeader').addClass('hidden');
$('.walletCommands#walletCommandsPrepare').addClass('hidden'); $('.walletCommands#walletCommandsPrepare').addClass('hidden');
$('.walletCommands#walletCommandsTx').addClass('hidden'); $('.walletCommands#walletCommandsTx').addClass('hidden');
$('.walletCommands#walletCommandsProgress').addClass('hidden');
$('.walletCommands#walletCommandsSubmit').addClass('hidden'); $('.walletCommands#walletCommandsSubmit').addClass('hidden');
this._mode = 'proposal'; this._mode = 'proposal';
@ -481,6 +547,7 @@
#walletCommandsHeader { margin-top:2em; } #walletCommandsHeader { margin-top:2em; }
#walletCommandsPrepare { margin-top:2em; } #walletCommandsPrepare { margin-top:2em; }
#walletCommandsTx { margin-top:2em; } #walletCommandsTx { margin-top:2em; }
#walletCommandsProgress { margin-top:2em; }
#walletCommandsSubmit { margin-top:2em; } #walletCommandsSubmit { margin-top:2em; }
.validationError { background-color:#ffe6e6; } .validationError { background-color:#ffe6e6; }
@ -606,6 +673,20 @@
</div> </div>
<div class="row walletCommands hidden" id="walletCommandsProgress">
<div class="col-xs-12">
<div class="form-group">
<label for="feeTxid">Fee Transaction Progress:</label>
<div id="progresstxt">We'll wait for 6 confirmations. Waiting for new blocks to confirm...</div>
<div id="progressbar"></div>
</div>
</div>
</div>
<div class="row walletCommands hidden" id="walletCommandsSubmit"> <div class="row walletCommands hidden" id="walletCommandsSubmit">
<div class="col-xs-12"> <div class="col-xs-12">