Skip to content

Commit

Permalink
Routine-56 - Envoyer un courriel pour valider les médailles #56
Browse files Browse the repository at this point in the history
  • Loading branch information
massicos committed Jan 29, 2016
1 parent 3346269 commit 52eefd1
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 53 deletions.
69 changes: 39 additions & 30 deletions www/js/dialogModeParent.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,7 @@ $(function () {
modal: true,
buttons: {
"OK": function () {

url = "/routine" + config.getSuffixeCheminpParNiveau() +
"/services/famille_modeParent.php?mdp=" + $("#mdpParent").val();
var jqxhr = $.ajax( {
url: url,
dataType: "json",
async: false,
context: this
})
.done(function(msg) {
console.log( "success " + msg.nom + " " + msg.modeParent);
if (msg.modeParent) {
$("#btnOuvrirDialogModeParent").hide();
famille.setModeParent(true);
tableauBordView.affichageModeParent($(".tableauBord"));
$(this).dialog("close");
} else {
$("#modeParentMessage").text("Erreur, mot de passe invalide.");
$("#mdpParent").val("");
$("#modeParentMessage").show();
}

})
.fail(function(msg) {
console.log( "error" + msg.erreur);
$("#modeParentMessage").text("Erreur, problème de communication.");
})
.always(function() {
console.log( "complete" );
});
authentificationModeParent();
},
Cancel: function () {
$(this).dialog("close");
Expand Down Expand Up @@ -72,5 +43,43 @@ $(function () {
console.log( "complete" );
});
});

$("#mdpParent").keypress(function(event) {
if (event.which == 13) {
console.log("Enter !!");
authentificationModeParent();
}
});

function authentificationModeParent() {
url = "/routine" + config.getSuffixeCheminpParNiveau() +
"/services/famille_modeParent.php?mdp=" + $("#mdpParent").val();
var jqxhr = $.ajax( {
url: url,
dataType: "json",
async: false,
context: this
})
.done(function(msg) {
console.log( "success " + msg.nom + " " + msg.modeParent);
if (msg.modeParent) {
$("#btnOuvrirDialogModeParent").hide();
famille.setModeParent(true);
tableauBordView.affichageModeParent($(".tableauBord"));
monDialog.dialog("close");
} else {
$("#modeParentMessage").text("Erreur, mot de passe invalide.");
$("#mdpParent").val("");
$("#modeParentMessage").show();
}

})
.fail(function(msg) {
console.log( "error" + msg.erreur);
$("#modeParentMessage").text("Erreur, problème de communication.");
})
.always(function() {
console.log( "complete" );
});
}
});
55 changes: 32 additions & 23 deletions www/js/login.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
$(document).ready(function() {
$("#btnConnecter").click(function() {
authentification();
});

$("#password").keypress(function(event) {
if (event.which == 13) {
console.log("Enter !!");
authentification();
}
});

function authentification() {
if (ajaxLogin("services/famille_login.php", $("#login").val(), $("#password").val(), $("#loginMessage"))) {
window.location.assign("index.php");
//alert("Done !!");
}
else {
$("#password").val("");
}
}
}

});

function ajaxLogin(url, login, password, errorDisplay) {
// Ajax
var succesAjax = false;
Expand All @@ -21,25 +30,25 @@ $(document).ready(function() {
async: false,
context: this
})
.done(function (msg) {
console.log("done");
console.debug(msg);
if (msg.isLogin) {
succesAjax = true;
}
else {
$(errorDisplay).text("Veuillez entrer un code d'usager et un mot de passe valide.");
$(errorDisplay).show();
succesAjax = false;
}
})
.fail(function (msg) {
console.log("fail");
$(errorDisplay).text("Problème de communication !");
$(errorDisplay).show();
succesAjax = false;
})
return succesAjax;
.done(function (msg) {
console.log("done");
console.debug(msg);
if (msg.isLogin) {
succesAjax = true;
}
else {
$(errorDisplay).text("Veuillez entrer un code d'usager et un mot de passe valide.");
$(errorDisplay).show();
succesAjax = false;
}
})
.fail(function (msg) {
console.log("fail");
$(errorDisplay).text("Problème de communication !");
$(errorDisplay).show();
succesAjax = false;
})
return succesAjax;
}
});

0 comments on commit 52eefd1

Please sign in to comment.