Commit 19000f5d authored by Okthane's avatar Okthane

m

parent 5ee8f950
......@@ -55,11 +55,8 @@
<img name ="im-ID" id="img-ID" src="" height="150em"/>
</div>
<div id=conditions class="col-md-3 my-5 d-flex justify-content-center">
<ul>
<li id="li-oneface">Un seul visage<span></span></li>
<li id="li-format">Format correct<span></span></li>
<li id="li-dimensons">Format correct<span></span></li>
<li id="li-poids">Poids<span></span></li>
<ul class="list-group">
<li id="li-oneface" class="list-group-item list-group-item-secondary">Un seul visage<span></span></li>
</ul>
</div>
<div class="col-md-3 my-auto d-flex justify-content-center">
......@@ -77,7 +74,7 @@
<!-- <button onclick="defaultBtnActive()" class="btn-form" id="custom-fileUpload">Choisissez une photo</button> -->
</div>
<div class="div-btn-form">
<input id="btnSubmit" type="submit" name="submit" value="Vérifier" class="btn-form">
<input id="btnSubmit" type="submit" name="submit" value="Vérifier" class="btn btn-secondary" style="background-color:#00b8de;width: 50%">
</div>
</form>
<script>
......
......@@ -16,6 +16,8 @@ const canva = "canvas";
const idConsole = "span-status";var Console;
const idFileUpload = "fileUpload"; var inputFileUpload;
const idCustomFileUpload = "custom-fileUpload"; var btnCustomFileUpload;
const idBtnSubmit = "btnSubmit";var btnSubmit;
......@@ -30,6 +32,7 @@ var errorRemoveBackGround = true;
var unSeulVisage = false;
var format_correct = false;
const id_li_OneFace = "li-oneface"; var li_OneFace;
// SCRIPT ====================================================================================
......@@ -47,6 +50,7 @@ $(document).ready(function(){
btnSubmit = $("#"+idBtnSubmit);
btnCancel = $("#"+idCancel);
Console = $("#"+idConsole);
li_OneFace = $("#"+id_li_OneFace);
//Si l'on change la photo,
......@@ -83,10 +87,12 @@ $(document).ready(function(){
src = data['src'];
console.log('src');
errorFormat = data['error'];
Console.empty();
Console.append(data['message']);
var message = data['message']
if(!errorFormat){
format_correct = true;
photoDetourage(errorFormat, formData);
photoDetourage(formData);
}
else{alert(message)}
})
});
......@@ -139,7 +145,9 @@ $(document).ready(function(){
<h3>Votre adresse électronique sera ${mailCalcule}, vous recevrez votre mot de passe dans les 24 heures.</h3>
</div>
<div class = "container">
<button type="button" id="valide-mail" style="align-items:start">Ok c'est bon !</button>
<form action="" method="" onsubmit="event.preventDefault();sendMail()">
<input type="submit" id="valide-mail" value="Ok c'est bon !" class="btn btn-secondary" style="background-color:#00b8de">
</form>
</div>
`
);
......@@ -155,7 +163,8 @@ $(document).ready(function(){
function sendMail(){
console.log($("input[name=\"mail\"]:checked").val());
var mail = $("input[name=\"mail\"]:checked").val();
if(unSeulVisage&&format_correct){
console.log("unSeulVisage: "+unSeulVisage+"\nformat_correct: "+format_correct);
if(unSeulVisage && format_correct){
$.ajax({
url: URL_CHOOSE_MAIL,
method: 'POST',
......@@ -170,10 +179,10 @@ function sendMail(){
// window.close();
}
async function photoDetourage(errorFormat, formData){
async function photoDetourage(formData){
await findFaces(ID);
console.log("await")
if(!errorFormat){
console.log("await");
if (unSeulVisage){
$.ajax({
//url de la requête
url: URL_DETOURAGE,
......@@ -194,6 +203,7 @@ async function photoDetourage(errorFormat, formData){
$("#img-ID2").attr('src',data['src']);
})
}
}
async function findFaces(idImage) {
......@@ -213,38 +223,15 @@ async function findFaces(idImage) {
$("#"+idStatut).append(predictions.length+" face(s) found!");
if(predictions.length==1){
$("#li-oneface").css('color','green');
li_OneFace.removeClass("list-group-item-secondary list-group-item-danger").addClass("list-group-item-success");
unSeulVisage = true;
}
else{$("#li-oneface").css('color','red');}
// const canvas = document.getElementById(canva);
// canvas.width = img.width;
// canvas.height = img.height;
// const ctx = canvas.getContext("2d");
// ctx.fillStyle = "rgba(250,225,6,0.5)";
// for (let i = 0; i < predictions.length; i++)
// {
// const start = predictions[i].topLeft;
// const end = predictions[i].bottomRight;
// const size = [end[0] - start[0], end[1] - start[1]];
// ctx.fillRect(start[0], start[1], size[0], size[1]);
// var landmark;
// for (let j = 0; j < predictions[i].landmarks.length; j++)
// {
// landmark = predictions[i].landmarks[j];
// ctx.beginPath();
// ctx.arc(landmark[0],landmark[1], 1, 0, 2*Math.PI,false);
// ctx.fill();
// ctx.lineWidth = 1;
// ctx.strokeStyle = '#ff0000';
// ctx.stroke();
// }
// }
else{li_OneFace.removeClass("list-group-item-secondary list-group-item-success").addClass("list-group-item-danger");}
}
else {
$("#"+idStatut).empty();
$("#"+idStatut).append("No Face(s) Found");
$("#li-oneface").css('color','red');
li_OneFace.removeClass("list-group-item-secondary list-group-item-success").addClass("list-group-item-danger");
}
btnSubmit.prop('disabled',false);
btnCustomFileUpload.prop('disabled',false);
......
......@@ -12,8 +12,10 @@ if($_SERVER["REQUEST_METHOD"] == "POST")
{
$allowed = array(
"jpg" => "image/jpeg",
"jpeg" => "image/jpeg",
"png" => "image/png",
"PNG" => "image/PNG"
"PNG" => "image/PNG",
"JPG" => "image/JPG"
);
$filename = htmlspecialchars(trim($_FILES["photo"]["name"]));// évite les noms de fichiers trop exotiques
$newfilename = $filename;
......@@ -60,7 +62,7 @@ if($_SERVER["REQUEST_METHOD"] == "POST")
}
else
{
$message = "Error: La taille du fichier est supérieure à la limite autorisée.";
$message = "Error: La taille du fichier est supérieure à la limite autorisée (1 Mo)";
$errorType = "poids_taille";
}
}
......
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