fix: Add debug logging for AI button

This commit is contained in:
DiTus
2026-03-21 07:49:58 +01:00
parent 785792fa6e
commit 3ec2e41da7
4 changed files with 99 additions and 19 deletions

View File

@ -17,6 +17,7 @@ window.dashboard = null;
window.toggleSidebar = toggleSidebar;
window.refreshTA = refreshTA;
window.openAIAnalysis = openAIAnalysis;
console.log('[App] openAIAnalysis exported:', typeof window.openAIAnalysis);
window.TimezoneConfig = TimezoneConfig;
window.renderIndicatorList = function() {
// This function is no longer needed for sidebar indicators
@ -43,10 +44,40 @@ document.addEventListener('DOMContentLoaded', async () => {
const settingsPopup = document.getElementById('settingsPopup');
const settingsBtn = document.getElementById('btnSettings');
// Toggle settings popup
if (settingsBtn && settingsPopup) {
settingsBtn.addEventListener('click', (e) => {
e.stopPropagation();
settingsPopup.classList.toggle('hidden');
if (!settingsPopup.classList.contains('hidden')) {
settingsPopup.classList.add('show');
}
});
settingsPopup.addEventListener('click', (e) => {
e.stopPropagation();
// Check if click is on form elements or their containers
if (e.target.tagName === 'INPUT' || e.target.tagName === 'SELECT' || e.target.closest('input') || e.target.closest('select')) {
return;
}
});
document.addEventListener('click', (e) => {
// Don't close if clicking on settings button or inside the popup
if (!settingsBtn.contains(e.target) && !settingsPopup.contains(e.target)) {
settingsPopup.classList.add('hidden');
settingsPopup.classList.remove('show');
}
});
}
if (timezoneSelect) {
timezoneSelect.value = TimezoneConfig.getTimezone();
const savedTimezone = localStorage.getItem('timezone') || TimezoneConfig.getTimezone();
timezoneSelect.value = savedTimezone;
timezoneSelect.addEventListener('change', (e) => {
TimezoneConfig.setTimezone(e.target.value);
localStorage.setItem('timezone', e.target.value);
settingsPopup.classList.add('hidden');
settingsPopup.classList.remove('show');
// Redraw chart and indicators
if (window.dashboard) {
@ -55,23 +86,7 @@ document.addEventListener('DOMContentLoaded', async () => {
});
}
// Toggle settings popup
if (settingsBtn && settingsPopup) {
settingsBtn.addEventListener('click', (e) => {
e.stopPropagation();
settingsPopup.classList.toggle('show');
});
settingsPopup.addEventListener('click', (e) => {
e.stopPropagation();
});
document.addEventListener('click', () => {
settingsPopup.classList.remove('show');
});
}
window.dashboard = new TradingDashboard();
window.dashboard = new TradingDashboard();
restoreSidebarState();
restoreSidebarTabState();
initSidebarTabs();
@ -79,4 +94,52 @@ document.addEventListener('DOMContentLoaded', async () => {
// Initialize panels
window.initIndicatorPanel();
initStrategyPanel();
// Initialize candle color pickers (after dashboard is created)
const candleUpColor = document.getElementById('candleUpColor');
const candleDownColor = document.getElementById('candleDownColor');
if (candleUpColor) {
candleUpColor.value = localStorage.getItem('candleUpColor') || '#ff9800';
candleUpColor.addEventListener('input', (e) => {
localStorage.setItem('candleUpColor', e.target.value);
if (window.dashboard && window.dashboard.candleSeries) {
window.dashboard.candleSeries.applyOptions({
upColor: e.target.value,
borderUpColor: e.target.value,
wickUpColor: e.target.value
});
}
});
}
if (candleDownColor) {
candleDownColor.value = localStorage.getItem('candleDownColor') || '#ff9800';
candleDownColor.addEventListener('input', (e) => {
localStorage.setItem('candleDownColor', e.target.value);
if (window.dashboard && window.dashboard.candleSeries) {
window.dashboard.candleSeries.applyOptions({
downColor: e.target.value,
borderDownColor: e.target.value,
wickDownColor: e.target.value
});
}
});
}
const priceDecimalsInput = document.getElementById('priceDecimalsInput');
if (priceDecimalsInput) {
const storedValue = localStorage.getItem('priceDecimals');
console.log('[App] Loaded priceDecimals from localStorage:', storedValue);
priceDecimalsInput.value = storedValue !== null && storedValue !== '' ? storedValue : '2';
priceDecimalsInput.addEventListener('input', (e) => {
const parsed = parseInt(e.target.value);
const value = Math.max(0, Math.min(8, isNaN(parsed) ? 2 : parsed));
console.log('[App] Setting priceDecimals to:', value);
localStorage.setItem('priceDecimals', value.toString());
if (window.dashboard && window.dashboard.updatePricePrecision) {
window.dashboard.updatePricePrecision(value);
}
});
}
});