From 4e7b785183b3600169e7173bfaeb3439ef8d0d44 Mon Sep 17 00:00:00 2001 From: ALGLAVE Ivan <ivan.alglave8@etu.univ-lorraine.fr> Date: Fri, 1 Jan 2021 18:26:28 +0100 Subject: [PATCH] Message posting event sent to parent window instead of top window, various fixes --- AccountConnection.php | 27 +++++++++++---------- AccountCreation.php | 27 +++++++++++---------- AdvancedSearch.php | 4 ++-- Hierarchy.php | 2 +- Home.php | 8 +++---- MyAccount.php | 18 ++++++++------ MyFavouriteRecipes.php | 4 ++-- RecipeList.php | 6 ++--- RecipeView.php | 4 ++-- Recipes.php | 5 ++-- css/Account.css | 54 ++++++++++++++++++++++++++++++++++++++++++ css/AdvancedSearch.css | 1 + css/MyAccount.css | 0 css/RecipeList.css | 2 +- css/RecipeView.css | 1 + css/Recipes.css | 5 ---- scripts/SQL.php | 12 ++++++---- 17 files changed, 122 insertions(+), 58 deletions(-) create mode 100644 css/Account.css delete mode 100644 css/MyAccount.css delete mode 100644 css/Recipes.css diff --git a/AccountConnection.php b/AccountConnection.php index 050f751..6cf1280 100644 --- a/AccountConnection.php +++ b/AccountConnection.php @@ -3,22 +3,25 @@ <head> <title>Drinkpedia</title> <meta charset="UTF-8"> - <link rel="stylesheet" type="text/css" href="css/MyAccount.css"> + <link rel="stylesheet" type="text/css" href="css/Account.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> + <script src="scripts/DataQuery.js"></script> </head> <body> - <h1>Connexion</h1> + <div class="content"> + <h1>Connexion</h1> + <label>Email</label> + <input id="emailInput" type="email"> + <label>Mot de passe</label> + <input id="pwdInput" type="password"> + <button onclick="tryConnect();">Se connecter</button> - <label>Email</label> - <input id="emailInput" type="email"> - <label>Mot de passe</label> - <input id="pwdInput" type="password"> - <button onclick="tryConnect();">Se connecter</button> - <label>Pas de compte ?</label> - <a onclick="goToCreate();">Créer</a> + <div class="alt"> + <a onclick="goToCreate();">Pas de compte ? Créer</a> + </div> + </div> - <script src="scripts/DataQuery.js"></script> <script> function goToCreate() { @@ -26,7 +29,7 @@ event: 'usercreate', value: '' }; - window.top.postMessage(data, [data.event, data.value]); + window.parent.postMessage(data, [data.event, data.value]); } function tryConnect() @@ -42,7 +45,7 @@ event: 'useraccount', value: e }; - window.top.postMessage(data, [data.event, data.value]); + window.parent.postMessage(data, [data.event, data.value]); } else { diff --git a/AccountCreation.php b/AccountCreation.php index cbbfd05..f4219a3 100644 --- a/AccountCreation.php +++ b/AccountCreation.php @@ -3,22 +3,25 @@ <head> <title>Drinkpedia</title> <meta charset="UTF-8"> - <link rel="stylesheet" type="text/css" href="css/MyAccount.css"> + <link rel="stylesheet" type="text/css" href="css/Account.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> + <script src="scripts/DataQuery.js"></script> </head> <body> - <h1>Création d'un compte</h1> + <div class="content"> + <h1>Création d'un compte</h1> + <label>Email</label> + <input id="emailInput" type="email"> + <label>Mot de passe</label> + <input id="pwdInput" type="password"> + <button onclick="createAccount();">Créer mon compte</button> - <label>Email</label> - <input id="emailInput" type="email"> - <label>Mot de passe</label> - <input id="pwdInput" type="password"> - <button onclick="createAccount();">Créer mon compte</button> - <label>Déjà un compte ?</label> - <a onclick="goToConnect();">Se connecter</a> + <div class="alt"> + <a onclick="goToConnect();">Déjà un compte ? Se connecter</a> + </div> + </div> - <script src="scripts/DataQuery.js"></script> <script> function goToConnect() { @@ -26,7 +29,7 @@ event: 'userconnect', value: '' }; - window.top.postMessage(data, [data.event, data.value]); + window.parent.postMessage(data, [data.event, data.value]); } function createAccount() @@ -50,7 +53,7 @@ event: 'useraccount', value: e }; - window.top.postMessage(data, [data.event, data.value]); + window.parent.postMessage(data, [data.event, data.value]); } }) } diff --git a/AdvancedSearch.php b/AdvancedSearch.php index 0da62a5..3701f69 100644 --- a/AdvancedSearch.php +++ b/AdvancedSearch.php @@ -185,7 +185,7 @@ showScore: 'false', title: 'Résultats de la recherche :' }; - window.top.postMessage(data, [data.event, data.value, data.showScore, data.title]); + window.parent.postMessage(data, [data.event, data.value, data.showScore, data.title]); } function notifyParentScore(e) // Send a message to the parent window, asking to display the recipe #e @@ -196,7 +196,7 @@ showScore: 'false', title: 'Résultats de la recherche :' }; - window.top.postMessage(data, [data.event, data.value, data.showScore, data.title]); + window.parent.postMessage(data, [data.event, data.value, data.showScore, data.title]); } function appendIngredient(ing, status) diff --git a/Hierarchy.php b/Hierarchy.php index b664e0e..57c4b25 100644 --- a/Hierarchy.php +++ b/Hierarchy.php @@ -70,7 +70,7 @@ event: 'hierarchyDisplay', value: $aliment }; - window.top.postMessage(data, [data.event, data.value]); + window.parent.postMessage(data, [data.event, data.value]); } </script> diff --git a/Home.php b/Home.php index 275d836..c5abbe5 100644 --- a/Home.php +++ b/Home.php @@ -6,14 +6,14 @@ <link rel="stylesheet" type="text/css" href="css/Home.css"> </head> -<body id="body"> - - <?php +<?php include 'scripts/SQL.php'; //connect_db(); - ?> +<body id="body"> + + <div class="background"></div> <div id="content"> diff --git a/MyAccount.php b/MyAccount.php index 4427072..5139b19 100644 --- a/MyAccount.php +++ b/MyAccount.php @@ -3,7 +3,7 @@ <head> <title>Drinkpedia</title> <meta charset="UTF-8"> - <link rel="stylesheet" type="text/css" href="css/MyAccount.css"> + <link rel="stylesheet" type="text/css" href="css/Account.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> <script src="scripts/DataQuery.js"></script> </head> @@ -18,16 +18,20 @@ event: 'userconnect', value: e }; - window.top.postMessage(data, [data.event, data.value]); + window.parent.postMessage(data, [data.event, data.value]); } }); </script> - <h1>My Account</h1> + <div class="content"> + <h1>Mon compte</h1> - <label id="email"></label> - - <button onclick="disconnect();">Se déconnecter</button> + <label id="email"></label> + <div class="alt"> + <a onclick="alert('To be implemented');">Changer mon mot de passe</a> + </div> + <button onclick="disconnect();">Se déconnecter</button> + </div> <script> @@ -44,7 +48,7 @@ event: 'userconnect', value: '' }; - window.top.postMessage(data, [data.event, data.value]); + window.parent.postMessage(data, [data.event, data.value]); }); } </script> diff --git a/MyFavouriteRecipes.php b/MyFavouriteRecipes.php index e5a007d..6dfffc5 100644 --- a/MyFavouriteRecipes.php +++ b/MyFavouriteRecipes.php @@ -4,10 +4,10 @@ <title>Drinkpedia</title> <meta charset="UTF-8"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> + <script src="scripts/DataQuery.js"></script> </head> <body> - <script src="scripts/DataQuery.js"></script> <script> getFavourites(function(e) @@ -18,7 +18,7 @@ showScore: 'false', title: 'Favoris :' }; - window.top.postMessage(data, [data.event, data.value, data.showScore, data.title]); + window.parent.postMessage(data, [data.event, data.value, data.showScore, data.title]); }) </script> </body> diff --git a/RecipeList.php b/RecipeList.php index 8a14530..ea01bf6 100644 --- a/RecipeList.php +++ b/RecipeList.php @@ -5,6 +5,7 @@ <meta charset="UTF-8"> <link rel="stylesheet" type="text/css" href="css/RecipeList.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> + <script src="scripts/DataQuery.js"></script> </head> <body> @@ -58,7 +59,6 @@ </ul> - <script src="scripts/DataQuery.js"></script> <script> document.addEventListener('keyup', function (e) { @@ -68,7 +68,7 @@ event: 'keyup', value: e.keyCode }; - window.top.postMessage(data, [data.event, data.value]); + window.parent.postMessage(data, [data.event, data.value]); } }); @@ -78,7 +78,7 @@ event: 'recipeselect', value: id }; - window.top.postMessage(data, [data.event, data.value]); + window.parent.postMessage(data, [data.event, data.value]); } function switchFavourite(img) diff --git a/RecipeView.php b/RecipeView.php index 517e7ec..5c07d1f 100644 --- a/RecipeView.php +++ b/RecipeView.php @@ -2,6 +2,7 @@ <head> <link rel="stylesheet" type="text/css" href="css/RecipeView.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> + <script src="scripts/DataQuery.js"></script> </head> <body> @@ -47,7 +48,6 @@ </div> - <script src="scripts/DataQuery.js"></script> <script> document.addEventListener('keyup', function (e) @@ -58,7 +58,7 @@ event: 'keyup', value: e.keyCode }; - window.top.postMessage(data, [data.event, data.value]); + window.parent.postMessage(data, [data.event, data.value]); } }); diff --git a/Recipes.php b/Recipes.php index 48c726f..41183a0 100644 --- a/Recipes.php +++ b/Recipes.php @@ -3,12 +3,11 @@ <head> <title>Drinkpedia</title> <meta charset="UTF-8"> - <link rel="stylesheet" type="text/css" href="css/Recipes.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> + <script src="scripts/DataQuery.js"></script> </head> <body> - <script src="scripts/DataQuery.js"></script> <script> getRecipes([], [], 0, true, true, function(e) { var data = { @@ -17,7 +16,7 @@ showScore: 'false', title: 'Tous les cocktails :' }; - window.top.postMessage(data, [data.event, data.value, data.showScore, data.title]); + window.parent.postMessage(data, [data.event, data.value, data.showScore, data.title]); }); </script> diff --git a/css/Account.css b/css/Account.css new file mode 100644 index 0000000..4244398 --- /dev/null +++ b/css/Account.css @@ -0,0 +1,54 @@ +body { + display: flex; + justify-content: center; +} + +.content { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + margin: 25px; + background-color: rgba(255, 255, 255, 0.75); + padding: 25px; + width: 50vw; + border-radius: 25px; +} + +input { + margin-top: 5px; + width: 30%; + font-size: 20px; + font-weight: bold; + padding: 2px; +} + +label { + margin-top: 10px; + font-size: 24px; +} + +button { + font-size: x-large; + font-weight: bold; + border-radius: 10px; + background-color: darkgray; + margin: 10px; + cursor: pointer; +} + +button:hover { + background-color: grey; +} + +.alt { + margin: 25px; + display: inline; +} + +a { + color: blue; + font-weight: bold; + text-decoration: underline; + cursor: pointer; +} \ No newline at end of file diff --git a/css/AdvancedSearch.css b/css/AdvancedSearch.css index 8fcb98f..fd83ef5 100644 --- a/css/AdvancedSearch.css +++ b/css/AdvancedSearch.css @@ -50,6 +50,7 @@ body { background-color: darkgray; margin: 25px; padding: 15px; + cursor: pointer; } #searchDiv button:hover { diff --git a/css/MyAccount.css b/css/MyAccount.css deleted file mode 100644 index e69de29..0000000 diff --git a/css/RecipeList.css b/css/RecipeList.css index ae39cef..126c184 100644 --- a/css/RecipeList.css +++ b/css/RecipeList.css @@ -11,7 +11,7 @@ ul { ul li { padding: 8px 16px; - height: 75px; + height: min-content; border-bottom: 1px solid black; background-color: rgba(88, 88, 88, 0.5); display: block; diff --git a/css/RecipeView.css b/css/RecipeView.css index 1779cf4..0d22b73 100644 --- a/css/RecipeView.css +++ b/css/RecipeView.css @@ -15,4 +15,5 @@ img { right: 0px; width: 32px; height: 32px; + cursor: pointer; } \ No newline at end of file diff --git a/css/Recipes.css b/css/Recipes.css deleted file mode 100644 index 43e7007..0000000 --- a/css/Recipes.css +++ /dev/null @@ -1,5 +0,0 @@ -li:hover { - cursor: pointer; - color: blue; - font-size: x-large; -} \ No newline at end of file diff --git a/scripts/SQL.php b/scripts/SQL.php index 4b5453b..010c2b5 100644 --- a/scripts/SQL.php +++ b/scripts/SQL.php @@ -1,9 +1,13 @@ <?php - -session_start(); -$bdd = new PDO('mysql:host=localhost;dbname=drinkpedia;charset=utf8', 'root', '', array( +error_reporting(E_ERROR | E_PARSE); +if(session_status() == PHP_SESSION_NONE) session_start(); +/*$bdd = new PDO('mysql:host=localhost;dbname=drinkpedia;charset=utf8', 'root', '', array( + PDO::ATTR_PERSISTENT => true +));*/ +$bdd = new PDO('mysql:host=localhost;dbname=id15804762_drinkpedia;charset=utf8', 'id15804762_access', 'DAccessPwd!1', array( PDO::ATTR_PERSISTENT => true )); + $bdd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); function connect_db() @@ -16,7 +20,7 @@ function create_user($u_email, $u_pwd) global $bdd; $res = $bdd->query('SELECT email FROM user WHERE email LIKE \'' . $u_email . '\''); if($res->fetch()) return '0'; - $bdd->query('INSERT INTO user (email, pwdhash, favourites) VALUES (\'' . $u_email . '\', \'' . $u_pwd . '\', \'1|2|4\')'); + $bdd->query('INSERT INTO user (email, pwdhash, favourites) VALUES (\'' . $u_email . '\', \'' . $u_pwd . '\', \'\')'); return '1'; } -- GitLab