Overview
The export functions API provides capabilities to export results as JSON, print formatted reports, reset the application, and manage action buttons.exportarResultados()
Exports all client and vehicle data as a JSON file for download. Source:script.js:529-548
Parameters
This function takes no parameters. It uses global variablesobtenerDatosCliente() and vehiculosData.
Returns
void - Does not return a value
Side Effects
- Creates a JSON blob with all application data
- Triggers browser download
- Filename format:
ITV_{apellidos}_{timestamp}.json - Includes current date and time in Spanish locale
Export Data Structure
Example Implementation
Example Export File
The JSON is formatted with 2-space indentation for readability. The timestamp in the filename ensures unique file names for multiple exports.
imprimirResultados()
Generates a print-friendly version of the results and triggers the browser print dialog. Source:script.js:551-573
Parameters
This function takes no parameters.Returns
void - Does not return a value
Process Flow
- Saves current page HTML
- Extracts results and client information sections
- Replaces page content with print-formatted version
- Triggers browser print dialog
- Restores original page content
- Reinitializes event listeners
The function automatically restores the original page state after printing, ensuring users can continue working without refreshing.
Example Implementation
Print Layout Features
- Header: βConcesionario de Coches - Resultados ITVβ in blue
- Content: Client information and full results
- Footer: Timestamp of when the report was printed
- Styling: Clean, professional Arial font with proper spacing
reiniciarFormulario()
Resets the entire application to its initial state with user confirmation. Source:script.js:522-526
Parameters
This function takes no parameters.Returns
void - Does not return a value
Side Effects
- Shows browser confirmation dialog
- Reloads the entire page if confirmed
- Preserves all data if cancelled
Example Implementation
Usage
This action is destructive and cannot be undone. Always prompts for user confirmation before proceeding.
agregarBotonesAccion()
Adds export, print, and reset action buttons to the results section. Source:script.js:578-605
Parameters
This function takes no parameters.Returns
void - Does not return a value
Side Effects
- Checks if action buttons already exist (prevents duplicates)
- Appends button container to
#muestraelement - Injects secondary button styles if not present
Buttons Created
- π¨οΈ Imprimir - Calls
imprimirResultados() - π₯ Exportar JSON - Calls
exportarResultados() - π Nuevo Formulario - Calls
reiniciarFormulario()
Example Implementation
This function is automatically called 500ms after results are displayed to ensure smooth UI transitions.
agregarEstilosBotonSecundario()
Injects CSS styles for secondary action buttons if not already present. Source:script.js:610-688
Parameters
This function takes no parameters.Returns
void - Does not return a value
Styles Applied
Button Styles (.btn-secondary)
- Gradient background: light gray to slate
- Blue border and text
- Rounded corners (0.5rem)
- Hover effect: purple gradient with lift animation
- Responsive padding and sizing
Vehicle Status Styles
.estado-vehiculo.aprobado: Green background and border.estado-vehiculo.no-aprobado: Red background and border
Other Styles
.observacion-vehiculo: Light blue background for observations.desglose-item: Green background for cost breakdown items.total-final: Purple gradient background for total cost
Example Implementation
Workflow Integration
Typical User Flow
- User fills out client information
- User fills out vehicle forms
- User clicks βCalcular Resultadosβ β
calcularYMostrar() - Results are displayed with action buttons β
agregarBotonesAccion() - User can:
- Print results β
imprimirResultados() - Export to JSON β
exportarResultados() - Start over β
reiniciarFormulario()
- Print results β
Function Call Chain
File Naming Conventions
JSON Export
Format:ITV_{apellidos}_{timestamp}.json
Examples:
ITV_Garcia_1709820225000.jsonITV_Rodriguez_1709820330500.json
The timestamp ensures unique filenames even when exporting multiple times in quick succession.
Browser Compatibility
Required APIs
Blob- For JSON file creationURL.createObjectURL()- For download linkswindow.print()- For print functionalitylocation.reload()- For form resetdocument.createElement()- For dynamic DOM manipulation
Supported Features
- Download attribute on anchor elements
- Modern ES6+ JavaScript syntax
- DOM manipulation
- Spanish locale date/time formatting
Related Functions
- Form Generation - Generate forms to export
- Data Validation - Validate before export
- Calculation Engine - Calculate data to export