beautify
This commit is contained in:
parent
a5d08063d8
commit
a345a22565
57
index.php
57
index.php
|
@ -1,29 +1,31 @@
|
||||||
<?php
|
<?php
|
||||||
try {
|
try {
|
||||||
$config = include('config.php');
|
$config = include('config.php');
|
||||||
$bdd = new PDO('mysql:host='.$config['host'].';dbname='.$config['dbName'].';charset=utf8', $config['username'], $config['pw']);
|
$bdd = new PDO('mysql:host='.$config['host'].';dbname='.$config['dbName'].';charset=utf8', $config['username'], $config['pw']);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
die('Erreur : '.$e->getMessage());
|
die('Erreur : '.$e->getMessage());
|
||||||
}
|
}
|
||||||
$reponse = $bdd->query('SELECT * FROM projetphp');
|
$reponse = $bdd->query('SELECT * FROM projetphp');
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
|
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title></title>
|
<title></title>
|
||||||
<!-- somme features-->
|
<!-- somme features-->
|
||||||
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Roboto:300,300italic,700,700italic">
|
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Roboto:300,300italic,700,700italic">
|
||||||
<link rel="stylesheet" href="//cdn.rawgit.com/necolas/normalize.css/master/normalize.css">
|
<link rel="stylesheet" href="//cdn.rawgit.com/necolas/normalize.css/master/normalize.css">
|
||||||
<link rel="stylesheet" href="//cdn.rawgit.com/milligram/milligram/master/dist/milligram.min.css">
|
<link rel="stylesheet" href="//cdn.rawgit.com/milligram/milligram/master/dist/milligram.min.css">
|
||||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
|
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/2.1.2/sweetalert.min.js" integrity="sha256-KsRuvuRtUVvobe66OFtOQfjP8WA2SzYsmm4VPfMnxms=" crossorigin="anonymous"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/2.1.2/sweetalert.min.js" integrity="sha256-KsRuvuRtUVvobe66OFtOQfjP8WA2SzYsmm4VPfMnxms=" crossorigin="anonymous"></script>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||||
<!--My features-->
|
<!--My features-->
|
||||||
<link rel="stylesheet" href="style.css?<?php echo date('l jS \of F Y h:i:s A'); ?>">
|
<link rel="stylesheet" href="style.css?<?php echo date('l jS \of F Y h:i:s A'); ?>">
|
||||||
<script src="script.js?<?php echo date('l jS \of F Y h:i:s A'); ?>"></script>
|
<script src="script.js?<?php echo date('l jS \of F Y h:i:s A'); ?>"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<table id="allRecord">
|
<table id="allRecord">
|
||||||
<thead>
|
<thead>
|
||||||
|
@ -38,29 +40,34 @@ $reponse = $bdd->query('SELECT * FROM projetphp');
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
while($data = $reponse->fetch())
|
while ($data = $reponse->fetch()) {
|
||||||
{
|
?>
|
||||||
?>
|
<tr class="record">
|
||||||
<tr class="record">
|
<td class="login">
|
||||||
<td class="login">
|
<?= ($data["login"]) ?>
|
||||||
<?= ($data["login"]) ?></td>
|
</td>
|
||||||
<td class="datene">
|
<td class="datene">
|
||||||
<?= ($data["date_naissance"]) ?></td>
|
<?= ($data["date_naissance"]) ?>
|
||||||
<td class="email">
|
</td>
|
||||||
<?= ($data["e_mail"]) ?></td>
|
<td class="email">
|
||||||
<td class="pw">
|
<?= ($data["e_mail"]) ?>
|
||||||
<?= ($data["mot_de_passe"]) ?></td>
|
</td>
|
||||||
<td class="sl">
|
<td class="pw">
|
||||||
<?= ($data["security_level"]) ?></td>
|
<?= ($data["mot_de_passe"]) ?>
|
||||||
<td><i class="fas fa-edit click editUser"></i><i class="fas fa-trash-alt click delUser"></i></td>
|
</td>
|
||||||
</tr>
|
<td class="sl">
|
||||||
<?php
|
<?= ($data["security_level"]) ?>
|
||||||
}
|
</td>
|
||||||
?>
|
<td><i class="fas fa-edit click editUser"></i><i class="fas fa-trash-alt click delUser"></i></td>
|
||||||
|
</tr>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
<tr rowspan="2">
|
<tr rowspan="2">
|
||||||
<td colspan="6" style="text-align:center"><i class="fas fa-user-plus fa-4x click" ></i></td>
|
<td colspan="6" style="text-align:center"><i class="fas fa-user-plus fa-4x click"></i></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|
69
post.php
69
post.php
|
@ -2,50 +2,45 @@
|
||||||
$ret["return"] = false;
|
$ret["return"] = false;
|
||||||
$ret["pw"] = null;
|
$ret["pw"] = null;
|
||||||
try {
|
try {
|
||||||
$config = include('config.php');
|
$config = include('config.php');
|
||||||
$bdd = new PDO('mysql:host='.$config['host'].';dbname='.$config['dbName'].';charset=utf8', $config['username'], $config['pw']);
|
$bdd = new PDO('mysql:host='.$config['host'].';dbname='.$config['dbName'].';charset=utf8', $config['username'], $config['pw']);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
die('Erreur : '.$e->getMessage());
|
die('Erreur : '.$e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
//DELETE FROM `projetphp` WHERE `projetphp`.`login` = \'caprout\'
|
//DELETE FROM `projetphp` WHERE `projetphp`.`login` = \'caprout\'
|
||||||
if(isset($_POST["userToDel"]))
|
if (isset($_POST["userToDel"])) {
|
||||||
{
|
$req = $bdd->prepare('DELETE FROM `projetphp` WHERE `projetphp`.`login`=:login');
|
||||||
$req = $bdd->prepare('DELETE FROM `projetphp` WHERE `projetphp`.`login`=:login');
|
$req->execute(array( 'login' => htmlspecialchars($_POST["userToDel"])));
|
||||||
$req->execute(array( 'login' => htmlspecialchars($_POST["userToDel"])));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//UPDATE `projetphp` SET `security_level` = '6' WHERE `projetphp`.`login` = 'aaazzze';
|
//UPDATE `projetphp` SET `security_level` = '6' WHERE `projetphp`.`login` = 'aaazzze';
|
||||||
if(isset($_POST["updatePW"], $_POST["datene"], $_POST["email"], $_POST["pw"], $_POST["sl"], $_POST["login"]))
|
if (isset($_POST["updatePW"], $_POST["datene"], $_POST["email"], $_POST["pw"], $_POST["sl"], $_POST["login"])) {
|
||||||
if(preg_match('/^(([^<>()\[\]\\.,;:\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,}))$/', $_POST["email"]))
|
if (preg_match('/^(([^<>()\[\]\\.,;:\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,}))$/', $_POST["email"])) {
|
||||||
if(htmlspecialchars($_POST["updatePW"], ENT_QUOTES, 'UTF-8') == "true" && preg_match('/^[a-z]{8,16}$/',$_POST["pw"]))
|
if (htmlspecialchars($_POST["updatePW"], ENT_QUOTES, 'UTF-8') == "true" && preg_match('/^[a-z]{8,16}$/', $_POST["pw"])) {
|
||||||
{
|
$req = $bdd->prepare('UPDATE `projetphp` SET `date_naissance` = :datene, `e_mail` = :email, `mot_de_passe` = :pw, `security_level` = :sl WHERE `projetphp`.`login` = :login');
|
||||||
$req = $bdd->prepare('UPDATE `projetphp` SET `date_naissance` = :datene, `e_mail` = :email, `mot_de_passe` = :pw, `security_level` = :sl WHERE `projetphp`.`login` = :login');
|
$req->execute(array(
|
||||||
$req->execute(array(
|
'datene' => htmlspecialchars($_POST["datene"], ENT_QUOTES, 'UTF-8'),
|
||||||
'datene' => htmlspecialchars($_POST["datene"], ENT_QUOTES, 'UTF-8'),
|
'email' => htmlspecialchars($_POST["email"], ENT_QUOTES, 'UTF-8'),
|
||||||
'email' => htmlspecialchars($_POST["email"], ENT_QUOTES, 'UTF-8'),
|
'pw' => md5(htmlspecialchars($_POST["pw"], ENT_QUOTES, 'UTF-8')),
|
||||||
'pw' => md5(htmlspecialchars($_POST["pw"], ENT_QUOTES, 'UTF-8')),
|
'sl' => htmlspecialchars($_POST["sl"], ENT_QUOTES, 'UTF-8'),
|
||||||
'sl' => htmlspecialchars($_POST["sl"], ENT_QUOTES, 'UTF-8'),
|
'login' => htmlspecialchars($_POST["login"], ENT_QUOTES, 'UTF-8'),
|
||||||
'login' => htmlspecialchars($_POST["login"], ENT_QUOTES, 'UTF-8'),
|
));
|
||||||
));
|
$ret["return"] = true;
|
||||||
$ret["return"] = true;
|
$ret["pw"] = md5(htmlspecialchars($_POST["pw"], ENT_QUOTES, 'UTF-8'));
|
||||||
$ret["pw"] = md5(htmlspecialchars($_POST["pw"], ENT_QUOTES, 'UTF-8'));
|
} elseif (htmlspecialchars($_POST["updatePW"], ENT_QUOTES, 'UTF-8') == "false") {
|
||||||
}
|
$req = $bdd->prepare('UPDATE `projetphp` SET `date_naissance` = :datene, `e_mail` = :email, `security_level` = :sl WHERE `projetphp`.`login` = :login');
|
||||||
else if(htmlspecialchars($_POST["updatePW"], ENT_QUOTES, 'UTF-8') == "false")
|
$req->execute(array(
|
||||||
{
|
'datene' => htmlspecialchars($_POST["datene"], ENT_QUOTES, 'UTF-8'),
|
||||||
$req = $bdd->prepare('UPDATE `projetphp` SET `date_naissance` = :datene, `e_mail` = :email, `security_level` = :sl WHERE `projetphp`.`login` = :login');
|
'email' => htmlspecialchars($_POST["email"], ENT_QUOTES, 'UTF-8'),
|
||||||
$req->execute(array(
|
'sl' => htmlspecialchars($_POST["sl"], ENT_QUOTES, 'UTF-8'),
|
||||||
'datene' => htmlspecialchars($_POST["datene"], ENT_QUOTES, 'UTF-8'),
|
'login' => htmlspecialchars($_POST["login"], ENT_QUOTES, 'UTF-8'),
|
||||||
'email' => htmlspecialchars($_POST["email"], ENT_QUOTES, 'UTF-8'),
|
));
|
||||||
'sl' => htmlspecialchars($_POST["sl"], ENT_QUOTES, 'UTF-8'),
|
$ret["return"] = true;
|
||||||
'login' => htmlspecialchars($_POST["login"], ENT_QUOTES, 'UTF-8'),
|
$ret["pw"] = htmlspecialchars($_POST["pw"], ENT_QUOTES, 'UTF-8');
|
||||||
));
|
} else ;
|
||||||
$ret["return"] = true;
|
} else ;
|
||||||
$ret["pw"] = htmlspecialchars($_POST["pw"], ENT_QUOTES, 'UTF-8');
|
}
|
||||||
}
|
|
||||||
else;
|
|
||||||
else;
|
|
||||||
|
|
||||||
echo json_encode((object)$ret);
|
echo json_encode((object)$ret);
|
||||||
?>
|
|
||||||
|
|
397
script.js
397
script.js
|
@ -1,247 +1,226 @@
|
||||||
htmlAddUser = '<tr class="newRecord">\
|
htmlAddUser = '<tr class="newRecord">\
|
||||||
<td class="login">\
|
<td class="login">\
|
||||||
<input type="text" /></td>\
|
<input type="text" /></td>\
|
||||||
<td class="datene">\
|
<td class="datene">\
|
||||||
<input type="date" /></td>\
|
<input type="date" /></td>\
|
||||||
<td class="email">\
|
<td class="email">\
|
||||||
<input type="text" /></td>\
|
<input type="text" /></td>\
|
||||||
<td class="pw">\
|
<td class="pw">\
|
||||||
<input type="password" /></td>\
|
<input type="password" /></td>\
|
||||||
<td class="sl">\
|
<td class="sl">\
|
||||||
<select>\
|
<select>\
|
||||||
<option value="1">1</option>\
|
<option value="1">1</option>\
|
||||||
<option value="5">5</option>\
|
<option value="5">5</option>\
|
||||||
<option value="10">10</option>\
|
<option value="10">10</option>\
|
||||||
</select></td>\
|
</select></td>\
|
||||||
<td><i class="fas fa-check click confirmNewUser"></i><i class="fas fa-trash-alt click delUser"></i></td>\
|
<td><i class="fas fa-check click confirmNewUser"></i><i class="fas fa-trash-alt click delUser"></i></td>\
|
||||||
</tr>';
|
</tr>';
|
||||||
passwordPatern=/^[a-zA-Z0-9]{8,16}$/;
|
passwordPatern = /^[a-zA-Z0-9]{8,16}$/;
|
||||||
loginPatern=/^[a-z]{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/
|
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() {
|
$(function() {
|
||||||
$("#allRecord").on("keyup", ".pw input", function(){
|
$("#allRecord").on("keyup", ".pw input", function() {
|
||||||
if(passwordPatern.test($(this).val()) || $(this).val() == "")
|
if (passwordPatern.test($(this).val()) || $(this).val() == "") {
|
||||||
{
|
$(this).css("background-color", "");
|
||||||
$(this).css("background-color", "");
|
$('div', $(this).parent()).css("display", "none");
|
||||||
$('div', $(this).parent()).css("display", "none");
|
} else {
|
||||||
}
|
$(this).css("background-color", "red");
|
||||||
else
|
$('div', $(this).parent()).css("display", "block");
|
||||||
{
|
|
||||||
$(this).css("background-color", "red");
|
|
||||||
$('div', $(this).parent()).css("display", "block");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
$("#allRecord").on("keyup", ".email input", function(){
|
|
||||||
if(mailPatern.test($(this).val()))
|
|
||||||
{
|
|
||||||
$(this).css("background-color", "");
|
|
||||||
$('div', $(this).parent()).css("display", "none");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$(this).css("background-color", "red");
|
|
||||||
$('div', $(this).parent()).css("display", "block");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
||||||
/*~~~~~~~~~~~~~~~~TR TO DEL~~~~~~~~~~~~~~~~*/
|
|
||||||
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
||||||
$("#allRecord").on("click", ".delUser", function() {
|
|
||||||
newUser = false;
|
|
||||||
tr = $(this).parent().parent();
|
|
||||||
var login = "";
|
|
||||||
var sl = "";
|
|
||||||
if(tr.find("i.editUser").length !== 0)
|
|
||||||
{
|
|
||||||
sl = ltrim($('.sl', tr).html())
|
|
||||||
login = $('.login', tr).html();
|
|
||||||
}
|
|
||||||
else if(tr.find("i.confirmEditUser").length !== 0)
|
|
||||||
{
|
|
||||||
sl = $('.sl select', tr).val();
|
|
||||||
login = $('.login', tr).html();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
try{
|
|
||||||
login = "New user "+$('.login input', tr).val();
|
|
||||||
newUser = true;
|
|
||||||
}
|
|
||||||
catch(e)
|
|
||||||
{
|
|
||||||
swal("error : "+e);
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(sl == "10")
|
});
|
||||||
{
|
$("#allRecord").on("keyup", ".email input", function() {
|
||||||
swal( "Oops" , "You can't del user with sl 10" , "error" );
|
if (mailPatern.test($(this).val())) {
|
||||||
|
$(this).css("background-color", "");
|
||||||
|
$('div', $(this).parent()).css("display", "none");
|
||||||
|
} else {
|
||||||
|
$(this).css("background-color", "red");
|
||||||
|
$('div', $(this).parent()).css("display", "block");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
||||||
|
/*~~~~~~~~~~~~~~~~TR TO DEL~~~~~~~~~~~~~~~~*/
|
||||||
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
||||||
|
$("#allRecord").on("click", ".delUser", function() {
|
||||||
|
newUser = false;
|
||||||
|
tr = $(this).parent().parent();
|
||||||
|
var login = "";
|
||||||
|
var sl = "";
|
||||||
|
if (tr.find("i.editUser").length !== 0) {
|
||||||
|
sl = ltrim($('.sl', tr).html())
|
||||||
|
login = $('.login', tr).html();
|
||||||
|
} else if (tr.find("i.confirmEditUser").length !== 0) {
|
||||||
|
sl = $('.sl select', tr).val();
|
||||||
|
login = $('.login', tr).html();
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
login = "New user " + $('.login input', tr).val();
|
||||||
|
newUser = true;
|
||||||
|
} catch (e) {
|
||||||
|
swal("error : " + e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (sl == "10") {
|
||||||
|
swal("Oops", "You can't del user with sl 10", "error");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
login = ltrim(login);
|
login = ltrim(login);
|
||||||
swal({
|
swal({
|
||||||
title: "Are you sure to del "+login+" ?",
|
title: "Are you sure to del " + login + " ?",
|
||||||
text: "Once deleted, you will not be able to recover this!",
|
text: "Once deleted, you will not be able to recover this!",
|
||||||
icon: "warning",
|
icon: "warning",
|
||||||
buttons: true,
|
buttons: true,
|
||||||
dangerMode: true,
|
dangerMode: true,
|
||||||
})
|
})
|
||||||
.then((willDelete) => {
|
.then((willDelete) => {
|
||||||
if (willDelete) {
|
if (willDelete) {
|
||||||
if(!newUser)
|
if (!newUser)
|
||||||
$.post("post.php", {userToDel: login}, function(){
|
$.post("post.php", {
|
||||||
tr.remove();
|
userToDel: login
|
||||||
swal("Poof! "+login+" has been deleted!", {
|
}, function() {
|
||||||
icon: "success",
|
tr.remove();
|
||||||
});
|
swal("Poof! " + login + " has been deleted!", {
|
||||||
|
icon: "success",
|
||||||
|
});
|
||||||
|
});
|
||||||
|
else {
|
||||||
|
tr.remove();
|
||||||
|
swal("Poof! " + login + " has been deleted!", {
|
||||||
|
icon: "success",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
});
|
});
|
||||||
else {
|
|
||||||
tr.remove();
|
|
||||||
swal("Poof! "+login+" has been deleted!", {
|
|
||||||
icon: "success",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
||||||
/*~~~~~~~~~~~~~~~~TR TO EDIT~~~~~~~~~~~~~~~~*/
|
/*~~~~~~~~~~~~~~~~TR TO EDIT~~~~~~~~~~~~~~~~*/
|
||||||
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
||||||
$("#allRecord").on("click", ".editUser", function() {
|
$("#allRecord").on("click", ".editUser", function() {
|
||||||
$(this).toggleClass('fa-edit fa-check');
|
$(this).toggleClass('fa-edit fa-check');
|
||||||
$(this).toggleClass('editUser confirmEditUser');
|
$(this).toggleClass('editUser confirmEditUser');
|
||||||
for(i=1; i<$("td", $(this).parent().parent()).length-1;i++)
|
for (i = 1; i < $("td", $(this).parent().parent()).length - 1; i++) {
|
||||||
{
|
j = $($("td", $(this).parent().parent())[i]);
|
||||||
j= $($("td", $(this).parent().parent())[i]);
|
|
||||||
className = j.attr('class');
|
className = j.attr('class');
|
||||||
if(className == "sl")
|
if (className == "sl") {
|
||||||
{
|
|
||||||
val = ltrim(j.html());
|
val = ltrim(j.html());
|
||||||
j.html('<select>\
|
j.html('<select>\
|
||||||
<option value="1" '+(val=="1"?'selected':'')+'>1</option>\
|
<option value="1" ' + (val == "1" ? 'selected' : '') + '>1</option>\
|
||||||
<option value="5" '+(val=="5"?'selected':'')+'>5</option>\
|
<option value="5" ' + (val == "5" ? 'selected' : '') + '>5</option>\
|
||||||
<option value="10" '+(val=="10"?'selected':'')+'>10</option>\
|
<option value="10" ' + (val == "10" ? 'selected' : '') + '>10</option>\
|
||||||
</select>')
|
</select>')
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
inputOptions = '';
|
inputOptions = '';
|
||||||
if(className=="pw")
|
if (className == "pw")
|
||||||
inputOptions += 'type="password" data-oldpw="'+ltrim(j.html())+'" ';
|
inputOptions += 'type="password" data-oldpw="' + ltrim(j.html()) + '" ';
|
||||||
else if (j.attr('class') == "datene")
|
else if (j.attr('class') == "datene")
|
||||||
inputOptions += 'type="date" '
|
inputOptions += 'type="date" '
|
||||||
j.html('<input '+inputOptions+' value="'+(j.attr('class')=="pw"?'':ltrim(j.html()))+'" />');
|
j.html('<input ' + inputOptions + ' value="' + (j.attr('class') == "pw" ? '' : ltrim(j.html())) + '" />');
|
||||||
if(className=="pw")
|
if (className == "pw") {
|
||||||
{
|
|
||||||
j.append("<div>le mot de passe comporte entre 8 et 16 caractères parmi a..z A..Z 0..9</div>")
|
j.append("<div>le mot de passe comporte entre 8 et 16 caractères parmi a..z A..Z 0..9</div>")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
||||||
/*~~~~~~~~~~~~~~~~CONFIRM EDIT~~~~~~~~~~~~~~~~*/
|
/*~~~~~~~~~~~~~~~~CONFIRM EDIT~~~~~~~~~~~~~~~~*/
|
||||||
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
||||||
$("#allRecord").on("click", ".confirmEditUser", function() {
|
$("#allRecord").on("click", ".confirmEditUser", function() {
|
||||||
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
||||||
/*~~~~~~~~~~~~~~~~CALL BACK DE LA VERIF DE MOT DE PASSE~~~~~~~~~~~~~~~~*/
|
/*~~~~~~~~~~~~~~~~CALL BACK DE LA VERIF DE MOT DE PASSE~~~~~~~~~~~~~~~~*/
|
||||||
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
||||||
function callBackVerif(data){
|
function callBackVerif(data) {
|
||||||
var dataToSend = new Object(); //Objet contenant les données à envoyé
|
var dataToSend = new Object(); //Objet contenant les données à envoyé
|
||||||
dataToSend["updatePW"] = (data===true?false:true);
|
dataToSend["updatePW"] = (data === true ? false : true);
|
||||||
if($(".pw input", tr).val() === data || data === true) //Verif du mot de passe si nécesaire
|
if ($(".pw input", tr).val() === data || data === true) //Verif du mot de passe si nécesaire
|
||||||
{
|
{
|
||||||
for(i=0; i<tds.length-1;i++) //Analyse de chaque td
|
for (i = 0; i < tds.length - 1; i++) //Analyse de chaque td
|
||||||
{
|
{
|
||||||
j= $(tds[i]);
|
j = $(tds[i]);
|
||||||
className = j.attr('class');
|
className = j.attr('class');
|
||||||
if(className == "pw" && data === true)
|
if (className == "pw" && data === true)
|
||||||
value = $('input,select', j).data("oldpw");
|
value = $('input,select', j).data("oldpw");
|
||||||
else if(className=="login")
|
else if (className == "login")
|
||||||
value = ltrim(j.html());
|
value = ltrim(j.html());
|
||||||
else
|
|
||||||
value = $('input,select', j).val();
|
|
||||||
dataToSend[className] = value;
|
|
||||||
}
|
|
||||||
$.post("post.php", dataToSend, function(data){
|
|
||||||
try {
|
|
||||||
if(data.return == true)
|
|
||||||
{
|
|
||||||
for(i=1; i<tds.length-1;i++) //On change les input en pure html
|
|
||||||
{
|
|
||||||
j= $(tds[i]);
|
|
||||||
className = j.attr('class');
|
|
||||||
if(className == "pw")
|
|
||||||
value = data.pw;
|
|
||||||
else
|
|
||||||
value = $('input,select', j).val();
|
|
||||||
j.html(value);
|
|
||||||
}
|
|
||||||
swal("all done");
|
|
||||||
$(that).toggleClass('fa-check fa-edit');
|
|
||||||
$(that).toggleClass('confirmEditUser editUser');
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
swal(data);
|
value = $('input,select', j).val();
|
||||||
} catch (e) {
|
dataToSend[className] = value;
|
||||||
swal( "Oops" , "Something went wrong!<br>"+e , "error" );
|
}
|
||||||
}
|
$.post("post.php", dataToSend, function(data) {
|
||||||
console.log(data.return)
|
try {
|
||||||
}, "json");
|
if (data.return == true) {
|
||||||
}
|
for (i = 1; i < tds.length - 1; i++) //On change les input en pure html
|
||||||
else {
|
{
|
||||||
swal( "Oops" , "Password don't match !" , "error" );
|
j = $(tds[i]);
|
||||||
}
|
className = j.attr('class');
|
||||||
}
|
if (className == "pw")
|
||||||
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
value = data.pw;
|
||||||
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
else
|
||||||
tds = $("td", $(this).parent().parent()); //Récupère les td concernant le click
|
value = $('input,select', j).val();
|
||||||
tr = $(this).parent().parent(); //Récupère le tr concernant le click
|
j.html(value);
|
||||||
that = this;
|
}
|
||||||
if(mailPatern.test($(".email input", tr).val()) && (passwordPatern.test($(".pw input", tr).val()) || $(".pw input", tr).val() ==""))
|
swal("all done");
|
||||||
if ($(".pw input", tr).val() === "") {
|
$(that).toggleClass('fa-check fa-edit');
|
||||||
callBackVerif(true);
|
$(that).toggleClass('confirmEditUser editUser');
|
||||||
}
|
} else
|
||||||
else {
|
swal(data);
|
||||||
swal({
|
} catch (e) {
|
||||||
closeOnClickOutside: false,
|
swal("Oops", "Something went wrong!<br>" + e, "error");
|
||||||
closeOnEsc: false,
|
}
|
||||||
content: {
|
console.log(data.return)
|
||||||
element: "input",
|
}, "json");
|
||||||
attributes: {
|
} else {
|
||||||
placeholder: "Confirmer le mot de passe",
|
swal("Oops", "Password don't match !", "error");
|
||||||
type: "password",
|
}
|
||||||
},
|
}
|
||||||
},
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
||||||
}).then(callBackVerif);
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
||||||
}
|
tds = $("td", $(this).parent().parent()); //Récupère les td concernant le click
|
||||||
else
|
tr = $(this).parent().parent(); //Récupère le tr concernant le click
|
||||||
swal( "Oops" , "Input don't respect rules !" , "error" );
|
that = this;
|
||||||
});
|
if (mailPatern.test($(".email input", tr).val()) && (passwordPatern.test($(".pw input", tr).val()) || $(".pw input", tr).val() == ""))
|
||||||
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
if ($(".pw input", tr).val() === "") {
|
||||||
/*~~~~~~~~~~~~~~~~ADD USER~~~~~~~~~~~~~~~~*/
|
callBackVerif(true);
|
||||||
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
}
|
||||||
$("#allRecord").on("click", ".fa-user-plus", function(){
|
else {
|
||||||
$(this).parent().parent().before(htmlAddUser);
|
swal({
|
||||||
});
|
closeOnClickOutside: false,
|
||||||
$("#allRecord").on("click", ".confirmNewUser", function(){
|
closeOnEsc: false,
|
||||||
|
content: {
|
||||||
|
element: "input",
|
||||||
|
attributes: {
|
||||||
|
placeholder: "Confirmer le mot de passe",
|
||||||
|
type: "password",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}).then(callBackVerif);
|
||||||
|
} 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(){
|
$("#allRecord").on("click", ".delNewUser", function() {
|
||||||
tr = $(this).parent().parent();
|
tr = $(this).parent().parent();
|
||||||
tr.remove();
|
tr.remove();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
//J'avais plein d'espace a droite en récupérent mon innerHTML
|
//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
|
//https://stackoverflow.com/questions/24282158/removing-the-white-space-at-the-start-of-the-string
|
||||||
function ltrim(str) {
|
function ltrim(str) {
|
||||||
if(str == null) return str;
|
if (str == null) return str;
|
||||||
return str.replace(/^\s+/g, '');
|
return str.replace(/^\s+/g, '');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue