Created
January 8, 2018 18:35
-
-
Save mvnp/c84ae606db8be74dc5924a1bfcc5b22a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title></title> | |
</head> | |
<body> | |
<table border="1" width="100%"> | |
<thead> | |
<tr> | |
<th>Name</th> | |
<th>Market Cap</th> | |
<th>Price</th> | |
<th>Volume (24h)</th> | |
<th>Circulating Supply</th> | |
<th>Change (24h)</th> | |
</tr> | |
</thead> | |
<tbody id="loadHereMyCoins"></tbody> | |
</table> | |
<ul id='pagin'></ul> | |
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script> | |
<script type="text/javascript"> | |
var currencies = ['BRL', 'USD', 'EUR']; | |
var total = 1384; | |
var init = 30; | |
var pages = total / init; | |
for(var i = 1; i <= pages; i++){ | |
$('#pagin').append('<li ><a class="pagins" page="'+i+'" href="#">'+i+'</a></li>'); | |
} | |
function loadpage(start, end, currency) { | |
// console.log(start); | |
var endpoint = 'https://api.coinmarketcap.com/v1/ticker/?start='+start+'&limit=30'; | |
$.getJSON(endpoint,function(data) { | |
// console.log(data); | |
var html = ''; | |
$.each(data, function(k, v) { | |
console.log(v); | |
var v.24h_volume_usd = v.Dh_volume_usd; | |
html = '<tr>'; | |
html += '<td>'+v.name+'</td>'; | |
html += '<td>'+v.market_cap_usd+'</td>'; | |
html += '<td>'+v.Dh_volume_usd+'</td>'; | |
html += '<td>'+v.available_supply+'</td>'; | |
html += '</tr>'; | |
$('#loadHereMyCoins').prepend(html); | |
}); | |
}).fail(function() { | |
console.log('fudeu'); | |
}); | |
} | |
$('body').on('click','.pagins', function(){ | |
var pageagora = $(this).attr('page'); | |
initx = init + pageagora; | |
// console.log(pageagora); | |
// console.log(initx); | |
$('#loadHereMyCoins').html(''); | |
loadpage(pageagora, initx, 'BRL'); | |
}); | |
$('body').on('load','.pagins', function(){ | |
var pageagora = 1; | |
initx = init + pageagora; | |
// console.log(pageagora); | |
// console.log(initx); | |
$('#loadHereMyCoins').html(''); | |
loadpage(pageagora, initx, 'BRL'); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment