Select Git revision
validations_view.py
Forked from
Jean-Marie Place / SCODOC_R6A06
Source project has a limited visibility.
-
Emmanuel Viennet authoredEmmanuel Viennet authored
main.js 1.46 KiB
const data = [
{
name: "Regina",
base: "tomate",
price_small: 6.5,
price_large: 9.95,
image:
"https://images.unsplash.com/photo-1532246420286-127bcd803104?fit=crop&w=500&h=300",
},
{
name: "Napolitaine",
base: "tomate",
price_small: 6.5,
price_large: 8.95,
image:
"https://images.unsplash.com/photo-1562707666-0ef112b353e0?&fit=crop&w=500&h=300",
},
{
name: "Spicy",
base: "crème",
price_small: 5.5,
price_large: 8,
image:
"https://images.unsplash.com/photo-1458642849426-cfb724f15ef7?fit=crop&w=500&h=300",
},
];
const result = data.filter((datum) => datum.base === "tomate");
let html = "";
result.forEach((datum) => {
html += `<article class="pizzaThumbnail">
<a href="${datum.image}">
<img src="${datum.image}" />
<section>
<h4>${datum.name}</h4>
<ul>
<li> Prix petit format : ${datum.price_small} €</li>
<li> Prix grand format : ${datum.price_large} €</li>
</ul>
</section>
</a>
</article>`;
});
document.querySelector(".pageContent").innerHTML = html;
function alphabetSort(datum1, datum2) {
if (datum1.name < datum2.name) return -1;
else if (datum1.name > datum2.name) return 1;
return 0;
}
function croissantSort(a, b) {
return a.price_small - b.price_small;
}
function unCroissantSort(a, b) {
const substract = b.price_small - a.price_small;
return substract != 0 ? substract : croissantSort(a, b);
}