This commit is contained in:
Flatlogic Bot 2026-02-22 13:28:22 +00:00
parent 00bab18fd4
commit d45c0ed029

View File

@ -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);