Introduction to CoinTool
CoinTools is A Chrome Extension that has a few useful tools and graphs for Cryptocurrency.
Previous Contributions
- v0.0.1 Introduction to CoinTools! A Cryptocurrency Chrome Extension
Technology Stacks
Javascript that runs in Chrome.
Github of CoinTools
https://github.com/DoctorLai/CoinTools
Chrome Webstore
It is available online at Chrome Webstore.
CoinTools v0.0.2 Feature
Along with bug fixes and code refactoring, this version has the following features:
- Any two cryptocurrency conversions.
- UI Localisation with Simplified Chinese.
Commits
Roadmap of CoinTools
- real-time graphs
- search cryptocurrency
- historical data
CoinTools Screenshots
Javascript Async and Await to Convert from one coin to another
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | // 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>"); }); } } } } |
// 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
Contribution Welcome
Github: https://github.com/DoctorLai/SteemTools/
- Fork it!
- Create your feature branch: git checkout -b my-new-feature
- Commit your changes: git commit -am ‘Add some feature’
- Push to the branch: git push origin my-new-feature
- Submit a pull request.
Chrome Webstore
Install the CoinTools Now!
–EOF (The Ultimate Computing & Technology Blog) —
GD Star Rating
loading...
751 wordsloading...
Last Post: Introduction to CoinTools! A Cryptocurrency Chrome Extension
Next Post: CoinTools v0.0.3: Adding Total Market Cap USD Chart, Localization and Stock Price Emoji