You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
1.9 KiB

<html>
<head>
<title>TestWebserver</title>
<script src="jquery-3.1.0.min.js"></script>
</head>
<body>
<h1>Testpage</h1>
<p>
This is only a test for more detail see at <a href="https://steffen.gulpe.de/gitea/steffen/libUDPTCPNetwork">https://steffen.gulpe.de/gitea/steffen/libUDPTCPNetwork</a>
<p>
This is a smal test for sending and retrieving data.
<p>
<table>
<thead>
<th>name</th><th>value</th>
</thead>
<tr> <td>Sinus</td><td><input id="valsinus"></td> </tr>
<tr> <td>Cosinus</td><td><input id="valcosinus"></td> </tr>
<tr> <td>Time</td><td><input id="valtime"></td> </tr>
<tr> <td>Text</td><td><input id="valtext"></td> </tr>
</table>
<p>Return to <a href="index.html">INDEX.HTML</a>
</body>
<div id="debug"></div>
<script>
function refreshVariables() {
let debug = document.getElementById("debug");
let inputbox = document.getElementById("valtext");
let timebox = document.getElementById("valtime");
let sinusbox = document.getElementById("valsinus");
let cosinusbox = document.getElementById("valcosinus");
$.ajax({
type: "POST",
url: 'getdata',
data: JSON.stringify({"oldtext": inputbox.value, "sinus": sinusbox.value}),
success: function(response)
{
let variables = JSON.parse(response);
if (variables.text) inputbox.value = variables.text;
if (variables.time) {
let date = new Date(variables.time * 1000);
timebox.value = date.toLocaleDateString() + " " + date.toLocaleTimeString();
}
if (variables.sin) sinusbox.value = variables.sin;
if (variables.cos) cosinusbox.value = variables.cos;
},
error: function(error) {
debug.innerHTML = "ERROR";
}
});
}
function refresh() {
refreshVariables();
}
setInterval(refresh, 2000);
refreshVariables();
</script>
</html>