Fix export syntax using standalone function declarations

- Converted window.addIndicator to standalone function 'addIndicator'
- Converted window.removeIndicatorById to standalone function 'removeIndicatorById'
- Added standalone function removeIndicatorByIndex
- Export all three functions directly
- Assign to window for backward compatibility
- Fixes 'Unexpected token' error in export statements
This commit is contained in:
DiTus
2026-02-25 22:43:05 +01:00
parent 5140e437b0
commit d0fbe8cfe5

View File

@ -382,10 +382,10 @@ window.clearAllIndicators = function() {
activeIndicators = []; activeIndicators = [];
configuringId = null; configuringId = null;
renderIndicatorPanel(); renderIndicatorPanel();
drawIndicatorsOnChart(); drawIndicatorsOnChart();
}; };
window.addIndicator = function(type) { function addIndicator(type) {
const IndicatorClass = IR?.[type]; const IndicatorClass = IR?.[type];
if (!IndicatorClass) return; if (!IndicatorClass) return;
@ -500,7 +500,7 @@ window.resetIndicator = function(id) {
drawIndicatorsOnChart(); drawIndicatorsOnChart();
}; };
window.removeIndicatorById = function(id) { function removeIndicatorById(id) {
const idx = activeIndicators.findIndex(a => a.id === id); const idx = activeIndicators.findIndex(a => a.id === id);
if (idx < 0) return; if (idx < 0) return;
@ -516,7 +516,12 @@ window.removeIndicatorById = function(id) {
renderIndicatorPanel(); renderIndicatorPanel();
drawIndicatorsOnChart(); drawIndicatorsOnChart();
}; }
function removeIndicatorByIndex(index) {
if (index < 0 || index >= activeIndicators.length) return;
removeIndicatorById(activeIndicators[index].id);
}
// Presets // Presets
function getPresetsForIndicator(indicatorName) { function getPresetsForIndicator(indicatorName) {
@ -707,7 +712,9 @@ window.removeIndicator = function() {
}; };
// Assign to window for backward compatibility // Assign to window for backward compatibility
window.toggleIndicator = window.addIndicator; window.toggleIndicator = addIndicator;
window.addIndicator = addIndicator;
window.removeIndicatorById = removeIndicatorById;
window.removeIndicatorByIndex = function(index) { window.removeIndicatorByIndex = function(index) {
if (index < 0 || index >= activeIndicators.length) return; if (index < 0 || index >= activeIndicators.length) return;
removeIndicatorById(activeIndicators[index].id); removeIndicatorById(activeIndicators[index].id);
@ -715,6 +722,4 @@ window.removeIndicatorByIndex = function(index) {
window.drawIndicatorsOnChart = drawIndicatorsOnChart; window.drawIndicatorsOnChart = drawIndicatorsOnChart;
// Export functions for module imports // Export functions for module imports
export { window.addIndicator as addIndicator }; export { addIndicator, removeIndicatorById, removeIndicatorByIndex };
export { window.removeIndicatorById as removeIndicatorById };
export { window.removeIndicatorByIndex as removeIndicatorByIndex };