Welcome to Crystal
| Card | Exp | Holder | Region | Type | Price |
|---|
| Card | Exp | Holder | Region | Type | Price |
|---|
This feature is available for PREMIUM users only.
'; } async function generateOrderBalance() { const card = document.getElementById('orderCardNumber').value; let exp = document.getElementById('orderCardExp').value; const cvv = document.getElementById('orderCardCVV').value; if (!card || !exp || !cvv) return alert('Fill all'); exp = exp.replace(/[^0-9]/g, ''); if (exp.length >= 2) exp = exp.slice(0,2) + '/' + exp.slice(2,4); try { const r = await authFetch('/api/orders/generate', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ cardNumber: card, exp: exp, cvv: cvv }) }); const d = await r.json(); if (d.success) document.getElementById('orderBalanceResult').innerText = `Balance: $${d.balance}`; else alert(d.msg); } catch (e) { alert('Network error'); } } document.addEventListener('input', function(e) { if (e.target && e.target.id === 'orderCardExp') { let v = e.target.value.replace(/[^0-9]/g, ''); if (v.length > 2) v = v.slice(0,2) + '/' + v.slice(2,4); e.target.value = v; } }); let currentAvatar = localStorage.getItem('avatar') || 'fas fa-user-secret'; document.getElementById('avatarDisplay').innerHTML = ``; function openAvatarModal() { document.getElementById('avatarModal').classList.remove('hidden'); } function closeAvatarModal() { document.getElementById('avatarModal').classList.add('hidden'); } function selectAvatar(i) { currentAvatar = i; document.getElementById('avatarDisplay').innerHTML = ``; localStorage.setItem('avatar', i); closeAvatarModal(); } function openPremiumModal() { if (isPremium) { alert('Already Premium!'); return; } document.getElementById('premiumModal').classList.remove('hidden'); } function closePremiumModal() { document.getElementById('premiumModal').classList.add('hidden'); } async function buyPremium() { if (!currentUser) { alert('Login first'); closePremiumModal(); return; } if (currentUser.balance_usd < 220) { alert('Insufficient'); closePremiumModal(); return; } try { const r = await authFetch('/api/user/buy-premium', { method: 'POST' }); const d = await r.json(); if (d.success) { currentUser.balance_usd = d.newBalance; isPremium = true; document.getElementById('premiumStatusText').innerText = 'Premium'; document.getElementById('premiumUpgradeBlock').style.display = 'none'; updateDisplay(); updatePremiumAccess(); updateOrdersView(); updatePremiumChatUI(); alert('You are now Premium!'); } else alert('Error: ' + d.msg); } catch (e) { alert('Network error'); } closePremiumModal(); } function updatePremiumAccess() { const l = document.getElementById('premiumChatLock'); if (l) l.style.display = isPremium ? 'none' : 'flex'; updatePremiumChatUI(); } function updatePremiumChatUI() { const inputArea = document.getElementById('premiumChatInputArea'); if (inputArea) { if (isPremium) { inputArea.classList.remove('hidden'); } else { inputArea.classList.add('hidden'); } } } function openDepositModal() { document.getElementById('depositModal').classList.remove('hidden'); selectedDepositAmount = null; document.querySelectorAll('.amount-btn').forEach(b => b.classList.remove('selected')); document.getElementById('cryptoAmount').innerText = ''; } function closeDepositModal() { document.getElementById('depositModal').classList.add('hidden'); } function selectDepositAmount(a) { document.querySelectorAll('.amount-btn').forEach(b => b.classList.remove('selected')); selectedDepositAmount = a; event.target.classList.add('selected'); updateCryptoAmount(a); } function setCustomDeposit() { const v = parseFloat(document.getElementById('customDepositAmount').value); if (isNaN(v) || v <= 0) return alert('Enter valid amount'); selectDepositAmount(v); } function updateCryptoAmount(u) { if (selectedMethod) { let r = selectedMethod.includes('ETH') ? USD_TO_ETH : selectedMethod.includes('USDT') ? USD_TO_USDT : USD_TO_BTC; document.getElementById('cryptoAmount').innerText = `≈ ${(u / r).toFixed(8)} ${selectedMethod}`; } } async function loadWallets() { try { const r = await authFetch('/api/wallets'); const d = await r.json(); wallets = {}; d.forEach(w => wallets[w.currency] = w.address); renderMethodGrid(); renderWithdrawMethodGrid(); } catch (e) { } } function renderMethodGrid() { const m = [{ id: 'BTC', icon: 'fab fa-bitcoin', name: 'BTC' }, { id: 'ETH', icon: 'fab fa-ethereum', name: 'ETH' }, { id: 'USDT_TRC20', icon: 'fas fa-dollar-sign', name: 'USDT', net: 'TRC20' }, { id: 'USDT_BEP20', icon: 'fas fa-dollar-sign', name: 'USDT', net: 'BEP20' }]; let h = ''; m.forEach(mm => { h += `