From bb21e2074b84ae5a8de2ddd774323e2be1e0059f Mon Sep 17 00:00:00 2001 From: ALGLAVE Ivan <ivan.alglave8@etu.univ-lorraine.fr> Date: Thu, 31 Dec 2020 13:43:51 +0100 Subject: [PATCH] RecipeList shows the score depending on a parameter in the url --- AdvancedSearch.php | 12 +++++++++++- Home.php | 6 +++++- RecipeList.php | 4 +++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/AdvancedSearch.php b/AdvancedSearch.php index 1e7df18..3a2fde3 100644 --- a/AdvancedSearch.php +++ b/AdvancedSearch.php @@ -172,7 +172,8 @@ else if(value == 'unwanted') unwanted.push(key); }); getRecipes(wanted, unwanted, maxUnsatisfied, allowMissing, allowUnwanted, function(e) { - notifyParent(e); + if(maxUnsatisfied > 0) notifyParentScore(e); + else notifyParent(e); }); } @@ -184,6 +185,15 @@ }; window.top.postMessage(data, [data.event, data.value]); } + + function notifyParentScore(e) // Send a message to the parent window, asking to display the recipe #e + { + var data = { + event: 'recipelistscore', + value: e + }; + window.top.postMessage(data, [data.event, data.value]); + } function appendIngredient(ing, status) { diff --git a/Home.php b/Home.php index d72643b..cd75344 100644 --- a/Home.php +++ b/Home.php @@ -61,7 +61,11 @@ } else if(m_event == 'recipelist') { - switchView('RecipeList.php?ids=' + m_value); + switchView('RecipeList.php?ids=' + m_value + '&showscore=false'); + } + else if(m_event == 'recipelistscore') + { + switchView('RecipeList.php?ids=' + m_value + '&showscore=true'); } else if(m_event == 'hierarchyDisplay') { diff --git a/RecipeList.php b/RecipeList.php index 0e7a5ec..308de0c 100644 --- a/RecipeList.php +++ b/RecipeList.php @@ -15,6 +15,8 @@ include "Donnees.inc.php"; include "scripts/Functions.php"; + + $showScore = $_GET['showscore'] == 'true' ? true : false; if ($_GET['ids'] == '') echo '<h1>No recipe found</h1>'; @@ -32,7 +34,7 @@ echo '<div class="extra">'; echo '<img class="toggleFavourite" src="images/favourite.png" >'; - echo '<p class="unsatisfied">Non satisfiés : ' . $re[1] . '</p>'; + if($showScore) echo '<p class="unsatisfied">Non satisfiés : ' . $re[1] . '</p>'; echo '</div>'; echo '<div class="listElement" onclick="showRecipe(' . intval($re[0]) . ');">'; -- GitLab