diff --git a/index.html b/index.html index be6da78c5e9ec9f23846a724d7820f71b1816897..1e5a25efd0011aa84ea2475b719fc5f3617e141b 100644 --- a/index.html +++ b/index.html @@ -1,57 +1,76 @@ - - 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 0000000000000000000000000000000000000000..56d7325d208fed6972b7eef079981d6be9b039b5 --- /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 0000000000000000000000000000000000000000..66bc8abab52f51094dee4c1eb6365c3facbb2311 --- /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