82 lines
3.0 KiB
HTML
82 lines
3.0 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>GMTROM - True Random Number Generator</title>
|
|
<link rel="stylesheet" type="text/css" href="style.css">
|
|
<link rel="icon" type="image/png" href="logomiddle.png">
|
|
</head>
|
|
<body>
|
|
<img src="logo.png" alt="Logo" class="logo">
|
|
<h1>GMTROM - True Random Number Generator</h1>
|
|
<form id="randomForm">
|
|
<input type="button" value="Initialize" id="initButton"><br><br>
|
|
<label for="quantity">Quantity of Random Numbers:</label>
|
|
<input type="number" id="quantity" name="quantity"><br><br>
|
|
<label for="bits">Number of Bits per Random Number:</label>
|
|
<input type="number" id="bits" name="bits"><br><br>
|
|
<input type="submit" value="Generate" id="generateButton">
|
|
<input type="submit" value="Shutdown" id="shutdownButton">
|
|
</form>
|
|
|
|
<div id="status"></div>
|
|
<div id="result"></div>
|
|
|
|
<script>
|
|
document.getElementById('initButton').addEventListener('click', function() {
|
|
fetch('https://172.16.78.57:5000/trng/randomNum/init')
|
|
.then(response => {
|
|
document.getElementById('status').innerText = 'Status: ' + response.status;
|
|
if (response.status === 200) {
|
|
console.log('Initialisierung erfolgreich');
|
|
} else {
|
|
console.log('Fehler beim Initialisieren');
|
|
}
|
|
})
|
|
.catch(error => {
|
|
console.error('Fehler beim Initialisieren:', error);
|
|
});
|
|
});
|
|
|
|
document.getElementById('generateButton').addEventListener('click', function(event) {
|
|
event.preventDefault(); // Verhindert das Absenden des Formulars
|
|
|
|
var quantity = document.getElementById('quantity').value;
|
|
var bits = document.getElementById('bits').value;
|
|
|
|
var url = 'https://172.16.78.57:5000/trng/randomNum/getRandom';
|
|
if (quantity && bits) {
|
|
url += '?quantity=' + quantity + '&numBits=' + bits;
|
|
}
|
|
|
|
fetch(url)
|
|
.then(response => {
|
|
document.getElementById('status').innerText = 'Status: ' + response.status;
|
|
return response.json();
|
|
})
|
|
.then(data => {
|
|
var resultDiv = document.getElementById('result');
|
|
var hexNumbers = JSON.parse(data.randomNumbers);
|
|
resultDiv.innerText = hexNumbers.join(', ');
|
|
})
|
|
.catch(error => {
|
|
console.error('Fehler beim Abrufen der Daten:', error);
|
|
});
|
|
});
|
|
|
|
document.getElementById('shutdownButton').addEventListener('click', function() {
|
|
fetch('https://172.16.78.57:5000/trng/randomNum/shutdown')
|
|
.then(response => {
|
|
document.getElementById('status').innerText = 'Status: ' + response.status;
|
|
if (response.status === 200) {
|
|
console.log('Shutdown erfolgreich');
|
|
} else {
|
|
console.log('Fehler beim Shutdown');
|
|
}
|
|
})
|
|
.catch(error => {
|
|
console.error('Fehler beim Shutdown:', error);
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html> |