Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ALGLAVE Ivan
Drinkpedia
Commits
859b5de6
Commit
859b5de6
authored
Dec 03, 2020
by
SCHNEIDER Remi
Browse files
Merge branch 'master' of
https://gitlab.univ-lorraine.fr/alglave2u/drinkpedia
parents
680e05b2
236e1a6a
Changes
5
Hide whitespace changes
Inline
Side-by-side
AdvancedSearch.php
View file @
859b5de6
...
...
@@ -4,10 +4,22 @@
<title>
Drinkpedia
</title>
<meta
charset=
"UTF-8"
>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"css/AdvancedSearch.css"
>
<script
type =
"text/javascript"
src=
"scripts/DataQuery.js"
></script>
</head>
<body>
<h1>
AdvancedSearch
</h1>
<script>
alert
(
'
Before query
'
);
getIngredients
(
function
(
e
)
{
alert
(
'
hihi
'
);
});
alert
(
'
Query sent
'
);
</script>
</body>
</html>
\ No newline at end of file
Hierarchy.php
View file @
859b5de6
...
...
@@ -36,7 +36,7 @@
if
(
$sup_cat
!=
null
)
{
echo
'<div class="category-view">'
;
echo
'<h1> Super-catégories de '
.
$aliment
.
' </h1>'
;
foreach
(
$sup_cat
as
$cat
)
{
if
(
$sup_cat
!=
null
)
foreach
(
$sup_cat
as
$cat
)
{
echo
'<li><button onclick="notifyParent('
.
"'"
.
$cat
.
"'"
.
');">'
.
$cat
.
'</button></li>'
;
}
echo
'</div>'
;
...
...
@@ -45,7 +45,7 @@
if
(
$sous_cat
!=
null
)
{
echo
'<div class="category-view">'
;
echo
'<h1> Sous-catégories de '
.
$aliment
.
' </h1>'
;
foreach
(
$sous_cat
as
$cat
)
{
if
(
$sous_cat
!=
null
)
foreach
(
$sous_cat
as
$cat
)
{
//echo '<li><button onclick="notifyParent('.$cat.');">'.$cat.'</button></li>';
echo
'<li><button onclick="notifyParent('
.
"'"
.
$cat
.
"'"
.
');">'
.
$cat
.
'</button></li>'
;
}
...
...
scripts/DataQuery.js
View file @
859b5de6
...
...
@@ -9,15 +9,18 @@ function query(func_name, args, callback)
function
getRecipes
(
wanted_ingredients
=
[],
unwanted_ingredients
=
[],
max_unsatisfied
=
0
,
allow_missing
=
true
,
allow_unwanted
=
true
,
callback
)
{
alert
(
'
hi
'
);
query
(
'
getRecipe
'
,
[
wanted_ingredients
,
unwanted_ingredients
,
max_unsatisfied
,
allow_missing
,
allow_unwanted
],
callback
);
}
function
getIngredients
(
parent_category
=
'
Aliment
'
,
callback
)
{
alert
(
'
hi
'
);
query
(
'
getIngredients
'
,
[
parent_category
],
callback
);
}
function
getRecipeImage
(
id
,
callback
)
{
alert
(
'
hi
'
);
query
(
'
getRecipeImage
'
,
[
id
],
callback
);
}
\ No newline at end of file
scripts/DataQuery.php
View file @
859b5de6
...
...
@@ -10,7 +10,7 @@
}
else
if
(
$funcName
==
'getRecipes'
)
{
echo
getRecipes
(
$_POST
[
'arguments'
][
0
],
$_POST
[
'arguments'
][
1
],
$_POST
[
'arguments'
][
2
],
$_POST
[
'arguments'
][
3
],
$_POST
[
'arguments'
][
4
]);
echo
getRecipes
ForJS
(
$_POST
[
'arguments'
][
0
],
$_POST
[
'arguments'
][
1
],
$_POST
[
'arguments'
][
2
],
$_POST
[
'arguments'
][
3
],
$_POST
[
'arguments'
][
4
]);
}
else
if
(
$funcName
==
'getIngredients'
)
{
...
...
scripts/Functions.php
View file @
859b5de6
...
...
@@ -6,11 +6,22 @@ function recipeContains($recipe, $ingredient)
return
false
;
}
function
getRecipesForJS
(
$wanted_ingredients
,
$unwanted_ingredients
,
$max_unsatisfied
,
$allow_missing
,
$allow_unwanted
)
{
$res
=
""
;
$validRecipes
=
getRecipes
(
$wanted_ingredients
,
$unwanted_ingredients
,
$max_unsatisfied
,
$allow_missing
,
$allow_unwanted
);
foreach
(
$validRecipes
as
$recipe
)
{
$res
.
=
$recipe
[
'id'
]
.
':'
.
$recipe
[
'score'
]
.
'|'
;
}
return
$res
;
}
function
getRecipes
(
$wanted_ingredients
,
$unwanted_ingredients
,
$max_unsatisfied
,
$allow_missing
,
$allow_unwanted
)
{
include
"../Donnees.inc.php"
;
$Recipes
=
''
;
$Recipes
=
array
()
;
for
(
$i
=
0
;
$i
<
count
(
$Recettes
);
$i
++
)
{
$recipe
=
$Recettes
[
$i
];
...
...
@@ -48,7 +59,11 @@ function getRecipes($wanted_ingredients, $unwanted_ingredients, $max_unsatisfied
{
if
(
$score
<=
$max_unsatisfied
)
{
$Recipes
.
=
$i
.
':'
.
$score
.
'|'
;
//$Recipes .= $i . ':' . $score . '|';
$Recipes
[]
=
array
(
'id'
=>
$i
,
'score'
=>
$score
);
}
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment