Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Drinkpedia
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ALGLAVE Ivan
Drinkpedia
Commits
b80a8855
Commit
b80a8855
authored
4 years ago
by
SCHNEIDER Remi
Browse files
Options
Downloads
Patches
Plain Diff
Co-authored-by: Ivan Alglave <alglaveivan@outlook.com>
parent
81751df1
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Hierarchy.php
+65
-6
65 additions, 6 deletions
Hierarchy.php
css/Hierarchy.css
+8
-0
8 additions, 0 deletions
css/Hierarchy.css
with
73 additions
and
6 deletions
Hierarchy.php
+
65
−
6
View file @
b80a8855
...
...
@@ -10,21 +10,80 @@
<body
id=
"body"
>
<!--
HTML
-->
<!--
PHP
-->
<?php
// Renvoie un tableau de sous-categories de l'aliment en cours, null si l'aliment n'en a pas
function
get_sous_categories
(
$aliment
)
{
include
"Donnees.inc.php"
;
$res
=
null
;
if
(
isset
(
$Hierarchie
[
$aliment
][
'sous-categorie'
]))
{
$res
=
$Hierarchie
[
$aliment
][
'sous-categorie'
];
}
return
$res
;
}
<!-- JAVASCRIPT -->
// Renvoie un tableau de super-categories de l'aliment en cours, null si l'aliment n'en a pas
function
get_super_categories
(
$aliment
)
{
include
"Donnees.inc.php"
;
$res
=
null
;
if
(
isset
(
$Hierarchie
[
$aliment
][
'super-categorie'
]))
{
$res
=
$Hierarchie
[
$aliment
][
'super-categorie'
];
}
return
$res
;
}
<script>
// Renvoie la liste des recettes qui contiennent un aliment spécifique :
function
get_recettes_associees
(
$aliment
)
{
return
null
;
// A FAIRE
}
if
(
!
isset
(
$_GET
[
'element'
]))
{
// Si on ouvre la Hiérachie pour la première fois, on part de 'Aliment'
$aliment
=
'Vin effervescent'
;
}
else
{
// Sinon on récupère l'aliment en cours
$aliment
=
$_GET
[
'element'
];
}
$sup_cat
=
get_super_categories
(
$aliment
);
$sous_cat
=
get_sous_categories
(
$aliment
);
// Crée la disposition de la hiérarchie
echo
'<div class="hierarchy_view">'
;
// On affiche les Super-Catégories, s'il y'en a :
if
(
$sup_cat
!=
null
)
{
echo
'<div class="category-view">'
;
echo
'<h1> Super-catégories de '
.
$aliment
.
' </h1>'
;
foreach
(
$sup_cat
as
$cat
)
{
echo
'<li><button onclick="notifyParent('
.
$cat
.
');">'
.
$cat
.
'</button></li>'
;
}
echo
'</div>'
;
}
// On affiche les sous-catégories, s'il y'en a :
if
(
$sous_cat
!=
null
)
{
echo
'<div class="category-view">'
;
echo
'<h1> Sous-catégories de '
.
$aliment
.
' </h1>'
;
foreach
(
$sous_cat
as
$cat
)
{
//echo '<li><button onclick="notifyParent('.$cat.');">'.$cat.'</button></li>';
echo
'<li><button onclick="alert('
.
$cat
.
');">'
.
$cat
.
'</button></li>'
;
}
echo
'</div>'
;
}
echo
'</div>'
;
?>
<!-- JAVASCRIPT -->
function
notifyParent
(
e
)
// Send a message to the parent window, asking to display the recipe #e
<script>
function
notifyParent
(
$aliment
)
// Send a message to the parent window, asking to change to page $aliment
{
var
data
=
{
event
:
'
recipeselect
'
,
value
:
Number
(
e
)
event
:
'
hierarchyDisplay
'
,
value
:
$aliment
};
window
.
top
.
postMessage
(
data
,
[
data
.
event
,
data
.
value
]);
}
...
...
This diff is collapsed.
Click to expand it.
css/Hierarchy.css
+
8
−
0
View file @
b80a8855
...
...
@@ -7,4 +7,12 @@
body
{
background
:
lightblue
;
width
:
100vw
;
}
.hierarchy-view
{
display
:
block
;
}
.category-view
{
display
:
block
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment