Skip to content
Snippets Groups Projects
Commit a4cea8e1 authored by redtang01's avatar redtang01
Browse files

TP1

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'
}];
function compareName(a, b) {
if (a.name < b.name) return -1;
if (a.name > b.name) return 1;
return 0;
}
function comparePriceSmall(a, b) {
return a.price_small - b.price_small;
}
function comparePriceSmallAndLarge(a, b) {
if (a.price_small == b.price_small) return a.price_large - b.price_large;
return a.price_small - b.price_small;
}
function filtedBase(_ref) {
var base = _ref.base;
return base == 'tomate';
}
function filtedPriceSmall(_ref2) {
var price_small = _ref2.price_small;
return price_small < 6;
}
function filtedTwoI(_ref3) {
var name = _ref3.name;
return name.split('i').length - 1 == 2;
}
var sortedByName = data.sort(compareName);
var sortedByLittlePrice = data.sort(comparePriceSmall);
var sortedByLittlePriceAndBigPrice = data.sort(comparePriceSmallAndLarge);
var filtedByBase = data.filter(filtedBase);
var filtedByLittlePriceLessThanSix = data.filter(filtedPriceSmall);
var filtedByTwoI = data.filter(filtedTwoI);
function constructHtml(_ref4) {
var name = _ref4.name,
price_small = _ref4.price_small,
price_large = _ref4.price_large,
image = _ref4.image;
return "<article class=\"pizzaThumbnail\">\n\t\t\t<a href=\"".concat(image, "\">\n <img src=\"").concat(image, "\"/>\n <section>\n <h4>").concat(name, "</h4>\n <ul>\n <li>Prix petit format : ").concat(price_small, " \u20AC</li>\n <li>Prix grand format : ").concat(price_large, " \u20AC</li>\n </ul>\n </section>\n\t\t\t</a>\n\t\t\t</article>");
}
sortedByName.forEach(function (e) {
document.querySelector('.pageContent').innerHTML += constructHtml(e);
});
//# 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","compareName","a","b","comparePriceSmall","comparePriceSmallAndLarge","filtedBase","filtedPriceSmall","filtedTwoI","split","length","sortedByName","sort","sortedByLittlePrice","sortedByLittlePriceAndBigPrice","filtedByBase","filter","filtedByLittlePriceLessThanSix","filtedByTwoI","constructHtml","forEach","e","document","querySelector","innerHTML"],"mappings":";;AAAA,IAAMA,IAAI,GAAG,CACZ;AACCC,EAAAA,IAAI,EAAE,QADP;AAECC,EAAAA,IAAI,EAAE,QAFP;AAGCC,EAAAA,WAAW,EAAE,GAHd;AAICC,EAAAA,WAAW,EAAE,IAJd;AAKCC,EAAAA,KAAK,EAAE;AALR,CADY,EAQZ;AACCJ,EAAAA,IAAI,EAAE,aADP;AAECC,EAAAA,IAAI,EAAE,QAFP;AAGCC,EAAAA,WAAW,EAAE,GAHd;AAICC,EAAAA,WAAW,EAAE,IAJd;AAKCC,EAAAA,KAAK,EAAE;AALR,CARY,EAeZ;AACCJ,EAAAA,IAAI,EAAE,OADP;AAECC,EAAAA,IAAI,EAAE,OAFP;AAGCC,EAAAA,WAAW,EAAE,GAHd;AAICC,EAAAA,WAAW,EAAE,CAJd;AAKCC,EAAAA,KAAK,EAAE;AALR,CAfY,CAAb;;AAyBA,SAASC,WAAT,CAAqBC,CAArB,EAAwBC,CAAxB,EAA2B;AACvB,MAAID,CAAC,CAACN,IAAF,GAASO,CAAC,CAACP,IAAf,EAAqB,OAAO,CAAC,CAAR;AACrB,MAAIM,CAAC,CAACN,IAAF,GAASO,CAAC,CAACP,IAAf,EAAqB,OAAO,CAAP;AACrB,SAAO,CAAP;AACH;;AAED,SAASQ,iBAAT,CAA2BF,CAA3B,EAA8BC,CAA9B,EAAiC;AAC7B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EACaA,KADb,6CAE2BA,KAF3B,sEAIyBJ,IAJzB,8FAMiDE,WANjD,2EAOiDC,WAPjD;AAYA;;AAEDY,YAAY,CAACS,OAAb,CAAqB,UAAAC,CAAC,EAAE;AACpBC,EAAAA,QAAQ,CAACC,aAAT,CAAuB,cAAvB,EAAuCC,SAAvC,IAAoDL,aAAa,CAACE,CAAD,CAAjE;AACH,CAFD","sourcesContent":["const data = [\n\t{\n\t\tname: 'Regina',\n\t\tbase: 'tomate',\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\n\nfunction compareName(a, b) {\n if (a.name < b.name) return -1;\n if (a.name > b.name) return 1;\n return 0;\n}\n\nfunction comparePriceSmall(a, b) {\n return a.price_small - b.price_small;\n}\n\nfunction comparePriceSmallAndLarge(a, b) {\n if (a.price_small == b.price_small) return a.price_large - b.price_large;\n return a.price_small - b.price_small;\n}\n\nfunction filtedBase({base}) {\n return base == 'tomate';\n}\n\nfunction filtedPriceSmall({price_small}) {\n return price_small < 6;\n}\n\nfunction filtedTwoI({name}) {\n return name.split('i').length - 1 == 2;\n}\n\nconst sortedByName = data.sort(compareName);\nconst sortedByLittlePrice = data.sort(comparePriceSmall);\nconst sortedByLittlePriceAndBigPrice = data.sort(comparePriceSmallAndLarge);\n\nconst filtedByBase = data.filter(filtedBase);\nconst filtedByLittlePriceLessThanSix = data.filter(filtedPriceSmall);\nconst filtedByTwoI = data.filter(filtedTwoI);\n\nfunction constructHtml({name, price_small, price_large, image}) {\n\treturn `<article class=\"pizzaThumbnail\">\n\t\t\t<a href=\"${image}\">\n <img src=\"${image}\"/>\n <section>\n <h4>${name}</h4>\n <ul>\n <li>Prix petit format : ${price_small} €</li>\n <li>Prix grand format : ${price_large} €</li>\n </ul>\n </section>\n\t\t\t</a>\n\t\t\t</article>`;\n}\n\nsortedByName.forEach(e=>{\n document.querySelector('.pageContent').innerHTML += constructHtml(e);\n});\n"],"file":"main.js"}
\ No newline at end of file
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
<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="src/main.js" defer></script>
</head> </head>
<body> <body>
<header> <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"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/cli": "^7.12.10",
"@babel/core": "^7.12.10",
"@babel/preset-env": "^7.12.11"
},
"dependencies": {},
"repository": {
"type": "git",
"url": "https://gitlab.univ-lille.fr/tanguy.bonnet.etu/tp1.git"
}
}
console.log('Welcome to PizzaLand 🍕 !'); const data = [
\ No newline at end of file {
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',
}
];
function compareName(a, b) {
if (a.name < b.name) return -1;
if (a.name > b.name) return 1;
return 0;
}
function comparePriceSmall(a, b) {
return a.price_small - b.price_small;
}
function comparePriceSmallAndLarge(a, b) {
if (a.price_small == b.price_small) return a.price_large - b.price_large;
return a.price_small - b.price_small;
}
function filtedBase({base}) {
return base == 'tomate';
}
function filtedPriceSmall({price_small}) {
return price_small < 6;
}
function filtedTwoI({name}) {
return name.split('i').length - 1 == 2;
}
const sortedByName = data.sort(compareName);
const sortedByLittlePrice = data.sort(comparePriceSmall);
const sortedByLittlePriceAndBigPrice = data.sort(comparePriceSmallAndLarge);
const filtedByBase = data.filter(filtedBase);
const filtedByLittlePriceLessThanSix = data.filter(filtedPriceSmall);
const filtedByTwoI = data.filter(filtedTwoI);
function constructHtml({name, price_small, price_large, image}) {
return `<article class="pizzaThumbnail">
<a href="${image}">
<img src="${image}"/>
<section>
<h4>${name}</h4>
<ul>
<li>Prix petit format : ${price_small} €</li>
<li>Prix grand format : ${price_large} €</li>
</ul>
</section>
</a>
</article>`;
}
sortedByName.forEach(e=>{
document.querySelector('.pageContent').innerHTML += constructHtml(e);
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment