escpos-go-labels/index.html
Geoffrey “Frogeye” Preud'homme 61fa92d2f4
De-hardcode IPs
This allows the machine to survive IP changes, and help development.
2024-04-10 19:42:12 +02:00

120 lines
3.3 KiB
HTML

<!-- FILEPATH: index.html -->
<!DOCTYPE html>
<html>
<head>
<title>Create DNH Label</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f2f2f2;
margin: 0;
padding: 20px;
}
h1 {
color: #333;
text-align: center;
}
form {
max-width: 400px;
margin: 0 auto;
background-color: #fff;
padding: 20px;
border-radius: 5px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
label {
display: block;
margin-bottom: 10px;
font-weight: bold;
}
input[type="text"] {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
input[type="submit"] {
background-color: #4CAF50;
color: white;
padding: 10px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
}
input[type="submit"]:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<h1>Create DNH Label</h1>
<form id="labelForm" action="/create_dnh_label" method="POST">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required>
<br><br>
<input type="submit" value="Create Label">
</form>
<h1>Create Generic Label</h1>
<form id="genericLabelForm" action="/create_generic_label" method="POST">
<label for="text">Text:</label>
<input type="text" id="text" name="text" required>
<br><br>
<input type="submit" value="Create Label">
</form>
<script>
document.getElementById("labelForm").addEventListener("submit", function(event) {
event.preventDefault();
var form = event.target;
var formData = new FormData(form);
fetch(form.action, {
method: form.method,
body: formData
})
.then(function(response) {
if (response.ok) {
alert("Label created successfully!");
} else {
console.log(response);
alert("Failed to create label. Please try again.");
}
})
.catch(function(error) {
console.log(error);
});
});
document.getElementById("genericLabelForm").addEventListener("submit", function(event) {
event.preventDefault();
var form = event.target;
var formData = new FormData(form);
fetch(form.action, {
method: form.method,
body: formData
})
.then(function(response) {
if (response.ok) {
alert("Generic label created successfully!");
} else {
console.log(response);
alert("Failed to create generic label. Please try again.");
}
})
.catch(function(error) {
console.log(error);
});
});
</script>
</body>
</html>