refactor roi calc js into modular files
This commit is contained in:
parent
51d80364c0
commit
afe3817395
11 changed files with 1611 additions and 1144 deletions
34
hub/services/static/js/roi-calculator/README.md
Normal file
34
hub/services/static/js/roi-calculator/README.md
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
# 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`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue