diff --git a/dashboard/dashboard.js b/dashboard/dashboard.js index dfc82a6..c51a133 100644 --- a/dashboard/dashboard.js +++ b/dashboard/dashboard.js @@ -587,6 +587,53 @@ class VehicleDashboard { this.displayVehicles(); } + // Helper: Extract engine configuration from engine name + getEngineConfig(engineName) { + if (!engineName) return 'N/A'; + const upper = engineName.toUpperCase(); + + // Match patterns like V6, V8, I4, H4, W12 + const vMatch = upper.match(/V(\d+)/); + if (vMatch) return `V${vMatch[1]}`; + + const iMatch = upper.match(/I(\d+)|INLINE[- ]?(\d+)/); + if (iMatch) return `I${iMatch[1] || iMatch[2]}`; + + const hMatch = upper.match(/H(\d+)|FLAT[- ]?(\d+)/); + if (hMatch) return `H${hMatch[1] || hMatch[2]}`; + + const wMatch = upper.match(/W(\d+)/); + if (wMatch) return `W${wMatch[1]}`; + + // Try to derive from cylinder count in name + const cylMatch = upper.match(/(\d)[- ]?CYL/); + if (cylMatch) return `${cylMatch[1]} Cil`; + + if (upper.includes('ELECTRIC')) return 'EV'; + if (upper.includes('ROTARY')) return 'Rotary'; + + return 'N/A'; + } + + // Helper: Format displacement (cc to L) + formatDisplacement(cc) { + if (!cc || cc === 0) return 'N/A'; + const liters = (cc / 1000).toFixed(1); + return `${liters}L`; + } + + // Helper: Format fuel type in Spanish + formatFuelType(fuel) { + const types = { + 'gasoline': 'Gasolina', + 'diesel': 'Diésel', + 'electric': 'Eléctrico', + 'hybrid': 'Híbrido', + 'other': 'Otro' + }; + return types[fuel] || fuel || 'N/A'; + } + displayVehicles() { const container = document.getElementById('mainContent'); const resultCount = document.getElementById('resultCount'); @@ -595,7 +642,7 @@ class VehicleDashboard { if (this.filteredVehicles.length === 0) { container.innerHTML = ` -
Intenta ajustar los filtros
@@ -615,32 +662,32 @@ class VehicleDashboard {