fix: Add debug logging for AI button
This commit is contained in:
@ -104,6 +104,10 @@ body {
|
|||||||
.stat-value.positive { color: #26d367; }
|
.stat-value.positive { color: #26d367; }
|
||||||
.stat-value.negative { color: #ef5350; }
|
.stat-value.negative { color: #ef5350; }
|
||||||
|
|
||||||
|
/* Best Moving Averages percentage change colors */
|
||||||
|
.ta-ma-change.positive { color: #26d367; }
|
||||||
|
.ta-ma-change.negative { color: #ef5350; }
|
||||||
|
|
||||||
|
|
||||||
/* Chart Area */
|
/* Chart Area */
|
||||||
#chartWrapper {
|
#chartWrapper {
|
||||||
@ -199,3 +203,11 @@ body {
|
|||||||
--tv-hover: #252f3f;
|
--tv-hover: #252f3f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Settings Popup */
|
||||||
|
#settingsPopup.hidden {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
#settingsPopup.show {
|
||||||
|
display: block !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
97
js/app.js
97
js/app.js
@ -17,6 +17,7 @@ window.dashboard = null;
|
|||||||
window.toggleSidebar = toggleSidebar;
|
window.toggleSidebar = toggleSidebar;
|
||||||
window.refreshTA = refreshTA;
|
window.refreshTA = refreshTA;
|
||||||
window.openAIAnalysis = openAIAnalysis;
|
window.openAIAnalysis = openAIAnalysis;
|
||||||
|
console.log('[App] openAIAnalysis exported:', typeof window.openAIAnalysis);
|
||||||
window.TimezoneConfig = TimezoneConfig;
|
window.TimezoneConfig = TimezoneConfig;
|
||||||
window.renderIndicatorList = function() {
|
window.renderIndicatorList = function() {
|
||||||
// This function is no longer needed for sidebar indicators
|
// This function is no longer needed for sidebar indicators
|
||||||
@ -43,10 +44,40 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||||||
const settingsPopup = document.getElementById('settingsPopup');
|
const settingsPopup = document.getElementById('settingsPopup');
|
||||||
const settingsBtn = document.getElementById('btnSettings');
|
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) {
|
if (timezoneSelect) {
|
||||||
timezoneSelect.value = TimezoneConfig.getTimezone();
|
const savedTimezone = localStorage.getItem('timezone') || TimezoneConfig.getTimezone();
|
||||||
|
timezoneSelect.value = savedTimezone;
|
||||||
timezoneSelect.addEventListener('change', (e) => {
|
timezoneSelect.addEventListener('change', (e) => {
|
||||||
TimezoneConfig.setTimezone(e.target.value);
|
TimezoneConfig.setTimezone(e.target.value);
|
||||||
|
localStorage.setItem('timezone', e.target.value);
|
||||||
|
settingsPopup.classList.add('hidden');
|
||||||
settingsPopup.classList.remove('show');
|
settingsPopup.classList.remove('show');
|
||||||
// Redraw chart and indicators
|
// Redraw chart and indicators
|
||||||
if (window.dashboard) {
|
if (window.dashboard) {
|
||||||
@ -55,22 +86,6 @@ 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();
|
restoreSidebarState();
|
||||||
restoreSidebarTabState();
|
restoreSidebarTabState();
|
||||||
@ -79,4 +94,52 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||||||
// Initialize panels
|
// Initialize panels
|
||||||
window.initIndicatorPanel();
|
window.initIndicatorPanel();
|
||||||
initStrategyPanel();
|
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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1164,10 +1164,15 @@ export function refreshTA() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function openAIAnalysis() {
|
export function openAIAnalysis() {
|
||||||
|
console.log('[AI] openAIAnalysis called');
|
||||||
|
console.log('[AI] window.dashboard:', window.dashboard);
|
||||||
|
|
||||||
const symbol = 'BTC';
|
const symbol = 'BTC';
|
||||||
const interval = window.dashboard?.currentInterval || '1d';
|
const interval = window.dashboard?.currentInterval || '1d';
|
||||||
|
console.log('[AI] Interval:', interval);
|
||||||
const prompt = `Analyze Bitcoin (${symbol}) ${interval} chart. Current trend, support/resistance levels, and trading recommendation. Technical indicators: MA44, MA125.`;
|
const prompt = `Analyze Bitcoin (${symbol}) ${interval} chart. Current trend, support/resistance levels, and trading recommendation. Technical indicators: MA44, MA125.`;
|
||||||
|
|
||||||
const geminiUrl = `https://gemini.google.com/app?prompt=${encodeURIComponent(prompt)}`;
|
const geminiUrl = `https://gemini.google.com/app?prompt=${encodeURIComponent(prompt)}`;
|
||||||
|
console.log('[AI] Opening URL:', geminiUrl);
|
||||||
window.open(geminiUrl, '_blank');
|
window.open(geminiUrl, '_blank');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
"description": "Web dashboard for BTC trading",
|
"description": "Web dashboard for BTC trading",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "http-server -c-1 -p 3001 -a 0.0.0.0 ."
|
"start": "http-server -c-1 -p 3000 -a 0.0.0.0 ."
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "",
|
"author": "",
|
||||||
|
|||||||
Reference in New Issue
Block a user