On avance encore un peu...
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<meta name="generator" content="">
<title>Accueil</title>
<link rel="canonical" href="https://getbootstrap.com/docs/5.1/examples/features/">
<!-- Bootstrap core CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<!-- Favicons -->
<link rel="icon" href="/docs/5.1/assets/img/favicons/favicon.ico">
<meta name="theme-color" content="#7952b3">
<!-- Custom styles for this template -->
<link href="https://getbootstrap.com/docs/5.1/examples/features/features.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.8.1/font/bootstrap-icons.css">
</head>
<body>
<div class="container" id="header">
<div class="row">
<div class="col-md-4">
<h1 class="h6">Révision / Cours de développement web</h1>
</div>
<div class="col-md-4"><nav class="navbar navbar-expand-lg navbar-light bg-light text-center" id="menu-header"><div class="container-fluid"><div class="collapse navbar-collapse"></div></div></nav></div>
<div class="col-md-4" id="locateConnexion">
<form onSubmit="fonctionQueJeVeux();return false;" id="formDeConnexion">
<label>Nom</label><input type="text" id="nom" class="form-control" placeholder="numéro étudiant" required>
<label>Mot de passe</label><input type="password" id="pass1" placeholder="*******" class="form-control" required>
<label>Mot de passe à nouveau</label><input type="password" id="pass2" placeholder="*******" class="form-control" required>
<button type="submit" class="btn btn-primary">Se connecter</button>
</form>
</div>
</div>
</div>
<div class="container" id="center">
<div class="row">
Salut
</div>
</div>
<div class="container" id="footer">
<div class="row">
<div class="col-md-4"></div>
<div class="col-md-4">
<nav class="navbar navbar-expand-lg navbar-light bg-light text-center" id="menu-footer"><div class="container-fluid"><div class="collapse navbar-collapse"></div></div></nav>
</div>
<div class="col-md-4"></div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.10.2/dist/umd/popper.min.js" integrity="sha384-7+zCNj/IqJ95wo16oMtfsKbZ9ccEh31eOz1HGyDuCQ6wgnyJNSYdrPa03rtR1zdB" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.min.js" integrity="sha384-QJHtvGhmr9XOIpI6YVutG+2QOK9T+ZnN4kzFN1RtK3zEFEIsxhlmWl5/YESvpZ13" crossorigin="anonymous"></script>
<script>
console.log(document.getElementById('center'));
document.getElementById('center').style.minHeight = '400px';
document.getElementById('center').style.color = 'red';
let estConnecte = false;
let token = null;
let Menu = {entrees:[
{nom:"Items",url:"item.html",nouvellepage:0,actif:1,ordre:1},
{nom:"Utilisateurs",url:"utilisateur.html",nouvellepage:0,actif:1,ordre:3},
{nom:"Articles",url:"article.html",nouvellepage:0,actif:1,ordre:4},
{nom:"Tarifs",url:"tarif.html",nouvellepage:0,actif:1,ordre:2}
]};
console.log(Menu);
/*
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="item.html">Item</a>
</li>
*/
function ConstructionDuMenu(menu)
{
var ul = document.createElement('ul');
ul.classList.add('navbar-nav', 'me-auto', 'mb-2', 'mb-lg-0');
for(var i=0;i<menu.length;i++)
{
var li = document.createElement('li');
li.classList.add('nav-item');
var a = document.createElement('a');
a.classList.add('nav-link');
a.href=menu[i].url;
a.innerHTML = menu[i].nom;
li.appendChild(a);
ul.appendChild(li);
}
let ul2 = ul.cloneNode(true);
let emplacementDuMenuHaut = document.getElementById('menu-header').childNodes[0].childNodes[0];
emplacementDuMenuHaut.appendChild(ul);
let emplacementDuMenuBas = document.getElementById('menu-footer').childNodes[0].childNodes[0];
emplacementDuMenuBas.appendChild(ul2);
}
ConstructionDuMenu(Menu.entrees);
function fonctionQueJeVeux()
{
let login = document.getElementById('nom').value;
let pass1 = document.getElementById('pass1').value;
let pass2 = document.getElementById('pass2').value;
if(login == '')
{
alert('Hey, ton nom !!!');
return false;
}
if(pass1 == '' || pass2 == '')
{
alert('Hey, le mot de passe !!!');
return false;
}
if(!verifierSimilariteMotDePasse(pass1,pass2))
{
alert('Hey, mots de passe pas pareils !!!');
return false;
}
//AJAX
//URL : https://iwa2021.edriki.com/api/Connexion?login=LOGIN&pass=PASS
const xhr = new XMLHttpRequest();
const url = 'https://iwa2021.edriki.com/api/Connexion?login='+login+'&pass='+pass1+'';
xhr.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var reponse = JSON.parse(this.responseText);
if(reponse.status == 'success')
{
estConnecte = true;
token = reponse.token;
document.getElementById('formDeConnexion').hidden = true;
var prezNom = document.createElement('h3');
prezNom.innerHTML = reponse.person.nom+' '+reponse.person.prenom;
document.getElementById('locateConnexion').appendChild(prezNom);
}
}
};
xhr.open("GET", url,true);
xhr.send();
}
function verifierSimilariteMotDePasse(str1,str2)
{
if(str1 == str2)
{
return true;
}
return false;
}
</script>
</body>
</html>