Skip to content
Snippets Groups Projects
Commit 5daab0bb authored by Simon Prevost's avatar Simon Prevost
Browse files

tp1_tri_g.2

parent 8cd29c1a
No related branches found
No related tags found
No related merge requests found
{
"presets": ["@babel/env"]
}
\ No newline at end of file
"use strict";
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'
}];
var html = '';
/*
//tri par nom
data.sort(function (a, b) {
return a.name.localeCompare(b.name);
});
*/
/*
//tri par petit prix
data.sort(function (a, b) {
return a.price_small - b.price_small;
});
//tri par petit prix, puis grand prix
data.sort(function(a,b){
if((a.price_small - b.price_small) == 0)
return a.price_large - b.price_large;
else
return a.price_small - b.price_small;
});
//affichage des pizza dont la base est tomate
data = data.filter(word => word.base == 'tomate');
*/
//affichage des pizza dont le prix petit format < 6
data = data.filter(function (prix) {
return prix.price_small < 6;
});
data.forEach(function (value) {
var url = value.image;
html = html + '<article class="pizzaThumbnail"> <a href="' + url + '"> <img src="' + url + '"/> <section> <h4>' + value.name + '</h4><ul><li>Prix petit format : ' + value.price_small + '€</li><li>Prix grand format : ' + value.price_large + '€</li></ul></section> </a> </article>\n\n';
});
document.querySelector('.pageContent').innerHTML = html;
console.log(html);
//# sourceMappingURL=main.js.map
\ No newline at end of file
{"version":3,"sources":["../src/main.js"],"names":["data","name","base","price_small","price_large","image","html","filter","prix","forEach","value","url","document","querySelector","innerHTML","console","log"],"mappings":";;AAAA,IAAIA,IAAI,GAAG,CACV;AACCC,EAAAA,IAAI,EAAE,QADP;AAECC,EAAAA,IAAI,EAAE,QAFP;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n\t\tprice_small: 6.5,\n\t\tprice_large: 9.95,\n\t\timage: 'https://images.unsplash.com/photo-1532246420286-127bcd803104?fit=crop&w=500&h=300'\n\t},\n\t{\n\t\tname: 'Napolitaine',\n\t\tbase: 'tomate',\n\t\tprice_small: 6.5,\n\t\tprice_large: 8.95,\n\t\timage: 'https://images.unsplash.com/photo-1562707666-0ef112b353e0?&fit=crop&w=500&h=300'\n\t},\n\t{\n\t\tname: 'Spicy',\n\t\tbase: 'crème',\n\t\tprice_small: 5.5,\n\t\tprice_large: 8,\n\t\timage: 'https://images.unsplash.com/photo-1458642849426-cfb724f15ef7?fit=crop&w=500&h=300',\n\t}\n];\n\nlet html = '';\n/*\n//tri par nom\ndata.sort(function (a, b) {\n return a.name.localeCompare(b.name);\n});\n*/\n\n/*\n//tri par petit prix\ndata.sort(function (a, b) {\n return a.price_small - b.price_small;\n});\n\n\n//tri par petit prix, puis grand prix\ndata.sort(function(a,b){\n if((a.price_small - b.price_small) == 0)\n return a.price_large - b.price_large;\n else \n return a.price_small - b.price_small;\n});\n\n//affichage des pizza dont la base est tomate\ndata = data.filter(word => word.base == 'tomate');\n*/\n//affichage des pizza dont le prix petit format < 6\ndata = data.filter(prix => prix.price_small < 6)\n\ndata.forEach(function(value){\n let url = value.image;\n html = html + '<article class=\"pizzaThumbnail\"> <a href=\"'+url+'\"> <img src=\"'+url+'\"/> <section> <h4>'+ value.name +'</h4><ul><li>Prix petit format : ' + value.price_small + '€</li><li>Prix grand format : ' + value.price_large + '€</li></ul></section> </a> </article>\\n\\n';\n});\n\ndocument.querySelector('.pageContent').innerHTML = html;\nconsole.log(html);"],"file":"main.js"}
\ No newline at end of file
......@@ -13,6 +13,7 @@
<link rel="stylesheet" href="css/news.css">
<link rel="stylesheet" href="css/pizzaList.css">
<link rel="stylesheet" href="css/footer.css">
<script src="build/main.js" defer></script>
</head>
<body>
<header>
......
This diff is collapsed.
{
"name": "pizzaland",
"version": "1.0.0",
"description": "<img src=\"images/readme/header.jpg\">",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://gitlab.univ-lille.fr/simon.prevost2.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 🍕 !');
\ No newline at end of file
let 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',
}
];
let html = '';
/*
//tri par nom
data.sort(function (a, b) {
return a.name.localeCompare(b.name);
});
*/
/*
//tri par petit prix
data.sort(function (a, b) {
return a.price_small - b.price_small;
});
//tri par petit prix, puis grand prix
data.sort(function(a,b){
if((a.price_small - b.price_small) == 0)
return a.price_large - b.price_large;
else
return a.price_small - b.price_small;
});
//affichage des pizza dont la base est tomate
data = data.filter(word => word.base == 'tomate');
//affichage des pizza dont le prix petit format < 6
data = data.filter(prix => prix.price_small < 6)
*/
//affichage des pizza dont le nom contient deux fois la lettre "i"
data = data.filter(nom => nom.name.)
data.forEach(function(value){
let url = value.image;
html = html + '<article class="pizzaThumbnail"> <a href="'+url+'"> <img src="'+url+'"/> <section> <h4>'+ value.name +'</h4><ul><li>Prix petit format : ' + value.price_small + '€</li><li>Prix grand format : ' + value.price_large + '€</li></ul></section> </a> </article>\n\n';
});
document.querySelector('.pageContent').innerHTML = html;
console.log(html);
\ 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