From d45c0ed029c32e7e0fdefb4585235ad4694c0cba Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Sun, 22 Feb 2026 13:28:22 +0000 Subject: [PATCH] 211222 --- recharge.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/recharge.php b/recharge.php index e349e34..28e9592 100644 --- a/recharge.php +++ b/recharge.php @@ -412,12 +412,18 @@ let remainingSeconds = 1800; let modalChatPolling = false; window.lastRechargeStatus = null; +// Helper to get relative API path correctly regardless of subdir +const getApiPath = () => { + return 'api/'; +}; + async function updateRate() { const select = document.getElementById('fiatCurrency'); + if (!select) return; const symbol = select.value; try { - const resp = await fetch(apiPath + 'exchange.php?v=' + Date.now()); + const resp = await fetch(getApiPath() + 'exchange.php?v=' + Date.now()); const data = await resp.json(); if (data.success && data.rates) { exchangeRates = data.rates; @@ -486,7 +492,7 @@ function finishTransfer() { const formData = new FormData(); formData.append('action', 'complete_transfer'); formData.append('order_id', orderId); - fetch(apiPath + 'finance.php?v=' + Date.now(), { method: 'POST', body: formData }) + fetch(getApiPath() + 'finance.php?v=' + Date.now(), { method: 'POST', body: formData }) .then(r => r.json()) .then(data => { if (data.success) { @@ -549,14 +555,13 @@ function startStatusPolling(order_id) { const modalEl = document.getElementById('rechargeModal'); if (!modalEl || !modalEl.classList.contains('show')) return; try { - const r = await fetch(apiPath + `recharge_status.php?id=${order_id}&t=${Date.now()}`); + const r = await fetch(getApiPath() + `recharge_status.php?id=${order_id}&t=${Date.now()}`); if (!r.ok) throw new Error('Network response was not ok'); const data = await r.json(); if (data.success) { const currentStatus = String(data.status); - const side = document.querySelector('.info-side'); - if (window.lastRechargeStatus !== currentStatus || (side && side.innerHTML.trim() === "")) { + if (window.lastRechargeStatus !== currentStatus) { window.lastRechargeStatus = currentStatus; renderRechargeUI(data); } @@ -580,7 +585,7 @@ function renderRechargeUI(data) { const status = String(data.status || '0'); if (status === 'completed' || status === '3') { - finishTransferUI(); + setTimeout(() => finishTransferUI(), 500); return; } @@ -753,7 +758,7 @@ document.addEventListener('DOMContentLoaded', async () => { if (remainingSeconds > 0 && state.orderId) { openRechargeModal(state.initialMessage, true, state.orderId); try { - const r = await fetch(apiPath + `recharge_status.php?id=${state.orderId}&_t=${Date.now()}`); + const r = await fetch(getApiPath() + `recharge_status.php?id=${state.orderId}&_t=${Date.now()}`); const data = await r.json(); if (data.success) { window.lastRechargeStatus = String(data.status);