Implement bot status toggle functionality in agent.user.js, allowing users to switch between idle and running states. Update UI elements for better interaction and clarity, including improved status display and event handling for the toggle button.

This commit is contained in:
thuanle
2025-08-03 01:37:39 +07:00
parent 00dd2a2eee
commit 2d175e571f

View File

@@ -633,7 +633,7 @@ GM_log('[TL] 🏁 Welcome to Binance Alpha Farm Agent.');
statusDisplay = '▶️ Running';
break;
default:
statusDisplay = '❓ Unknown';
statusDisplay = AppSettings.getBotStatus();
}
// Get server info
@@ -663,7 +663,7 @@ GM_log('[TL] 🏁 Welcome to Binance Alpha Farm Agent.');
<span id="debug-toggle-btn" style="color: ${AppSettings.getDebug() ? '#17a2b8' : '#6c757d'}; cursor: pointer; padding: 2px 4px; border-radius: 3px; border: 1px solid ${AppSettings.getDebug() ? '#17a2b8' : '#6c757d'}; background: ${AppSettings.getDebug() ? 'rgba(23, 162, 184, 0.1)' : 'rgba(108, 117, 125, 0.1)'}; transition: all 0.2s ease;" title="Click to toggle debug mode">🐛 Debug: ${AppSettings.getDebug() ? '✔️ ON' : '❌ OFF'}</span>
</div>
<div style="margin-bottom: 4px;">
<span style="color: #007bff;">Bot Status: ${statusDisplay}</span>
<span id="bot-status-toggle-btn" style="color: #007bff; cursor: pointer; padding: 2px 4px; border-radius: 3px; border: 1px solid #007bff; background: rgba(0, 123, 255, 0.1); transition: all 0.2s ease;" title="Click to toggle bot status between idle and running">🤖 Bot Status: ${statusDisplay}</span>
</div>
<div style="margin-bottom: 4px;">
<span id="server-toggle-btn" style="color: #e83e8c; cursor: pointer; padding: 2px 4px; border-radius: 3px; border: 1px solid #e83e8c; background: rgba(232, 62, 140, 0.1); transition: all 0.2s ease;" title="Click to switch between local and prod servers">🌐 Server: ${serverLabel} ${serverConnected}</span>
@@ -714,6 +714,18 @@ GM_log('[TL] 🏁 Welcome to Binance Alpha Farm Agent.');
};
}
// Add event listener for bot status toggle button
const botStatusToggleBtn = contentDiv.querySelector('#bot-status-toggle-btn');
if (botStatusToggleBtn) {
botStatusToggleBtn.onclick = () => {
const currentBotStatus = AppSettings.getBotStatus();
const newBotStatus = currentBotStatus === AppEnums.BOT_STATUS.IDLE ? AppEnums.BOT_STATUS.RUNNING : AppEnums.BOT_STATUS.IDLE;
AppSettings.setBotStatus(newBotStatus);
// Update the content to reflect the change
AppUi.dashboardOverlay.updateContent();
};
}
// Add event listener for server toggle button
const serverToggleBtn = contentDiv.querySelector('#server-toggle-btn');
if (serverToggleBtn) {