mirror of
https://github.com/seigler/govobject-proposal
synced 2025-07-26 22:36:09 +00:00
adjust payment cycle selectors
This commit is contained in:
parent
ac7a8eac01
commit
3d255b6d72
2 changed files with 23 additions and 6 deletions
|
@ -65,9 +65,14 @@
|
|||
paymentCycle.selectedPeriods = $('#end_epoch').find(':selected').data('index');
|
||||
|
||||
var payment_amount = parseInt($('#payment_amount').val());
|
||||
if (isNaN(payment_amount)) payment_amount = 0;
|
||||
|
||||
var periods = parseInt((paymentCycle.selectedPeriods+1)-paymentCycle.selectedStartIndex);
|
||||
|
||||
var label = $('#end_epoch').find(':selected').data('label');
|
||||
|
||||
$('#total_amount').text(payment_amount * periods);
|
||||
$('#total_amount_due').text(" with a final payment on " + label);
|
||||
};
|
||||
|
||||
$(document).ready(function() {
|
||||
|
@ -299,7 +304,7 @@
|
|||
<!-- -->
|
||||
<!-- The following form group is a placeholder for proposal end time. Please change to the correct id. -->
|
||||
<div class="form-group">
|
||||
<label for="start_epoch">Last Payment:</label>
|
||||
<label for="start_epoch">Payments:</label>
|
||||
<select name="start_epoch" class="form-control" id="end_epoch"></select>
|
||||
</div>
|
||||
<!-- -->
|
||||
|
@ -336,7 +341,7 @@
|
|||
<div class="col-xs-12">
|
||||
<div class="form-group">
|
||||
<label for="total_amount">Total Amount: </label>
|
||||
<span id="total_amount">0</span> <span>DASH</span>
|
||||
<span id="total_amount">0</span> <span>DASH</span> <span id="total_amount_due"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -100,12 +100,17 @@ PaymentCycle.prototype.updateDropdowns = function() {
|
|||
var superblock = this.getNextSuperblock(blockHeight);
|
||||
var timestamp = this.getBlockTimestamp(superblock);
|
||||
|
||||
var before = this.getBlockTimestamp((superblock-(this.paymentCycle/2)));
|
||||
var after = this.getBlockTimestamp((superblock+(this.paymentCycle/2)));
|
||||
|
||||
var label = new Date(timestamp).toLocaleDateString();
|
||||
if (this.network == 'testnet') label += " @ " + new Date(timestamp).toLocaleTimeString();
|
||||
|
||||
var superblockDate = {
|
||||
superblock: superblock,
|
||||
timestamp: timestamp,
|
||||
before: before,
|
||||
after: after,
|
||||
label: label
|
||||
};
|
||||
this.startDate.push(superblockDate);
|
||||
|
@ -115,8 +120,8 @@ PaymentCycle.prototype.updateDropdowns = function() {
|
|||
|
||||
}
|
||||
|
||||
this.endDate.shift(); // remove first element of endDate
|
||||
this.startDate.pop(); // remove last element of startDate to keep length even
|
||||
// this.endDate.shift(); // remove first element of endDate
|
||||
// this.startDate.pop(); // remove last element of startDate to keep length even
|
||||
|
||||
var now = Math.floor(Date.now());
|
||||
|
||||
|
@ -132,7 +137,7 @@ PaymentCycle.prototype.updateDropdowns = function() {
|
|||
|
||||
var eta = self.getTimeDifference(opts, now, this.timestamp);
|
||||
var time = this.timestamp - now;
|
||||
var option = $("<option />").val((Math.floor(this.timestamp / 1000))).text(this.label).attr('data-index', index).attr('data-time', time).attr('data-eta', eta).attr('data-block', this.superblock);
|
||||
var option = $("<option />").val((Math.floor(this.before / 1000))).text(this.label).attr('data-index', index).attr('data-time', time).attr('data-eta', eta).attr('data-block', this.superblock);
|
||||
start_epoch.append(option);
|
||||
|
||||
});
|
||||
|
@ -150,6 +155,9 @@ PaymentCycle.prototype.updateEndEpoch = function() {
|
|||
|
||||
var end_epoch = $("#end_epoch");
|
||||
end_epoch.find('option').remove();
|
||||
|
||||
var i = 1;
|
||||
|
||||
$.each(this.endDate, function(index) {
|
||||
|
||||
if(index >= self.selectedStartIndex) {
|
||||
|
@ -157,11 +165,15 @@ PaymentCycle.prototype.updateEndEpoch = function() {
|
|||
var eta = self.getTimeDifference(opts, self.startDate[self.selectedStartIndex].timestamp, this.timestamp);
|
||||
var time = this.timestamp - self.startDate[self.selectedStartIndex].timestamp;
|
||||
|
||||
var option = $("<option />").val((Math.floor(this.timestamp / 1000))).text(this.label).attr('data-index', index).attr('data-time', time).attr('data-eta', eta).attr('data-block', this.superblock);
|
||||
var option = $("<option />").val((Math.floor(this.after / 1000))).text((i)+" Payment").attr('data-index', index).attr('data-label', this.label).attr('data-time', time).attr('data-eta', eta).attr('data-block', this.superblock);
|
||||
end_epoch.append(option);
|
||||
|
||||
i++;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue