$(function() { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /*~~~~~~~~~~~~~~~~TR TO EDIT~~~~~~~~~~~~~~~~*/ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ $("#allRecord").on("click", ".editUser", function() { $(this).toggleClass('fa-edit fa-check'); $(this).toggleClass('editUser confirmEditUser'); for(i=0; i<$("td", $(this).parent().parent()).length-1;i++) { j= $($("td", $(this).parent().parent())[i]); className = j.attr('class'); if(className == "sl") { val = ltrim(j.html()); j.html('') } else { inputOptions = ''; if(className=="pw") inputOptions += 'type="password" data-oldpw="'+ltrim(j.html())+'" '; else if (j.attr('class') == "datene") inputOptions += 'type="date" ' j.html(''); } } }); /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /*~~~~~~~~~~~~~~~~CONFIRM EDIT~~~~~~~~~~~~~~~~*/ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ $("#allRecord").on("click", ".confirmEditUser", function() { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /*~~~~~~~~~~~~~~~~CALL BACK DE LA VERIF DE MOT DE PASSE~~~~~~~~~~~~~~~~*/ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ function callBackVerif(data){ var dataToSend = new Object(); //Objet contenant les données à envoyé dataToSend["updatePW"] = (data===true?false:true); if($(".pw input", tr).val() === data || data === true) //Verif du mot de passe si nécesaire { for(i=0; i"+e , "error" ); } console.log(data.return) }, "json"); } else { swal( "Oops" , "Password don't match !" , "error" ); } } /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ tds = $("td", $(this).parent().parent()); //Récupère les td concernant le click tr = $(this).parent().parent(); //Récupère le tr concernant le click that = this; if ($(".pw input", tr).val() === "") { callBackVerif(true); } else { swal({ closeOnClickOutside: false, closeOnEsc: false, content: { element: "input", attributes: { placeholder: "Confirmer le mot de passe", type: "password", }, }, }).then(callBackVerif); } }); }); //J'avais plein d'espace a droite en récupérent mon innerHTML //https://stackoverflow.com/questions/24282158/removing-the-white-space-at-the-start-of-the-string function ltrim(str) { if(str == null) return str; return str.replace(/^\s+/g, ''); }