diff --git a/mining/index.html b/mining/index.html index a67720a..1b83c8c 100644 --- a/mining/index.html +++ b/mining/index.html @@ -140,28 +140,3 @@ description: pages.mining.description - diff --git a/network/index.html b/network/index.html index 6dbb976..026fc03 100644 --- a/network/index.html +++ b/network/index.html @@ -124,90 +124,3 @@ description: pages.currency.description - - diff --git a/src/js/tables.js b/src/js/tables.js new file mode 100644 index 0000000..d9a4274 --- /dev/null +++ b/src/js/tables.js @@ -0,0 +1,97 @@ +;(function ($) { + 'use strict'; + $(document).ready(function () { + + var siteApi = '/api/v1/'; + + if($('#blocks').length){ + // Get the blockchain info + $.ajax({ + url: siteApi+"chain/latestBlocks/" + }) + .done(function(response){ + var blocks = response.blocks; + + blocks.map(function(block){ + var height = block.height, + age = moment.unix(block.time).format("LLL"), + txs = block.txlength, + out = block.cbvalue, + difficulty = block.difficulty; + + $("#blocks>tbody").append('' + height + '' + age + '' + txs + '' + out + '' + difficulty + ''); + }); + }); + } + + if($('#exchanges').length){ + // Get the exchange data + $.ajax({ + url: siteApi+"exchange/", + error: function(jqXHR, textStatus, errorThrown) { + console.log(jqXHR); + console.log(textStatus); + console.log('errorThrown:'); + } + }) + .done(function(response){ + var exchanges = response; + + exchanges.map(function(exchange){ + if(exchange){ + console.log('exchange',exchange); + var name = exchange.exchange, + url = exchange.url + volume = "$" + formatCurrency(exchange.volume,0), + price = "$" + formatCurrency(exchange.price), + change = formatNumber(exchange.percent_change); + + $("#exchanges>tbody").append('' + name + '' + volume + '' + price + '' + change + '%'); + } + }); + }); + } + + if($('#masternodes_count').length){ + // Get the current number of masternodes. + $.ajax({ + url: siteApi+"masternodes/stats/" + }) + .done(function(response){ + console.log('masternode stats', response.stats); + var masternodes_count = formatNumber(response.stats['count']), + masternodes_max = formatNumber(response.stats['max']); + + $("#masternodes_count").text(masternodes_count); + $("#masternodes_max").text(masternodes_max); + }); + } + + if($('#budgets').length){ + // Get the budget proposals + $.ajax({ + url: siteApi+"budgets/" + }) + .done(function(response){ + var proposals = response.proposals; + + proposals.map(function(proposal){ + var title = proposal.title ? proposal.title : proposal.name, + url = proposal.dw_url, + owner = proposal.owner_username, + votes_yes = proposal.yes, + votes_no = proposal.no, + required_votes = proposal.remaining_yes_votes_until_funding, + amount_monthly = formatCurrency(proposal.monthly_amount) + will_be_funded = proposal.will_be_funded ? "yes" : "no"; + + $("#budgets>tbody").append('' + title + '' + owner + '' + votes_yes + '/' + votes_no + '' + required_votes + '' + amount_monthly + '' + will_be_funded + ''); + + }); + }); + } + + }); +}(jQuery)); + +