primevue-mirror/apps/showcase/service/CarService.js

39 lines
1.0 KiB
JavaScript
Raw Permalink Normal View History

2023-02-28 08:29:30 +00:00
export const CarService = {
brands: ['Vapid', 'Carson', 'Kitano', 'Dabver', 'Ibex', 'Morello', 'Akira', 'Titan', 'Dover', 'Norma'],
2021-12-05 17:21:38 +00:00
2023-02-28 08:29:30 +00:00
colors: ['Black', 'White', 'Red', 'Blue', 'Silver', 'Green', 'Yellow'],
2021-12-05 17:21:38 +00:00
generateCar(id) {
return {
id,
vin: this.generateVin(),
brand: this.generateBrand(),
color: this.generateColor(),
year: this.generateYear()
2022-09-14 14:26:41 +00:00
};
2023-02-28 08:29:30 +00:00
},
2021-12-05 17:21:38 +00:00
generateVin() {
2022-09-14 14:26:41 +00:00
let text = '';
let possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
2021-12-05 17:21:38 +00:00
for (let i = 0; i < 5; i++) {
text += possible.charAt(Math.floor(Math.random() * possible.length));
}
return text;
2023-02-28 08:29:30 +00:00
},
2021-12-05 17:21:38 +00:00
generateBrand() {
return this.brands[Math.floor(Math.random() * Math.floor(10))];
2023-02-28 08:29:30 +00:00
},
2021-12-05 17:21:38 +00:00
generateColor() {
return this.colors[Math.floor(Math.random() * Math.floor(7))];
2023-02-28 08:29:30 +00:00
},
2021-12-05 17:21:38 +00:00
generateYear() {
return 2000 + Math.floor(Math.random() * Math.floor(19));
}
2023-02-28 08:29:30 +00:00
};