Commit bb21e207 authored by ALGLAVE Ivan's avatar ALGLAVE Ivan
Browse files

RecipeList shows the score depending on a parameter in the url

parent 7b7d1960
...@@ -172,7 +172,8 @@ ...@@ -172,7 +172,8 @@
else if(value == 'unwanted') unwanted.push(key); else if(value == 'unwanted') unwanted.push(key);
}); });
getRecipes(wanted, unwanted, maxUnsatisfied, allowMissing, allowUnwanted, function(e) { getRecipes(wanted, unwanted, maxUnsatisfied, allowMissing, allowUnwanted, function(e) {
notifyParent(e); if(maxUnsatisfied > 0) notifyParentScore(e);
else notifyParent(e);
}); });
} }
...@@ -184,6 +185,15 @@ ...@@ -184,6 +185,15 @@
}; };
window.top.postMessage(data, [data.event, data.value]); 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) function appendIngredient(ing, status)
{ {
......
...@@ -61,7 +61,11 @@ ...@@ -61,7 +61,11 @@
} }
else if(m_event == 'recipelist') 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') else if(m_event == 'hierarchyDisplay')
{ {
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
include "Donnees.inc.php"; include "Donnees.inc.php";
include "scripts/Functions.php"; include "scripts/Functions.php";
$showScore = $_GET['showscore'] == 'true' ? true : false;
if ($_GET['ids'] == '') echo '<h1>No recipe found</h1>'; if ($_GET['ids'] == '') echo '<h1>No recipe found</h1>';
...@@ -32,7 +34,7 @@ ...@@ -32,7 +34,7 @@
echo '<div class="extra">'; echo '<div class="extra">';
echo '<img class="toggleFavourite" src="images/favourite.png" >'; 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>';
echo '<div class="listElement" onclick="showRecipe(' . intval($re[0]) . ');">'; echo '<div class="listElement" onclick="showRecipe(' . intval($re[0]) . ');">';
......
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