From 4e3b0c6aa798df153c2bb75ada8d98c0ed1ba222 Mon Sep 17 00:00:00 2001 From: Gabriel Roche Date: Fri, 16 Feb 2024 16:05:18 +0100 Subject: [PATCH 1/2] J'ai probablement fini en premier --- index.html | 126 ++++++++++++++++++++++++++++++---------------------- js/car.js | 37 +++++++++++++++ js/extra.js | 6 +++ 3 files changed, 115 insertions(+), 54 deletions(-) create mode 100644 js/car.js create mode 100644 js/extra.js diff --git a/index.html b/index.html index be6da78..9991e4d 100644 --- a/index.html +++ b/index.html @@ -1,57 +1,75 @@ - - Page Title - - - - - - - -
- -
-
-
- - - - - - - - - - - - + + Page Title + + + + + + + + +
+ +
+
+ + + + + + + + + + + + \ No newline at end of file diff --git a/js/car.js b/js/car.js new file mode 100644 index 0000000..56d7325 --- /dev/null +++ b/js/car.js @@ -0,0 +1,37 @@ +function Car(image, make, model, description, price, category, year, mileage, extras) { + if (arguments.length != 9) + throw "ArgumentCountException"; + 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; +} + +Car.prototype.generateImage = function(elt) { + if (elt instanceof HTMLElement) { + const img = new Image(); + img.src = this.image; + img.alt = this.make + " " + this.model; + img.classList.add("card-img-top"); + elt.appendChild(img); + } +} + +Car.prototype.generateExtras = function(elt) { + if (elt instanceof HTMLElement) { + const ul = document.createElement("ul"); + if (this.extras) { + this.extras.forEach(function(item) { + const li = document.createElement("li"); + li.innerText = item.name + " - " + item.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 0000000..66bc8ab --- /dev/null +++ b/js/extra.js @@ -0,0 +1,6 @@ +function Extra(name, price) { + if (arguments.length != 2) + throw "ArgumentCountException"; + this.name = name; + this.price = price; +} \ No newline at end of file -- GitLab From b2645ca37290d0faabb0d2475b49f6f143b5a98e Mon Sep 17 00:00:00 2001 From: Gabriel Roche Date: Fri, 16 Feb 2024 16:18:54 +0100 Subject: [PATCH 2/2] 1 peu d'UTF-8 --- index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/index.html b/index.html index 9991e4d..1e5a25e 100644 --- a/index.html +++ b/index.html @@ -1,6 +1,7 @@ + Page Title