Skip to main content

Posts

Showing posts from December, 2015

Automated currency conversion in text

I have created a js script to automatically convert currency on page according to the current rate. Lets say I write "$5" and want to show its value in other currencies. I just need to enclose it in a tag with class = "exchange" and voila: $5 . To enable this behavior you need to link jQuery (add <script src="https://code.jquery.com/jquery-2.1.4.min.js" type="text/javascript"></script> to the head of page) and the script itself (add <script src="https://drclnatj7kvk6.cloudfront.net/currency.js" type="text/javascript"></script> to the bottom of the page). Script is based on http://fixer.io/ and http://openexchangerates.github.io/money.js/ . Fiddle is available here:  https://jsfiddle.net/40rr05fb/42/embedded/result/ . Language and displaying currencies can be easily set. Extending the script is also straightforward.