Skip to content

Commit

Permalink
Merge pull request #20 from OrganicBeetle/gh-pages
Browse files Browse the repository at this point in the history
Crypto Symbol Accessibility[Issue #19]
  • Loading branch information
Harish-2003 authored Sep 29, 2024
2 parents 0f96d7f + f5e621d commit bd541d5
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 4 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h2>About the Repository</h2>
<section id="crypto-price-predictor">
<h2>Crypto Price Predictor</h2>
<div id="crypto-form">
<label for="crypto">Enter Cryptocurrency Symbol (e.g., BITCOIN, ETHERUM):</label>
<label for="crypto">Enter Cryptocurrency Symbol (e.g., BITCOIN(BTC), ETHERUM(ETH)):</label>
<input type="text" id="crypto" name="crypto">
<button id="predict-btn">Predict Price</button>
</div>
Expand Down
101 changes: 98 additions & 3 deletions script.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,106 @@
document.getElementById("predict-btn").addEventListener("click", function() {
let crypto = document.getElementById("crypto").value.toUpperCase();
let cryptoInput = document.getElementById("crypto").value.toUpperCase();

// A map of symbols to their corresponding API names
const cryptoMap = {
// Major cryptocurrencies
'BTC': 'bitcoin',
'ETH': 'ethereum',
'USDT': 'tether',
'BNB': 'binancecoin',
'USDC': 'usd-coin',
'XRP': 'ripple',
'DOGE': 'dogecoin',
'ADA': 'cardano',
'SOL': 'solana',
'DOT': 'polkadot',
'MATIC': 'matic-network',
'SHIB': 'shiba-inu',
'LTC': 'litecoin',
'TRX': 'tron',
'AVAX': 'avalanche-2',
'ATOM': 'cosmos',
'LINK': 'chainlink',
'XMR': 'monero',
'BCH': 'bitcoin-cash',
'ALGO': 'algorand',
'ICP': 'internet-computer',
'VET': 'vechain',
'FIL': 'filecoin',
'NEAR': 'near',
'HBAR': 'hedera-hashgraph',

// Stablecoins
'DAI': 'dai',
'BUSD': 'binance-usd',
'PAX': 'paxos-standard',

// DeFi tokens
'UNI': 'uniswap',
'AAVE': 'aave',
'SUSHI': 'sushi',
'COMP': 'compound-governance-token',
'YFI': 'yearn-finance',

// Layer 2 solutions and scaling
'LRC': 'loopring',
'ZRX': '0x',
'OMG': 'omisego',

// NFT and metaverse tokens
'MANA': 'decentraland',
'SAND': 'the-sandbox',
'ENJ': 'enjincoin',
'AXS': 'axie-infinity',
'GALA': 'gala',

// Privacy coins
'ZEC': 'zcash',
'DASH': 'dash',

// Other popular tokens
'FTM': 'fantom',
'GRT': 'the-graph',
'1INCH': '1inch',
'CHZ': 'chiliz',
'BAT': 'basic-attention-token',
'CRV': 'curve-dao-token',
'KSM': 'kusama',
'QTUM': 'qtum',
'ZIL': 'zilliqa',
'EGLD': 'elrond-erd-2',
'HOT': 'holotoken',
'THETA': 'theta-token',
'HNT': 'helium',
'SNX': 'synthetix-network-token',
'RUNE': 'thorchain',
'XLM': 'stellar',
'REN': 'ren',
'FTT': 'ftx-token',
'RVN': 'ravencoin',
'KAVA': 'kava',
'CRO': 'crypto-com-chain',
'MIOTA': 'iota',
'ETC': 'ethereum-classic',

// Meme coins
'BABYDOGE': 'baby-doge-coin',
'SAFEMOON': 'safemoon',
'ELON': 'dogelon-mars',

// Add more symbols and tokens as needed
};


// Convert the input to either the API-friendly name or keep it as it is
let crypto = cryptoMap[cryptoInput] || cryptoInput.toLowerCase();

if (crypto) {
fetch(`https://api.coingecko.com/api/v3/simple/price?ids=${crypto}&vs_currencies=usd`)
.then(response => response.json())
.then(data => {
if (data[crypto.toLowerCase()]) {
document.getElementById("price").innerText = "$" + data[crypto.toLowerCase()].usd;
if (data[crypto]) {
document.getElementById("price").innerText = "$" + data[crypto].usd;
} else {
document.getElementById("price").innerText = "Cryptocurrency not found!";
}
Expand Down

0 comments on commit bd541d5

Please sign in to comment.