Skip to content

Instantly share code, notes, and snippets.

@hansspiess
Last active August 29, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hansspiess/10556170 to your computer and use it in GitHub Desktop.
Save hansspiess/10556170 to your computer and use it in GitHub Desktop.
A Pen by Hans Spieß.
<div class="coindesk js-coindesk">
<p class="coindesk__price">
€ <span class="js-eur-value"></span>
</p>
<p>
Zuletzt aktualisiert am <span class="js-last-updated"></span>
</p>
<p class="small">Powered by <a href="/price/">CoinDesk</a></p>
</div>
(function appendCoindeskData(){
if ($(".js-coindesk").length !== 0) {
$.getJSON( "http://api.coindesk.com/v1/bpi/currentprice/EUR.json", function( data ) {
var currentprice = (Math.round(data.bpi.EUR.rate_float*100)/100).toFixed(2),
updated = new Date(data.time.updatedISO),
updatedlocale = updated.toLocaleString().replace(/:00$/,'');
$( ".js-eur-value" ).empty().append( currentprice );
$( ".js-last-updated" ).empty().append( updatedlocale );
});
setTimeout(appendCoindeskData, 60000);
}
})();

Add a Coindesk Price Ticker to your Website

The Bitcoin Price Ticker Widget provided by Coindesk is a little too heavy and less configurable, so here is a lightweight and configurable solution which only displays the current price in EUR (can be altered according to the Coindesk Api

A Pen by Hans Spieß on CodePen.

License.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment