diff --git a/index.html b/index.html index be6da78c5e9ec9f23846a724d7820f71b1816897..0d8f8f8542de0412962c5978259f9cc5c755b3ef 100644 --- a/index.html +++ b/index.html @@ -1,57 +1,76 @@ + Page Title - + + - - + + -
- -
+
+ +
+
-
- + + + - + - - + + - - + + + + + \ No newline at end of file diff --git a/js/car.js b/js/car.js new file mode 100644 index 0000000000000000000000000000000000000000..95debb94032f2d34e4fa2e94e4201d6f5c6a40eb --- /dev/null +++ b/js/car.js @@ -0,0 +1,31 @@ +function Car(image, make, model, description, price, category, year, mileage, extras) { + this.image = image; + this.make = make; + this.model = model; + this.description = description; + this.price = price; + this.category = category; + this.year = year; + this.mileage = mileage; + this.extras = extras; +} + +//je ne comprend pas pourquoi les images ne s'affiche pas +Car.prototype.generateImage = function (elt) { + crossOriginIsolated.log(this.image); + let img = document.createElement("img"); + img.setAttribute("src", this.image); + img.setAttribute("alt", this.make + " " + this.model); + img.setAttribute("class", "card-img-top"); + elt.appendChild(img); +} + +Car.prototype.generateExtras = function (elt){ + let ul = document.createElement("ul"); + for (let extra of this.extras) { + let li = document.createElement("li"); + li.textContent = extra.name + ' - €' + extra.price; + ul.appendChild(li); + } + elt.appendChild(ul); +} \ No newline at end of file diff --git a/js/extra.js b/js/extra.js new file mode 100644 index 0000000000000000000000000000000000000000..d5f7ff9bd055aaff03a975e7372fe578b0c8ea21 --- /dev/null +++ b/js/extra.js @@ -0,0 +1,4 @@ +function Extra(name, price) { + this.name = name; + this.price = price; +} \ No newline at end of file