sok dolog

This commit is contained in:
2026-01-17 15:51:30 +01:00
parent a926a9d667
commit dcb08a5e84
6 changed files with 223 additions and 22 deletions

View File

@@ -15,6 +15,11 @@
</body>
<script>
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
var answid;
async function fetch_data()
{
@@ -37,6 +42,51 @@
console.error('Error:', error);
});
}
async function open_message(id)
{
answid = id;
var url = 'admin/api/all_messages/' + id;
fetch(url)
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.text();
})
.then(data => {
document.getElementById("messages").innerHTML = data + '<footer> <div class="textbox"><input class="text_input" name="valami" type="text" id="promptText" placeholder="answ"><button class="send_button" onclick="send_data()">send</button></div></footer>';
console.log(data.body)
})
.catch(error => {x0
console.error('Error:', error);
});
}
async function send_data()
{
let text = document.getElementById("promptText").value;
let url = "/admin/api/write/" + answid
fetch(url, {
method: "PUT",
body: text,
headers: {
"Content-type": "application/json; charset=UTF-8"
}
});
document.getElementById("promptText").value = "";
await sleep(10);
open_message(answid);
}
</script>
</html>