mirror of
https://github.com/seigler/dash-website
synced 2025-07-26 23:06:09 +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": {
|
"globals": {
|
||||||
"Modernizr": false,
|
"Modernizr": false,
|
||||||
|
"moment": false,
|
||||||
|
"formatCurrency": false,
|
||||||
|
"formatNumber": false,
|
||||||
"jQuery": false
|
"jQuery": false
|
||||||
},
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
|
|
|
@ -35,6 +35,11 @@
|
||||||
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery.matchHeight/0.7.0/jquery.matchHeight-min.js" integrity="sha384-dfOR5hjVOg6B2OvgyHIS71mJWX5TgNQeFGo5cNNVglSep7ZvYcByrpEya6xbwwyB" crossorigin="anonymous"></script>
|
<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 src="/dist/js/main.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
|
window.globals = {
|
||||||
|
siteApi : "{{ site.api }}"
|
||||||
|
};
|
||||||
|
|
||||||
|
////////
|
||||||
function formatNumber (num) {
|
function formatNumber (num) {
|
||||||
return num.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,")
|
return num.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,")
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
"build:font": "npm run font",
|
"build:font": "npm run font",
|
||||||
"build:images": "npm run imagemin",
|
"build:images": "npm run imagemin",
|
||||||
"reload": "browser-sync reload",
|
"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: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: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",
|
"watch:js": "onchange 'src/js/*' -d 500 -- run-s uglify:dev copy:js reload",
|
||||||
|
|
|
@ -2,90 +2,94 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
|
|
||||||
var siteApi = '/api/v1/';
|
var siteApi = window.globals.siteApi || '/api/v1/';
|
||||||
|
|
||||||
|
if ($('#blocks').length) {
|
||||||
|
|
||||||
if($('#blocks').length){
|
|
||||||
// Get the blockchain info
|
// Get the blockchain info
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: siteApi+"chain/latestBlocks/"
|
url: siteApi + 'chain/latestBlocks/'
|
||||||
})
|
})
|
||||||
.done(function(response){
|
.done(function(response) {
|
||||||
var blocks = response.blocks;
|
var blocks = response.blocks;
|
||||||
|
|
||||||
blocks.map(function(block){
|
blocks.map(function(block) {
|
||||||
var height = block.height,
|
var height = block.height,
|
||||||
age = moment.unix(block.time).format("LLL"),
|
age = moment.unix(block.time).format('LLL'),
|
||||||
txs = block.txlength,
|
txs = block.txlength,
|
||||||
out = block.cbvalue,
|
out = block.cbvalue,
|
||||||
difficulty = block.difficulty;
|
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
|
// Get the exchange data
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: siteApi+"exchange/",
|
url: siteApi + 'exchange/',
|
||||||
error: function(jqXHR, textStatus, errorThrown) {
|
error: function(jqXHR, textStatus, errorThrown) {
|
||||||
console.log(jqXHR);
|
console.log(jqXHR);
|
||||||
console.log(textStatus);
|
console.log(textStatus);
|
||||||
console.log('errorThrown:');
|
console.log('errorThrown:',errorThrown);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.done(function(response){
|
.done(function(response) {
|
||||||
var exchanges = response;
|
var exchanges = response;
|
||||||
|
|
||||||
exchanges.map(function(exchange){
|
exchanges.map(function(exchange) {
|
||||||
if(exchange){
|
if (exchange) {
|
||||||
console.log('exchange',exchange);
|
console.log('exchange',exchange);
|
||||||
var name = exchange.exchange,
|
var name = exchange.exchange,
|
||||||
url = exchange.url
|
url = exchange.url,
|
||||||
volume = "$" + formatCurrency(exchange.volume,0),
|
volume = '$' + formatCurrency(exchange.volume,0),
|
||||||
price = "$" + formatCurrency(exchange.price),
|
price = '$' + formatCurrency(exchange.price),
|
||||||
change = formatNumber(exchange.percent_change);
|
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.
|
// Get the current number of masternodes.
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: siteApi+"masternodes/stats/"
|
url: siteApi + 'masternodes/stats/'
|
||||||
})
|
})
|
||||||
.done(function(response){
|
.done(function(response) {
|
||||||
console.log('masternode stats', response.stats);
|
console.log('masternode stats', response.stats);
|
||||||
var masternodes_count = formatNumber(response.stats['count']),
|
var masternodesCount = formatNumber(response.stats.count),
|
||||||
masternodes_max = formatNumber(response.stats['max']);
|
masternodesMax = formatNumber(response.stats.max);
|
||||||
|
|
||||||
$("#masternodes_count").text(masternodes_count);
|
$('#masternodes_count').text(masternodesCount);
|
||||||
$("#masternodes_max").text(masternodes_max);
|
$('#masternodes_max').text(masternodesMax);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if($('#budgets').length){
|
if ($('#budgets').length) {
|
||||||
|
|
||||||
// Get the budget proposals
|
// Get the budget proposals
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: siteApi+"budgets/"
|
url: siteApi + 'budgets/'
|
||||||
})
|
})
|
||||||
.done(function(response){
|
.done(function(response) {
|
||||||
var proposals = response.proposals;
|
var proposals = response.proposals;
|
||||||
|
|
||||||
proposals.map(function(proposal){
|
proposals.map(function(proposal) {
|
||||||
var title = proposal.title ? proposal.title : proposal.name,
|
var title = proposal.title ? proposal.title : proposal.name,
|
||||||
url = proposal.dw_url,
|
url = proposal.dw_url,
|
||||||
owner = proposal.owner_username,
|
owner = proposal.owner_username,
|
||||||
votes_yes = proposal.yes,
|
votesYes = proposal.yes,
|
||||||
votes_no = proposal.no,
|
votesNo = proposal.no,
|
||||||
required_votes = proposal.remaining_yes_votes_until_funding,
|
requiredVotes = proposal.remaining_yes_votes_until_funding,
|
||||||
amount_monthly = formatCurrency(proposal.monthly_amount)
|
amountMonthly = formatCurrency(proposal.monthly_amount),
|
||||||
will_be_funded = proposal.will_be_funded ? "yes" : "no";
|
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