Skip to content
Snippets Groups Projects
Commit a56b5a4f authored by Aurelien Carray's avatar Aurelien Carray
Browse files

tp1

parent 096c4ded
Branches
No related tags found
No related merge requests found
{
"presets": ["@babel/env"]
}
"use strict";
var cssClass = '<article class="pizzaThumbnail">';
var 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'
}];
data.sort(function (a, b) {
var price_small = a.price_small,
price_large = a.price_large;
if (price_small - b.price_small == 0) return price_large - b.price_large;
return price_small - b.price_small;
});
function tomatoBase(element) {
return element.base == 'tomate';
}
function cheapLilFormat(element) {
return element.price_small < 6.0;
}
var total = [''];
data.filter(tomatoBase).forEach(function (pizza) {
var name = pizza.name,
image = pizza.image,
price_small = pizza.price_small,
price_large = pizza.price_large;
var href = '<a href="' + image + '"><img src="' + image + '"/>';
var section = '<section><h4>' + name + '</h4>';
var list = '<ul><li>Prix petit format : ' + price_small + '€</li><li>Prix grand format : ' + price_large + '€</li></ul>';
var html = cssClass + href + section + list + '</section></a></article>';
total.push(html);
});
document.querySelector('.pageContainer').innerHTML = total;
\ No newline at end of file
...@@ -13,6 +13,9 @@ ...@@ -13,6 +13,9 @@
<link rel="stylesheet" href="css/news.css"> <link rel="stylesheet" href="css/news.css">
<link rel="stylesheet" href="css/pizzaList.css"> <link rel="stylesheet" href="css/pizzaList.css">
<link rel="stylesheet" href="css/footer.css"> <link rel="stylesheet" href="css/footer.css">
<script src="build/main.js" defer></script>
</head> </head>
<body> <body>
<header> <header>
......
This diff is collapsed.
{
"name": "pizzaland",
"version": "1.0.0",
"description": "Pizza",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://gitlab.univ-lille.fr/aurelien.carray.etu/tp1.git"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/cli": "^7.12.10",
"@babel/core": "^7.12.10",
"@babel/preset-env": "^7.12.11"
}
}
console.log('Welcome to PizzaLand 🍕 !'); const cssClass='<article class="pizzaThumbnail">';
\ No newline at end of file
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',
}
];
data.sort(function(a, b){
const {price_small, price_large} = a;
if (price_small - b.price_small == 0) return price_large - b.price_large;
return price_small - b.price_small;
});
function tomatoBase(element){
return element.base == 'tomate';
}
const total= [''];
data.filter(tomatoBase).forEach(function(pizza){
const {name,image,price_small,price_large}=pizza;
const href='<a href="'+image+'"><img src="'+image+'"/>';
const section='<section><h4>'+name+'</h4>';
const list='<ul><li>Prix petit format : '+price_small+'€</li><li>Prix grand format : '+price_large+'€</li></ul>';
const html=cssClass+href+section+list+'</section></a></article>';
total.push(html);
});
document.querySelector('.pageContainer').innerHTML = total;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment