From a5d08063d87bf1646f0d20ca77755aac579cccae Mon Sep 17 00:00:00 2001 From: adri Date: Wed, 2 Jan 2019 10:29:27 +0100 Subject: [PATCH] add user html done --- index.php | 3 +++ script.js | 62 ++++++++++++++++++++++++++++++++++++++++++++++++------- style.css | 5 +++++ 3 files changed, 62 insertions(+), 8 deletions(-) diff --git a/index.php b/index.php index ec19f63..e2760b7 100755 --- a/index.php +++ b/index.php @@ -57,6 +57,9 @@ $reponse = $bdd->query('SELECT * FROM projetphp'); + + + diff --git a/script.js b/script.js index 407993f..7c6a7e3 100644 --- a/script.js +++ b/script.js @@ -1,7 +1,26 @@ +htmlAddUser = '\ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ +'; +passwordPatern=/^[a-zA-Z0-9]{8,16}$/; +loginPatern=/^[a-z]{8,16}$/ +mailPatern=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;//https://emailregex.com/ + + $(function() { - passwordPatern=/^[a-zA-Z0-9]{8,16}$/; - loginPatern=/^[a-z]{8,16}$/ - mailPatern=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;//https://emailregex.com/ $("#allRecord").on("keyup", ".pw input", function(){ if(passwordPatern.test($(this).val()) || $(this).val() == "") { @@ -30,6 +49,7 @@ $("#allRecord").on("keyup", ".email input", function(){ /*~~~~~~~~~~~~~~~~TR TO DEL~~~~~~~~~~~~~~~~*/ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ $("#allRecord").on("click", ".delUser", function() { + newUser = false; tr = $(this).parent().parent(); var login = ""; var sl = ""; @@ -45,10 +65,16 @@ $("#allRecord").on("click", ".delUser", function() { } else { - swal("error"); - return ; + try{ + login = "New user "+$('.login input', tr).val(); + newUser = true; + } + catch(e) + { + swal("error : "+e); + return ; + } } - console.log(sl); if(sl == "10") { swal( "Oops" , "You can't del user with sl 10" , "error" ); @@ -64,12 +90,19 @@ $("#allRecord").on("click", ".delUser", function() { }) .then((willDelete) => { if (willDelete) { - $.post("post.php", {userToDel: login}, function(){ + if(!newUser) + $.post("post.php", {userToDel: login}, function(){ + tr.remove(); + swal("Poof! "+login+" has been deleted!", { + icon: "success", + }); + }); + else { tr.remove(); swal("Poof! "+login+" has been deleted!", { icon: "success", }); - }) + } } else { } @@ -191,6 +224,19 @@ $("#allRecord").on("click", ".delUser", function() { else swal( "Oops" , "Input don't respect rules !" , "error" ); }); + /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ + /*~~~~~~~~~~~~~~~~ADD USER~~~~~~~~~~~~~~~~*/ + /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ + $("#allRecord").on("click", ".fa-user-plus", function(){ + $(this).parent().parent().before(htmlAddUser); + }); + $("#allRecord").on("click", ".confirmNewUser", function(){ + + }); + $("#allRecord").on("click", ".delNewUser", function(){ + tr = $(this).parent().parent(); + tr.remove(); + }); }); //J'avais plein d'espace a droite en récupérent mon innerHTML diff --git a/style.css b/style.css index 27f24bf..79245fb 100644 --- a/style.css +++ b/style.css @@ -16,3 +16,8 @@ input { margin: 0px; } + +select +{ + margin-bottom: 0px; !important +}