Files
web_tool/templates/index.html
2025-10-11 17:15:21 +02:00

93 lines
2.5 KiB
HTML

<!DOCTYPE html>
<html lang ="en">
<head>
<style>
body {
background-color: #2B2A34;
}
.input_field {
display: flex;
justify-content: center;
}
.response_container {
display: flex;
justify-content: center;
align-items: center;
max-width: fit-content;
margin: 5px auto;
}
.response_text {
display: flex;
justify-content: center;
border: 2px solid black;
border-radius: 5px;
max-width: 300px;
margin: 5px auto;
background-color: white;
width: 200px;
height: 20px;
}
.response_button {
display: flex;
justify-content: center;
}
</style>
<script>
async function send_input() {
const input = document.getElementById('input').value;
const res = await fetch('/button', {
method: 'POST',
headers: {
'Content-type': 'application/json',
},
body: JSON.stringify({name: input})
});
const data = await res.text();
const box = document.getElementById('response_text');
box.textContent = data
document.getElementById('input').value = '';
}
</script>
<meta charset="UTF-8">
<meta name="viewpoint" content="width=device-width, initial-scale=1.0">
<title>javascript test</title>
</head>
<body>
<div class="input_field">
<input type="text" id="input"/>
<button onclick = "send_input()"> send </button>
<script>
const input = document.getElementById('input');
input.addEventListener('keydown', function(event) {
if (event.code == 'Enter'){
send_input();
}
})
</script>
</div>
<div id="response_container" class="response_container">
<div id="response_text" class="response_text"></div>
<div class="response_button">
<button onclick="copy_to_clipboard()">📋</button>
</div>
<script>
function copy_to_clipboard() {
const copyText = document.getElementById('response_text').textContent;
console.log(copyText);
navigator.clipboard.writeText(copyText);
}
</script>
</div>
</body>
</html>