Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Alert for Cryptocurrency Price Fetching in script.js #116

Open
wants to merge 8 commits into
base: gh-pages
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions alert.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import requests
import time

# Function to get current crypto price from API (CoinGecko)
def get_crypto_price(crypto):
url = f"https://api.coingecko.com/api/v3/simple/price?ids={crypto}&vs_currencies=usd"
response = requests.get(url)
data = response.json()
return data[crypto]['usd']

# Alert function
def check_price(crypto, threshold):
current_price = get_crypto_price(crypto)
if current_price >= threshold:
print(f"Alert! {crypto} price has reached ${current_price} (Threshold: ${threshold})")
else:
print(f"{crypto} price: ${current_price}. Below threshold.")

# Example usage
crypto = "bitcoin" # Track Bitcoin
threshold = 50000 # Set a threshold for alerts

while True:
check_price(crypto, threshold)
time.sleep(300) # Check price every 5 minutes
65 changes: 3 additions & 62 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ function toggleMenu() {

// A map of symbols to their corresponding API names
const cryptoMap = {
// Major cryptocurrencies
'BTC': 'bitcoin',
'ETH': 'ethereum',
'USDT': 'tether',
Expand All @@ -75,40 +74,28 @@ const cryptoMap = {
'NEAR': 'near',
'HBAR': 'hedera-hashgraph',
'TON': 'toncoin',
'SUI':'sui',
'SUI': 'sui',
'OP': 'optimism',
'INJ': 'injective',
'ARB': 'arbitrum',

// 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',
Expand All @@ -132,17 +119,13 @@ const cryptoMap = {
'CRO': 'crypto-com-chain',
'MIOTA': 'iota',
'ETC': 'ethereum-classic',

// Meme coins
'BABYDOGE': 'baby-doge-coin',
'SAFEMOON': 'safemoon',
'ELON': 'dogelon-mars',
'PEPE': 'memetic',
'WIF': 'dogwithat',
'BONK': 'bonk',
'FLOKI': 'floki',

// Add more symbols and tokens as needed
'WETH': 'wrapped-ethereum',
'MKR': 'maker',
'BAL': 'balancer',
Expand Down Expand Up @@ -194,6 +177,7 @@ document.getElementById('predict-btn').addEventListener('click', function() {
.then(data => {
if (data[crypto]) {
document.getElementById("price").innerText = "$" + data[crypto].usd;
alert(`The current price of ${cryptoInputValue} is $${data[crypto].usd}`); // Alert with the price
} else {
document.getElementById("price").innerText = "Cryptocurrency not found!";
}
Expand All @@ -209,7 +193,6 @@ document.getElementById('predict-btn').addEventListener('click', function() {

// GSAP Animations
document.addEventListener('DOMContentLoaded', () => {
// Timeline for header and intro text animations
let tl = gsap.timeline();

tl.from("header h1", {
Expand All @@ -227,7 +210,6 @@ document.addEventListener('DOMContentLoaded', () => {
delay: 0.2
});

// Crypto price predictor section
tl.from("#crypto-price-predictor h2", {
y: 50,
opacity: 0,
Expand All @@ -251,53 +233,13 @@ document.addEventListener('DOMContentLoaded', () => {
delay: 0.2
});

// Animate the price result after prediction
gsap.from("#price-result", {
opacity: 0,
duration: 1,
ease: "power2.inOut",
delay: 1.5
});

// Telegram bot section animation
gsap.from("#telegram-bot", {
opacity: 0,
y: 100,
duration: 0.8,
ease: "power2.out",
delay: 1
});

// Repo info section
gsap.from("#repo-info h2", {
opacity: 0,
x: -100,
duration: 0.8,
ease: "power3.out",
delay: 1.5
});

gsap.from("#repo-info p", {
opacity: 0,
y: 30,
duration: 0.8,
ease: "power3.out",
delay: 1.7
});

gsap.from("#repo-info a", {
opacity: 0,
scale: 0.8,
duration: 0.6,
ease: "elastic.out(1, 0.75)",
delay: 1.9
ease: "power1.out"
});
});





const tabs = document.querySelectorAll('.tab');
const cursor = document.getElementById('cursor');

Expand Down Expand Up @@ -344,4 +286,3 @@ document.addEventListener('DOMContentLoaded', function () {
});
});
});