class VehicleThumbnail { constructor(vehicle) { this.id = vehicle.id_vehicle; this.name = vehicle.make + ' ' + vehicle.model; this.year = vehicle.year; this.make = vehicle.make; this.model = vehicle.model; this.trim = vehicle.trim; this.landingImage = vehicle.landingImage; this.advertisePrice = vehicle.advertise_price.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); this.stockNumber = vehicle.stock_number; this.mileage = vehicle.mileage; } generateCardElement() { const wrapper = document.createElement('div'); wrapper.innerHTML = this.generateCardHTML().trim(); // Get the vehicle-card element const cardElement = wrapper.querySelector('.vehicle-card'); const ripple = new mdc.ripple.MDCRipple(cardElement); ripple.unbounded = false; cardElement.addEventListener('click', () => { console.log(dataStore) var queryString = encodeURIComponent(JSON.stringify(dataStore.filters)); const url = `vehicle-details/?vehicle_id=${encodeURIComponent(this.id)}&filters=${queryString}`; window.location.href = url; }); return cardElement; } generateCardHTML() { return `
Vehicle Image

${this.year} ${this.name} ${this.trim.join(' - ')}

Year: ${this.year}
Mileage: ${this.mileage} km
Price: $${this.advertisePrice}
Stock #: ${this.stockNumber} km
`; } } // Initialize the ripple component for all instances of VehicleThumbnail document.addEventListener('DOMContentLoaded', function () { const vehicleThumbnails = document.querySelectorAll('.mdc-ripple-surface'); vehicleThumbnails.forEach(thumbnail => { const ripple = new mdc.ripple.MDCRipple(thumbnail); ripple.unbounded = true; }); });