使用 bitcoinaverage.com 市场数据,以人类友好的方式以法定货币显示比特币价格
bitcoinprices.js is a JavaScript library for presenting Bitcoin prices with currency conversion.
Example:
See also
Liberty Music Store is an online store which allows musicians to sell their songs and receive Bitcoins.. The source code of Liberty Music Store is on Github, so you can check it for the integration example.
The sister project bitcoinaaddress.js for making bitcoin payments and QR codes.
Demo with clickable bitcoin prices, bitcoin price menu and manu bitcoin price conversion.
No server-side components needed.
You must have jQuery (version 1.9 or later) installed.
Put bitcoinprices.js in your application.
You manually need to call bitcoinprices.init() to trigger the loading of exchange rate data and
making price switching logic to work:
All configuration parameters can be omitted. Then defaults from bitcoinprices.js
is used (defaultConfig variable).
Your templating language must output Bitcoin prices with attribute:
bitcoinprices.init() fires HTML document marketdataavailable event when the script manages to load
exchange ratesactivecurrencychange event is firedbitcoinprices.convert() to convert between any currencies supported
by bitcoinaverage.combitcoinprices.updatePrices() if your own JavaScripts
sets the active currency and all prices on the page are updatd.It is suggested that you cache bitcoinaverage.com API output on a local server with proper cache headers. This may considerably speed up your site and reduces bitcoinaverage.com load.
Here is another example how bitcoinprices.js is used
with popular Drupal content management system and its UberCart eCommerce add on.
An example live site, It's time for plan B.
Change UberCart templates to output price as data-price-usd attribute.
Example modification to node--production.tpl.php:
$usd_price = round(render($content['sell_price']['#value']) , 2);
">Include bitcoinprices.js in your CSS.
Add CSS styles for .clickable-price selector (prices become clickable only when succesful market data
exchange rates have been downloaded from bitcoinaverage). clickable-price CSS class is added
automatically you don't need to add it to your templates:
.clickable-price {
cursor: pointer;
border-bottom: 1px #888 dashed;
}Include an initialization JavaScript snippet as a separate JS file:
…Mikko Ohtamaa (blog, Facebook, Twitter, Google+)
Contact for work and consulting offers.
暂无开放 Issues,或尚未同步最近议题。