From 6b0442cf04f8742fbef988f24576db3cf62f4400 Mon Sep 17 00:00:00 2001 From: Thomas Boudeele Date: Fri, 16 Feb 2024 14:47:43 +0100 Subject: [PATCH] Avec les compliments du chef --- index.html | 67 +++++++++++++++++++++++++++++++---------------------- js/car.js | 36 ++++++++++++++++++++++++++++ js/extra.js | 6 +++++ js/index.js | 2 +- 4 files changed, 82 insertions(+), 29 deletions(-) create mode 100644 js/car.js create mode 100644 js/extra.js diff --git a/index.html b/index.html index be6da78..71cef0b 100644 --- a/index.html +++ b/index.html @@ -1,48 +1,59 @@ - Page Title - - + Page Title + +
- -
-
+ +
+
- + + diff --git a/js/car.js b/js/car.js new file mode 100644 index 0000000..1e38fc0 --- /dev/null +++ b/js/car.js @@ -0,0 +1,36 @@ +function Car(image, make, model, desc,price,category,year,mileage,tabExtra) +{ + this.image = image; + this.make = make; + this.model = model; + this.desc = desc; + this.price = price; + this.category = category; + this.year = year; + this.mileage = mileage; + this.tabExtra = tabExtra; +} + +Car.prototype.generateImage = function(elt) +{ + let nv_img = document.createElement('img') + nv_img.src = this.image; + nv_img.alt = this.make + " " + this.model + nv_img.classList.add("card-img-top"); + + elt.appendChild(nv_img); +} + +Car.prototype.generateExtras = function(elt) +{ + let nv_ul = document.createElement('ul'); + + for (let index = 0; index < this.tabExtra.length; index++) + { + let nv_li = document.createElement('li'); + nv_li.textContent = this.tabExtra[index].name + " " + this.tabExtra[index].price + nv_ul.appendChild(nv_li); + } + + elt.appendChild(nv_ul); +} \ No newline at end of file diff --git a/js/extra.js b/js/extra.js new file mode 100644 index 0000000..15a9e80 --- /dev/null +++ b/js/extra.js @@ -0,0 +1,6 @@ +function Extra(name, price) +{ + this.name = name; + this.price = price; +} + diff --git a/js/index.js b/js/index.js index 4e1d119..e747b0a 100644 --- a/js/index.js +++ b/js/index.js @@ -124,7 +124,7 @@ for (const car of cars) {
  • Année: ${car.year}
  • Kilométrage: ${car.mileage}
  • - +
    -- GitLab