UI plugin for jQuery. Instead of traditional "calculator" looks converter, Currencyr came with "tooltip" looks idea right near the amount selector.
Le click $ — Milk: $2.35, Catfood: $15, Beers: $7.57Include these lines after jQuery library.
<style rel="stylesheet" type="text/css" href="/path/to/currencyr.css"> <style rel="stylesheet" type="text/css" href="/path/to/themes/@theme@/@theme@.css"> <script src="/path/to/currencyr.js"></script>
First you MUST assign the currencies, base and rates:
var currencies = {
"AED": "United Arab Emirates Dirham",
"AFN": "Afghan Afghani",
"ALL": "Albanian Lek",
"AMD": "Armenian Dram",
...
},
base = 'USD',
rates = {
"AED": 3.673177,
"AFN": 51.719367,
"ALL": 107.942001,
"AMD": 405.503334,
...
};
$.currencyr( currencies, base, rates );
It doesn't matter the way it assigned, statically or dinamically flavour.
Then call the plugin right on selector:
$('.amount').currencyr();
It's super easy to integrate with Open Exchange Rates:
var appId = YOUR_APP_ID;
$.getJSON( 'http://openexchangerates.org/api/currencies.json', function( response ) {
var currencies = response;
$.getJSON( 'http://openexchangerates.org/api/latest.json', { 'app_id': appId }, function( response ) {
$.currencyr( currencies, response.base, response.rates );
$( '.amount' ).currencyr();
});
});
$('.amount').currencyr( { option_name: option_value } );
If you have any feedback, any at all, tweet @firmanw, or head over to the Currencyr github repository and create a new issue.