mirror of
https://github.com/seigler/govobject-proposal
synced 2025-07-27 06:46:10 +00:00
implement network selector
This commit is contained in:
parent
7d3132d450
commit
ba4fbbb4cc
2 changed files with 35 additions and 12 deletions
42
index.html
42
index.html
|
@ -32,22 +32,35 @@
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
var Bitcore = require('bitcore-lib-dash');
|
var Bitcore = require('bitcore-lib-dash');
|
||||||
var provider = 'https://dev-test.dash.org/';
|
|
||||||
|
|
||||||
var socket = io(provider);
|
var socket;
|
||||||
|
|
||||||
socket.on('connect', function() {
|
var mainnetProvider = 'https://dev-test.dash.org/';
|
||||||
socket.emit('subscribe', 'inv');
|
var testnetProvider = 'https://dev-test.dash.org/';
|
||||||
console.log("socket.io initialized...");
|
|
||||||
});
|
var init = function(network, provider) {
|
||||||
|
var gov = new Bitcore.GovObject.Proposal();
|
||||||
|
gov.network = network || 'testnet';
|
||||||
|
|
||||||
|
var paymentCycle = new PaymentCycle(gov, provider);
|
||||||
|
paymentCycle.updateDropdowns();
|
||||||
|
|
||||||
|
socket = io(provider);
|
||||||
|
|
||||||
|
socket.on('connect', function() {
|
||||||
|
socket.emit('subscribe', 'inv');
|
||||||
|
console.log("socket.io initialized...");
|
||||||
|
});
|
||||||
|
|
||||||
|
return gov;
|
||||||
|
};
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
var gov = new Bitcore.GovObject.Proposal();
|
|
||||||
gov.network = 'testnet';
|
|
||||||
|
|
||||||
var paymentCycle = new PaymentCycle(gov);
|
var gov = init('testnet', testnetProvider); // default network;
|
||||||
|
|
||||||
paymentCycle.updateDropdowns(); // update dropdown menus based on network and current time
|
$('#mainnet').change(function() { gov = init('mainnet', mainnetProvider); });
|
||||||
|
$('#testnet').change(function() { gov = init('testnet', testnetProvider); });
|
||||||
|
|
||||||
$("#time").val(Math.floor((new Date).getTime() / 1000));
|
$("#time").val(Math.floor((new Date).getTime() / 1000));
|
||||||
|
|
||||||
|
@ -149,6 +162,15 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
|
|
||||||
|
<div class="btn-group" data-toggle="buttons">
|
||||||
|
<label class="btn btn-primary">
|
||||||
|
<input type="radio" name="options" id="mainnet" autocomplete="off"> Mainnet
|
||||||
|
</label>
|
||||||
|
<label class="btn btn-primary active">
|
||||||
|
<input type="radio" name="options" id="testnet" autocomplete="off" checked> Testnet
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<!-- -->
|
<!-- -->
|
||||||
|
|
|
@ -4,10 +4,11 @@
|
||||||
* @param gov
|
* @param gov
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function PaymentCycle(gov) {
|
function PaymentCycle(gov, provider) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
this.network = gov.network;
|
this.network = gov.network;
|
||||||
|
this.provider = provider;
|
||||||
this.paymentCycle = 16616; // mainnet
|
this.paymentCycle = 16616; // mainnet
|
||||||
this.budgetCycles = 24;
|
this.budgetCycles = 24;
|
||||||
|
|
||||||
|
@ -152,7 +153,7 @@ PaymentCycle.prototype.updateDropdowns = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
PaymentCycle.prototype.getInfo = function(cb) {
|
PaymentCycle.prototype.getInfo = function(cb) {
|
||||||
$.getJSON(provider + "insight-api-dash/status?q=getinfo", function( data ) {
|
$.getJSON(this.provider + "insight-api-dash/status?q=getinfo", function( data ) {
|
||||||
cb(null, data);
|
cb(null, data);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue