2024-09-25 19:48:36 +00:00
|
|
|
<!-- SPDX-License-Identifier: GPL-3.0-or-later -->
|
2024-09-14 13:29:37 +00:00
|
|
|
{% extends "base.html" %}
|
|
|
|
|
|
2024-12-04 21:26:50 +00:00
|
|
|
{% block head %}
|
|
|
|
|
<title>LabelPrinter Image upload</title>
|
2025-11-02 18:51:07 +00:00
|
|
|
<style>
|
|
|
|
|
.threshold {
|
|
|
|
|
display: inline;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.dithering:checked ~ .threshold {
|
|
|
|
|
display: none;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|
2024-12-04 21:26:50 +00:00
|
|
|
{% endblock %}
|
|
|
|
|
|
2024-09-14 13:29:37 +00:00
|
|
|
{% block content %}
|
2025-11-02 18:51:07 +00:00
|
|
|
<form method="POST" action="/image" id="image_form" enctype="multipart/form-data">
|
2025-11-02 14:50:49 +00:00
|
|
|
{% if label_width == 450 %}
|
|
|
|
|
<label for="dropdown">Image:</label>
|
|
|
|
|
<select name="dropdown" id="image_preset_dropdown" onchange="handle_dropdown(this.value)">
|
|
|
|
|
<option value="file">Upload file</option>
|
|
|
|
|
{% if label_width == 450 %}
|
|
|
|
|
<option value="Abandoned">Abandoned item</option>
|
|
|
|
|
{% endif %}
|
|
|
|
|
</select><br>
|
|
|
|
|
{%endif%}
|
|
|
|
|
|
|
|
|
|
<div id="file">
|
|
|
|
|
<input type="file" name="image"><br>
|
2025-11-02 18:51:07 +00:00
|
|
|
<br>
|
|
|
|
|
<details name="advanced_options">
|
|
|
|
|
<summary>Advanced options</summary>
|
|
|
|
|
Dithering: <input type="checkbox" name="dithering" value="dithering" class="dithering" checked><br>
|
|
|
|
|
<div class="threshold">
|
|
|
|
|
Black/white cutoff threshold: <input type="number" value="50" name="threshold" style="width: 26px; padding: 3px; margin: 0px"> %
|
|
|
|
|
</div>
|
|
|
|
|
</details>
|
2025-11-02 14:50:49 +00:00
|
|
|
</div>
|
2024-09-26 18:38:41 +00:00
|
|
|
<input type="submit" value="Generate preview"><br>
|
2024-11-27 22:55:50 +00:00
|
|
|
Recommended image height = {{label_width}}, other sizes will be scaled
|
2024-09-14 13:29:37 +00:00
|
|
|
</form>
|
2024-09-14 18:49:57 +00:00
|
|
|
|
2024-09-26 18:38:41 +00:00
|
|
|
{% if info %}
|
|
|
|
|
<p class="info" style="color: {{info_color}}">{{info}}</p>
|
|
|
|
|
{% endif %}
|
|
|
|
|
|
2024-09-14 13:29:37 +00:00
|
|
|
{% if filename %}
|
2025-11-02 14:50:49 +00:00
|
|
|
<img src="user_data/{{filename}}" alt="Uploaded image" style="height: {{label_width * 0.7 }}px; width: auto;">
|
2024-09-15 12:57:26 +00:00
|
|
|
|
|
|
|
|
<form method="POST" action="/image-print">
|
|
|
|
|
{% if cut %}
|
|
|
|
|
<input type="checkbox" name="cut" value="cut" checked>
|
|
|
|
|
{%else %}
|
|
|
|
|
<input type="checkbox" name="cut" value="cut">
|
|
|
|
|
{%endif%}
|
|
|
|
|
<label for="cut"> Cut paper after printing </label><br>
|
|
|
|
|
|
|
|
|
|
<input type="submit" value="Print" style="font-size: 2em; padding: 20px 40px;">
|
2024-09-14 13:29:37 +00:00
|
|
|
{% endif %}
|
2025-11-02 14:50:49 +00:00
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
function get_persistent(name, initial_value) {
|
|
|
|
|
if (localStorage.getItem(name) == null) {
|
|
|
|
|
localStorage.setItem(name, initial_value)
|
|
|
|
|
}
|
|
|
|
|
return localStorage.getItem(name)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function handle_dropdown(value) {
|
|
|
|
|
localStorage.setItem("image_preset_dropdown", value)
|
|
|
|
|
if (value == "file") {
|
|
|
|
|
document.getElementById("file").style.display = "inline";
|
|
|
|
|
} else {
|
|
|
|
|
document.getElementById("file").style.display = "none";
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-11-02 18:51:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
const persistent_elements = ["dropdown", "threshold", "dithering", "advanced_options"]
|
|
|
|
|
|
|
|
|
|
for (element_name of persistent_elements) {
|
|
|
|
|
if (localStorage.getItem("image_form " + element_name) == null) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
element = document.getElementsByName(element_name)[0]
|
|
|
|
|
|
|
|
|
|
if (element.type == 'checkbox') {
|
|
|
|
|
element.checked = localStorage.getItem("image_form " + element_name) === "true";
|
|
|
|
|
} else if (element.name == 'advanced_options') {
|
|
|
|
|
element.open = localStorage.getItem("image_form " + element_name) === "true";
|
|
|
|
|
} else {
|
|
|
|
|
element.value = localStorage.getItem("image_form " + element_name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (element.name == 'dropdown') {
|
|
|
|
|
handle_dropdown(element.value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const image_form = document.getElementById("image_form")
|
|
|
|
|
image_form.addEventListener('submit', function(e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
|
|
for (const element of image_form.elements) {
|
|
|
|
|
if (element.type == 'checkbox') {
|
|
|
|
|
localStorage.setItem("image_form " + element.name, element.checked);
|
|
|
|
|
} else {
|
|
|
|
|
localStorage.setItem("image_form " + element.name, element.value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
element = document.getElementsByName("advanced_options")[0]
|
|
|
|
|
localStorage.setItem("image_form " + element.name, element.open);
|
|
|
|
|
|
|
|
|
|
image_form.submit();
|
|
|
|
|
})
|
|
|
|
|
|
2025-11-02 14:50:49 +00:00
|
|
|
</script>
|
2024-09-14 13:29:37 +00:00
|
|
|
{% endblock %}
|
|
|
|
|
|