CoinTool v0.0.2 - Cryptocurrency Conversion + UI Localization

in #utopian-io6 years ago (edited)

Introduction

CoinTools is A Chrome Extension that has a few useful tools and graphs for Cryptocurrency.

Previous Contributions

Technology Stacks

Javascript that runs in Chrome.

Github

https://github.com/DoctorLai/CoinTools

Chrome Webstore

It is available online at Chrome Webstore:
https://chrome.google.com/webstore/detail/coin-tools/fmglcggbdcbkpkfapngjobfeakehpcgj

v0.0.2 Feature

Along with bug fixes and code refactoring, this version has the following features:

  1. Any two cryptocurrency conversions
  2. UI Localisation with Simplified Chinese.

Commits

Here

Roadmap of CoinTools

  1. real-time graphs
  2. search cryptocurrency
  3. historical data

Screenshots

You can now select Simplified Chinese from the setting tab.
image.png

UI will be updated to Chinese immediately once you click Save.
image.png

You can enter each line any two crytocurrency separated by a space.
image.png

And when APP is loaded, it will call coinmarkcap API to convert, for example:
image.png

Javascript Async and Await to Convert from one coin to another

// ajax calling API
const getPriceOfUSD = (coin) => {
    return new Promise((resolve, reject) => {
        let api = "https://api.coinmarketcap.com/v1/ticker/" + coin + '/';
        fetch(api, {mode: 'cors'}).then(validateResponse).then(readResponseAsJSON).then(function(result) {
            resolve(result[0].price_usd);
        });        
    });
}

// ajax get conversion
const getConversion = async(coin1, coin2) => {
    let api1 = getPriceOfUSD(coin1);
    let api2 = getPriceOfUSD(coin2);
    return await api1 / await api2;
}

// conversion
const processConversion = (s) => {
    let arr = s.trim().split("\n");
    for (let i = 0; i < arr.length; i ++) {
        let pair = arr[i].split(" ");
        if (pair.length == 2) {
            let a = pair[0].trim().toLowerCase();
            let b = pair[1].trim().toLowerCase();
            var pat = /^[a-zA-Z\-]+$/;
            if (pat.test(a) && pat.test(b)) {
                let dom = $('div#conversion_results');
                let dom_id = "convert_" + a.replace("-", "") + "_" + b.replace("-", "");
                dom.append('<div id="' + dom_id + '"> </div>');
                getConversion(a, b).then(x => {
                    $('div#' + dom_id).html("<h4>1 " + a.toUpperCase() + " = <span class=yellow>" + x + "</span> " + b.toUpperCase() + "</h4>");
                });
            }
        }
    }
}

License

MIT

Contribution Welcome

Github: https://github.com/DoctorLai/CoinTools/

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request.

Chrome Webstore

Install the CoinTools Now!



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Great Job : )

Hey @justyy I am @utopian-io. I have just upvoted you!

Achievements

  • WOW WOW WOW People loved what you did here. GREAT JOB!
  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Looking for killer crypto tools? EFOLIO https://www.efolio.info is worth checking out.

Great post from a good talented man ..thanks for your post

Coin Marketplace

STEEM 0.28
TRX 0.11
JST 0.031
BTC 69123.03
ETH 3739.29
USDT 1.00
SBD 3.69