npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jquery-inline-currency

v0.3.5

Published

Simple jQuery plugin for showing prices in different currencies using actual exchange rates

Downloads

7

Readme

jQuery.inline-currency

Simple jQuery plugin for showing prices in different currencies using actual exchange rates.

How to use

  • Install plugin using npm or manually
    npm install jquery-inline-currency
  • Include plugin in the head or body section after jQuery:
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js"></script>
    <script src="./js/jquery.inline-currency.min.js"></script>
  • Set styles for the currencies tooltip or include my version from css/jquery.inline-currency.css;
    <link rel="stylesheet" href="./css/jquery.inline-currency.css" />
  • Put each price into some element, that will be selector for jQuery:
    <span class="jic">$10</span>
  • Apply inlineCurrency plugin to your prices:
    $(function () {
        $('.jic').inlineCurrency();
    });

How it works

Plugin tries to detect price from text, so this setup will be best with integer or float prices.

If you use formatting for your numbers (thousands and decimal separators), you should set some options to plugin.

Options

Default set:

{
    "currency": "USD",
    "convertTo": "EUR",
    "thousandsSplit": "",
    "decimalsSplit": ".",
    "containerElement": "p",
    "containerClass": "jic-container",
    "rateElement": "span",
    "rateClass": "jic-rate",
    "currencyElement": "span",
    "currencyClass": "jic-currency",
    "currencySplit": false,
    "debug": false
}

All parameters are optional.

Currency setup

  • currency — basic currency for your prices
  • convertTo — comma-separated list of currencies to convert to

Price recognition

  • thousandsSplit - thousands separator (can be empty, space, . or ,)
  • decimalsSplit - decimals separator (can be empty, space, . or ,)

Remember that this parameters can't be equal.

Tooltip generation setup

  • containerElement and containerClass - element that will be appended to each price
  • rateElement and rateClass - element and class for each exchange rate
  • currencyElement and currencyClass — element for each currency unit
  • currencySplit (Boolean or String) — excludes rateElement and generates exchange rates separated by currencySplit value

Inline parameters

Plugin also supports inline parameters (for exotic cases) which can help set price, base currency and convertTo for each price:

  • data-jic-value - price value
  • data-jic-currency — base currency
  • data-jic-convert-to — comma-separated list of currencies to convert to
<span class="jic" data-jic-value="10" data-jic-currency="EUR" data-jic-convert-to="rub, usd">Ten Euros</span>

Exchange rates source

In the begining it was Yahoo Currencies Service, but in the discussion at https://developer.yahoo.com/forum/General-Discussion-at-YDN/Using-Yahoo-Finance-API-Not-RSS-/1250246255000-0b82f8f0-7f48-3af2-8fe2-e73a138cbfaa/ it was mentioned:

The reason for the lack of documentation is that we don't have a Finance API. It appears some have reverse engineered an API that they use to pull Finance data, but they are breaking our Terms of Service (no redistribution of Finance data) in doing this so I would encourage you to avoid using these webservices.

Cheers, Robyn Tippins Community Manager, YDN

So, I've decided not to break Yahoo's Terms of Service and have found https://www.frankfurter.app/ (https://github.com/hakanensari/frankfurter). As it is free and has MIT License, it's the best choice for our purposes. Thanks, @hakanensari

How often do rates update

Once a day (for now, since October 2015). Check https://github.com/hakanensari/frankfurter for more info.

Browser compatibility

You can check window.localStorage use at http://caniuse.com/#search=localstorage