document.addEventListener('DOMContentLoaded', function() { const startBotBtn = document.getElementById('startBotBtn'); const stopBotBtn = document.getElementById('stopBotBtn'); const botStatus = document.getElementById('botStatus'); const logContainer = document.getElementById('logContainer'); let botRunning = false; let logEntries = []; let fakeOperationInterval; // Simulate bot operation function simulateBotOperation() { const now = new Date(); const timeString = now.toLocaleTimeString(); // Add log entry addLogEntry(`[${timeString}] Bot iniciado com sucesso`, 'info'); addLogEntry(`[${timeString}] Conectado à IQ Option`, 'info'); addLogEntry(`[${timeString}] Par de ativos: EURUSD-OTC`, 'info'); addLogEntry(`[${timeString}] Martingale: 2 níveis`, 'info'); // Simulate periodic operations fakeOperationInterval = setInterval(() => { const opTime = new Date(); const opTimeString = opTime.toLocaleTimeString(); const randomOutcome = Math.random() > 0.4 ? 'WIN' : 'LOSS'; if (randomOutcome === 'WIN') { addLogEntry(`[${opTimeString}] Operação concluída: WIN! Lucro: $${(Math.random() * 5 + 1).toFixed(2)}`, 'info'); } else { addLogEntry(`[${opTimeString}] Operação concluída: LOSS. Aplicando Martingale...`, 'warning'); } }, 5000); } // Add log entry function addLogEntry(message, type = 'info') { const entry = document.createElement('div'); entry.className = `log-entry ${type}`; entry.textContent = message; logContainer.prepend(entry); logEntries.unshift(message); // Keep log clean if (logEntries.length > 50) { logContainer.removeChild(logContainer.lastChild); logEntries.pop(); } } // Start bot startBotBtn.addEventListener('click', function() { if (!botRunning) { botRunning = true; botStatus.className = 'inline-block w-3 h-3 rounded-full bg-green-500 mr-2 pulse-animation'; startBotBtn.classList.add('opacity-50', 'cursor-not-allowed'); startBotBtn.disabled = true; stopBotBtn.classList.remove('opacity-50', 'cursor-not-allowed'); stopBotBtn.disabled = false; simulateBotOperation(); } }); // Stop bot stopBotBtn.addEventListener('click', function() { if (botRunning) { botRunning = false; botStatus.className = 'inline-block w-3 h-3 rounded-full bg-red-500 mr-2'; stopBotBtn.classList.add('opacity-50', 'cursor-not-allowed'); stopBotBtn.disabled = true; startBotBtn.classList.remove('opacity-50', 'cursor-not-allowed'); startBotBtn.disabled = false; clearInterval(fakeOperationInterval); const now = new Date(); const timeString = now.toLocaleTimeString(); addLogEntry(`[${timeString}] Bot parado pelo usuário`, 'warning'); } }); // Initialize UI feather.replace(); });