From 57ce5dc9ad910f1c9955dcfa3319c0db635652b0 Mon Sep 17 00:00:00 2001 From: Killian Deslandes Date: Fri, 16 Feb 2024 16:06:40 +0100 Subject: [PATCH 1/4] prototype car et extra + generateImage --- js/car.js | 19 +++++++++++++++++++ js/extra.js | 4 ++++ 2 files changed, 23 insertions(+) create mode 100644 js/car.js create mode 100644 js/extra.js diff --git a/js/car.js b/js/car.js new file mode 100644 index 0000000..96a152c --- /dev/null +++ b/js/car.js @@ -0,0 +1,19 @@ +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; +} + +Car.prototype.generateImage = function(elt) { + const img = document.createElement('img'); + img.src = this.image; + img.alt = this.make + " " + this.model; + img.classList.add('card-img-top'); + elt.appendChild(img); +}; \ No newline at end of file diff --git a/js/extra.js b/js/extra.js new file mode 100644 index 0000000..d5f7ff9 --- /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 -- GitLab From 91f88e78651f6136219faca43a41b62a7d2705aa Mon Sep 17 00:00:00 2001 From: Killian Deslandes Date: Fri, 16 Feb 2024 16:07:45 +0100 Subject: [PATCH 2/4] prototype dans le index.html --- index.html | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/index.html b/index.html index be6da78..1d5d41b 100644 --- a/index.html +++ b/index.html @@ -32,12 +32,17 @@ + +