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