// ... existing variables ... const BUY_RATE = 88; const SELL_RATE = 87; // Sell rate thoda kam rakhte hain profit ke liye let mode = 'BUY'; // Default function setMode(m) { mode = m; // UI Toggle Logic... if(m == 'BUY') { document.getElementById('mainBtn').innerText = "Proceed to Buy"; document.querySelector('.label-addr').innerText = "Your Wallet Address (TRC20)"; document.getElementById('addr').placeholder = "Paste your USDT Address"; document.querySelector('.rate-tag').innerText = "1 USDT = ₹" + BUY_RATE; } else { document.getElementById('mainBtn').innerText = "Proceed to Withdraw"; document.querySelector('.label-addr').innerText = "Your UPI ID (For Payment)"; document.getElementById('addr').placeholder = "e.g. user@ybl"; document.querySelector('.rate-tag').innerText = "1 USDT = ₹" + SELL_RATE; } document.getElementById('inr').value = ''; document.getElementById('usdt').value = ''; } function calc() { let v = document.getElementById('inr').value; let rate = mode == 'BUY' ? BUY_RATE : SELL_RATE; if(v > 0) { document.getElementById('usdt').value = (v / rate).toFixed(2); let addr = document.getElementById('addr').value; if(v >= 500 && addr.length > 3) document.getElementById('mainBtn').disabled = false; else document.getElementById('mainBtn').disabled = true; } } function submitOrder() { // ... UI Hiding Logic ... let fd = new FormData(); fd.append('action', 'create'); fd.append('type', mode); // Sends BUY or SELL fd.append('inr', document.getElementById('inr').value); fd.append('usdt', document.getElementById('usdt').value); // IMPORTANT: Yeh line check karo. 'addr' field ab multipurpose hai. // Buy me ye Wallet Address hai, Sell me ye UPI ID hai. fd.append('details', document.getElementById('addr').value); fd.append('proof', document.getElementById('file').files[0]); // Send to PHP fetch('api.php', {method:'POST', body:fd}) .then(r=>r.json()) .then(d=>{ if(d.status=='success'){ orderId = d.id; // ... Start Polling ... } }); }