mirror of
https://github.com/seigler/dash-website
synced 2025-07-26 06:46:10 +00:00
/network page tables JS refactor & cleanup. Updates ESLINT rules, adds htmlproof & eslint to build process, adds window.global.siteApi url defined from _config.yml
This commit is contained in:
parent
4ca9a382f5
commit
99d941c1fb
4 changed files with 49 additions and 37 deletions
|
@ -5,6 +5,9 @@
|
|||
},
|
||||
"globals": {
|
||||
"Modernizr": false,
|
||||
"moment": false,
|
||||
"formatCurrency": false,
|
||||
"formatNumber": false,
|
||||
"jQuery": false
|
||||
},
|
||||
"rules": {
|
||||
|
|
|
@ -35,7 +35,12 @@
|
|||
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery.matchHeight/0.7.0/jquery.matchHeight-min.js" integrity="sha384-dfOR5hjVOg6B2OvgyHIS71mJWX5TgNQeFGo5cNNVglSep7ZvYcByrpEya6xbwwyB" crossorigin="anonymous"></script>
|
||||
<script src="/dist/js/main.min.js"></script>
|
||||
<script>
|
||||
function formatNumber (num) {
|
||||
window.globals = {
|
||||
siteApi : "{{ site.api }}"
|
||||
};
|
||||
|
||||
////////
|
||||
function formatNumber (num) {
|
||||
return num.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,")
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
"build:font": "npm run font",
|
||||
"build:images": "npm run imagemin",
|
||||
"reload": "browser-sync reload",
|
||||
"build": "run-s clean build:js build:css build:font build:jekyll copy",
|
||||
"build": "run-s clean build:js build:css build:font build:jekyll copy htmlproof eslint",
|
||||
"watch:jekyll": "onchange 'index.html' '*/*.html' '_*/**/*.yml' '_includes/**/*.html' '_layouts/**/*.html' '_posts/*' -e '_site/*' -d 500 -- run-s build:jekyll:incremental copy reload",
|
||||
"watch:css": "onchange 'src/scss/**/*' -d 500 -- run-s sass prefix copy:css",
|
||||
"watch:js": "onchange 'src/js/*' -d 500 -- run-s uglify:dev copy:js reload",
|
||||
|
|
|
@ -2,90 +2,94 @@
|
|||
'use strict';
|
||||
$(document).ready(function () {
|
||||
|
||||
var siteApi = '/api/v1/';
|
||||
var siteApi = window.globals.siteApi || '/api/v1/';
|
||||
|
||||
if($('#blocks').length){
|
||||
// Get the blockchain info
|
||||
if ($('#blocks').length) {
|
||||
|
||||
// Get the blockchain info
|
||||
$.ajax({
|
||||
url: siteApi+"chain/latestBlocks/"
|
||||
url: siteApi + 'chain/latestBlocks/'
|
||||
})
|
||||
.done(function(response){
|
||||
.done(function(response) {
|
||||
var blocks = response.blocks;
|
||||
|
||||
blocks.map(function(block){
|
||||
blocks.map(function(block) {
|
||||
var height = block.height,
|
||||
age = moment.unix(block.time).format("LLL"),
|
||||
age = moment.unix(block.time).format('LLL'),
|
||||
txs = block.txlength,
|
||||
out = block.cbvalue,
|
||||
difficulty = block.difficulty;
|
||||
|
||||
$("#blocks>tbody").append('<tr><td data-header="Height">' + height + '</td><td data-header="Block Time">' + age + '</td><td data-header="Transactions">' + txs + '</td><td data-header="Value Out">' + out + '</td><td data-header="Difficulty">' + difficulty + '</td></tr>');
|
||||
$('#blocks>tbody').append('<tr><td data-header="Height">' + height + '</td><td data-header="Block Time">' + age + '</td><td data-header="Transactions">' + txs + '</td><td data-header="Value Out">' + out + '</td><td data-header="Difficulty">' + difficulty + '</td></tr>');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if($('#exchanges').length){
|
||||
if ($('#exchanges').length) {
|
||||
|
||||
// Get the exchange data
|
||||
$.ajax({
|
||||
url: siteApi+"exchange/",
|
||||
url: siteApi + 'exchange/',
|
||||
error: function(jqXHR, textStatus, errorThrown) {
|
||||
console.log(jqXHR);
|
||||
console.log(textStatus);
|
||||
console.log('errorThrown:');
|
||||
console.log('errorThrown:',errorThrown);
|
||||
}
|
||||
})
|
||||
.done(function(response){
|
||||
.done(function(response) {
|
||||
var exchanges = response;
|
||||
|
||||
exchanges.map(function(exchange){
|
||||
if(exchange){
|
||||
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),
|
||||
url = exchange.url,
|
||||
volume = '$' + formatCurrency(exchange.volume,0),
|
||||
price = '$' + formatCurrency(exchange.price),
|
||||
change = formatNumber(exchange.percent_change);
|
||||
|
||||
$("#exchanges>tbody").append('<tr><td data-header="Exchange"><a target="_blank" href="' + url + '">' + name + '</a></td><td data-header="Volume (24h)">' + volume + '</td><td data-header="Price">' + price + '</td><td data-header="Volume (%)">' + change + '%</td></tr>');
|
||||
$('#exchanges>tbody').append('<tr><td data-header="Exchange"><a target="_blank" href="' + url + '">' + name + '</a></td><td data-header="Volume (24h)">' + volume + '</td><td data-header="Price">' + price + '</td><td data-header="Volume (%)">' + change + '%</td></tr>');
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if($('#masternodes_count').length){
|
||||
if ($('#masternodes_count').length) {
|
||||
|
||||
// Get the current number of masternodes.
|
||||
$.ajax({
|
||||
url: siteApi+"masternodes/stats/"
|
||||
url: siteApi + 'masternodes/stats/'
|
||||
})
|
||||
.done(function(response){
|
||||
.done(function(response) {
|
||||
console.log('masternode stats', response.stats);
|
||||
var masternodes_count = formatNumber(response.stats['count']),
|
||||
masternodes_max = formatNumber(response.stats['max']);
|
||||
var masternodesCount = formatNumber(response.stats.count),
|
||||
masternodesMax = formatNumber(response.stats.max);
|
||||
|
||||
$("#masternodes_count").text(masternodes_count);
|
||||
$("#masternodes_max").text(masternodes_max);
|
||||
$('#masternodes_count').text(masternodesCount);
|
||||
$('#masternodes_max').text(masternodesMax);
|
||||
});
|
||||
}
|
||||
|
||||
if($('#budgets').length){
|
||||
if ($('#budgets').length) {
|
||||
|
||||
// Get the budget proposals
|
||||
$.ajax({
|
||||
url: siteApi+"budgets/"
|
||||
url: siteApi + 'budgets/'
|
||||
})
|
||||
.done(function(response){
|
||||
.done(function(response) {
|
||||
var proposals = response.proposals;
|
||||
|
||||
proposals.map(function(proposal){
|
||||
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";
|
||||
votesYes = proposal.yes,
|
||||
votesNo = proposal.no,
|
||||
requiredVotes = proposal.remaining_yes_votes_until_funding,
|
||||
amountMonthly = formatCurrency(proposal.monthly_amount),
|
||||
willBeFunded = proposal.will_be_funded ? 'yes' : 'no';
|
||||
|
||||
$("#budgets>tbody").append('<tr><td data-header="Title"><a href="' + url + '" target="_blank">' + title + '</a></td><td data-header="Owner">' + owner + '</td><td data-header="Votes (yes/no)">' + votes_yes + '/' + votes_no + '</td><td data-header="Votes Required">' + required_votes + '</td><td data-header="Monthly Amount">' + amount_monthly + '</td><td data-header="Will be Funded">' + will_be_funded + '</td></tr>');
|
||||
$('#budgets>tbody').append('<tr><td data-header="Title"><a href="' + url + '" target="_blank">' + title + '</a></td><td data-header="Owner">' + owner + '</td><td data-header="Votes (yes/no)">' + votesYes + '/' + votesNo + '</td><td data-header="Votes Required">' + requiredVotes + '</td><td data-header="Monthly Amount">' + amountMonthly + '</td><td data-header="Will be Funded">' + willBeFunded + '</td></tr>');
|
||||
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue