document.addEventListener('DOMContentLoaded', function() { // Price Input Handling const priceInput = document.getElementById('current-price'); const useLivePriceBtn = document.getElementById('use-live-price'); const updatePriceBtn = document.getElementById('update-price'); // Position Calculator Elements const capitalInput = document.getElementById('capital'); const riskPercentageInput = document.getElementById('risk-percentage'); const entryPriceInput = document.getElementById('entry-price'); const stopLossInput = document.getElementById('stop-loss'); const calculatePositionBtn = document.getElementById('calculate-position'); const positionResult = document.getElementById('position-result'); const positionSizeEl = document.getElementById('position-size'); const coinAmountEl = document.getElementById('coin-amount'); // Simulate fetching live price (in a real app, this would be from an API) function fetchLivePrice() { showLoading(); setTimeout(() => { // Simulate a live price (between 0.8 and 1.2) const livePrice = (0.8 + Math.random() * 0.4).toFixed(4); priceInput.value = livePrice; updateAnalysis(livePrice); hideLoading(); }, 1000); } // Update analysis based on price function updateAnalysis(price) { // Update recommendation const recommendationEl = document.getElementById('recommendation'); const recommendationText = getRandomRecommendation(); recommendationEl.innerHTML = `
${recommendationText.reason}
جارٍ تحميل البيانات من CoinGecko...