iso7010print/templates/index.html

68 lines
1.9 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<style>
body {
margin: 0 auto;
}
#things {
display: flex;
flex-flow: row wrap;
gap: 5px;
}
.thing {
width: 250px;
border: solid 2px;
}
</style>
</head>
<body>
<div>
<h1>ISO7010 Warning Stickers On Demand</h1>
<p>Brought to you by @samw@hacksrus.xyz. Label tape donations received with...</p>
<img src="/static/manythanks.png" height="100px">
</div>
{% for section, ws in ws.items() %}
<h2>{{ section }}</h2>
<div id="things">
{% for w in ws %}
<div class="thing" onclick="printme('{{w.name}}')">
<img src="{{ w.url }}" width="100%">
<div style="text-align: center; font-size: 20px;"> {{ w.name }} </div>
<button style="height: 30px; width: 100%">PRINT IT</button>
</div>
{% endfor %}
</div>
{% endfor %}
<script>
printing = false;
function printme(it) {
if (printing) {
return;
}
printing = true;
let formData = new FormData();
formData.append("w", it);
formData.append("count", 1);
for (e of document.getElementsByTagName("button")) {
e.disabled = true;
e.innerText = "printing....";
}
fetch("/", {
method: "POST",
body: new URLSearchParams(formData),
}).finally(() => {
for (e of document.getElementsByTagName("button")) {
e.disabled = false;
e.innerText = "PRINT IT";
}
printing = false;
})
}
</script>
</body>
</html>