46 lines
1.4 KiB
HTML
46 lines
1.4 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Formulaire César</title>
|
|
<script type="text/javascript">
|
|
var httpRequest;
|
|
function requeteHTTP(i, n) {
|
|
console.log("i = " +i);
|
|
console.log("n = " +n);
|
|
if (i === "") return false;
|
|
if ( (n >= 0) && (n <= 26) ) {
|
|
httpRequest = new XMLHttpRequest();
|
|
httpRequest.onreadystatechange = () => {
|
|
accuseReception(httpRequest);
|
|
};
|
|
httpRequest.open('GET', "http://localhost:8080/cesar/" + n + "?val=" + i, true);
|
|
httpRequest.setRequestHeader("Content-Type", "application/json");
|
|
httpRequest.send();
|
|
}
|
|
}
|
|
|
|
function accuseReception(httpRequest) {
|
|
if (httpRequest.readyState == XMLHttpRequest.DONE) {
|
|
if (httpRequest.status == 200) {
|
|
console.log(httpRequest.responseText);
|
|
document.getElementById("resultat").innerHTML = httpRequest.responseText;
|
|
} else {
|
|
console.error('Il y a eu un problème avec la requête.');
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<fieldset>
|
|
<label for="val">Texte à chiffrer :</label>
|
|
<input type="text" id="val" name="val" required><br />
|
|
<label for="decal">Decallage :</label>
|
|
<input type="text" id="decal" name="decal" required>
|
|
<br>
|
|
<button onclick="requeteHTTP(document.getElementById('val').value, document.getElementById('decal').value)">Envoyer</button>
|
|
</fieldset>
|
|
<div id="resultat"></div>
|
|
</body>
|
|
</html>
|