website/hub/services/static/js/roi-calculator/README.md

1.4 KiB

ROI Calculator Modules

This directory contains the modular ROI Calculator implementation, split into focused, maintainable modules.

Module Structure

Core Modules

  • calculator-core.js - Main ROICalculator class with calculation logic
  • chart-manager.js - Chart.js integration and chart rendering
  • ui-manager.js - DOM updates, table rendering, and metric display
  • export-manager.js - PDF and CSV export functionality
  • input-utils.js - Input validation, parsing, and formatting utilities
  • roi-calculator-app.js - Main application coordinator class

Integration

  • ../roi-calculator-modular.js - Global function wrappers for backward compatibility

Key Improvements

  1. Modular Architecture: Each module has a single responsibility
  2. Error Handling: Comprehensive try-catch blocks with graceful fallbacks
  3. No Global Variables: App instance contained in window.ROICalculatorApp
  4. Type Safety: Input validation and null checks throughout
  5. Separation of Concerns: Calculation, UI, charts, and exports are separated

Usage

All modules are automatically loaded via the HTML template. The ROICalculatorApp class coordinates all modules and provides the same public API as the original monolithic version.

Backward Compatibility

All existing HTML onclick handlers and function calls continue to work through the global wrapper functions in roi-calculator-modular.js.