Maintenance Gitlab - Jeudi 09 Décembre 2021 à partir de 10h - Mises à jour de sécurité

Commit 06654b0e authored by ALGLAVE Ivan's avatar ALGLAVE Ivan
Browse files

Cocktails.php displays a clickable list of all the cocktails

parent 92fb4095
...@@ -11,16 +11,30 @@ ...@@ -11,16 +11,30 @@
<ul> <ul>
<?php <?php
include "scripts/Functions.php"; include "Donnees.inc.php";
$ar = getRecipes(['Malibu'], [], 10, true, true); $ar = $Recettes;
foreach($ar as $r) for($i = 0; $i < count($ar); $i++)
{ {
echo '<li>' . $r['recipe']['titre'] . ' (unsatisfied ingredients = ' . $r['score'] . ')' . '</li>'; echo '<li onclick="notifyParent(' . $i . ');">' . $ar[$i]['titre'] . '</li>';
} }
?> ?>
</ul> </ul>
<script>
function notifyParent(e) // Send a message to the parent window, asking to display the recipe #e
{
var data = {
event: 'recipeselect',
value: Number(e)
};
window.top.postMessage(data, [data.event, data.value]);
}
</script>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -10,34 +10,17 @@ ...@@ -10,34 +10,17 @@
<body id="body"> <body id="body">
<ul id="origin_list"></ul> <!-- HTML -->
<!-- JAVASCRIPT --> <!-- JAVASCRIPT -->
<script>
let n_list_origin = document.getElementById('origin_list'); <script>
//let ingredients = getIngredients();
function detailIngredients()
{
let d = document.getElementsByClassName('detailed');
let ud = document.getElementsByClassName('undetailed');
for(let el in ud)
{
while (el.firstChild) {
el.removeChild(el.firstChild);
}
}
for(let el in d)
{
let c = getIngredients(el.value, function (data, status)
{
});
}
}
function notifyParent(e) function notifyParent(e) // Send a message to the parent window, asking to display the recipe #e
{ {
var data = { var data = {
event: 'recipeselect', event: 'recipeselect',
......
...@@ -60,12 +60,12 @@ ...@@ -60,12 +60,12 @@
wraper.disabled = false; wraper.disabled = false;
} }
function showRecipe(id) function showRecipe(id) // Show the Recipe with the id 'id' in the file 'Donnees.inc.php'
{ {
embed.setAttribute('src','RecipeView.php?id_recipe=' + id); embed.setAttribute('src','RecipeView.php?id_recipe=' + id);
wrapper.classList.add('active'); wrapper.classList.add('active'); // Set the RecipeView wrapper active
content.classList.add('blur'); content.classList.add('blur'); // Blurs the original content of the page
wrapper.disabled = true; wrapper.disabled = true;
embed.focus(); embed.focus();
......
...@@ -59,13 +59,16 @@ function getRecipes($wanted_ingredients, $unwanted_ingredients, $max_unsatisfied ...@@ -59,13 +59,16 @@ function getRecipes($wanted_ingredients, $unwanted_ingredients, $max_unsatisfied
function getIngredients($parent_category) function getIngredients($parent_category)
{ {
include "../Donnees.inc.php"; include "../Donnees.inc.php";
$res = ''; $res = '';
$ingredients = $Hierarchie[$parent_category]['sous-categorie'];
foreach($ingredients as $i) if(isset($Hierarchie[$parent_category]))
{ {
$res .= $i . '|'; $ingredients = $Hierarchie[$parent_category]['sous-categorie'];
foreach($ingredients as $i)
{
$res .= $i . '|';
}
} }
return $res; return $res;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment