refactor and user creating input redirect

This commit is contained in:
metamuffin 2024-11-04 16:16:28 +01:00
parent e93520702a
commit 5f8b7352cd
No known key found for this signature in database
GPG key ID: 718F9749DCDBD654
3 changed files with 98 additions and 84 deletions

View file

@ -403,7 +403,7 @@ end
local function r_index()
return respond(200, "Abrechenbarkeit", function()
print([[
<form action="/" method="GET" class="creation">
<form action="/" method="GET" id="user_creation">
<h3>User Creation</h3>
<label for="username">Username: </label>
<input type="text" name="create_user" id="username" />
@ -517,7 +517,13 @@ local function r_products()
</form>
</div>
]])
print([[<table class="productlist"><tr><th>Name</th><th>Price</th><th>Barcode</th><th>Count</th><th>Owner</th></tr>]])
print([[<table class="productlist"><tr>
<th>Name</th>
<th>Price</th>
<th>Barcode</th>
<th>Count</th>
<th>Owner</th>
</tr>]])
local pbals = product_balances()
for barcode, price, name, owner in read_products() do
print(string.format([[

View file

@ -1,10 +1,21 @@
/// <reference lib="dom" />
document.addEventListener("keypress", ev => {
document.addEventListener("keydown", ev => {
if (!(document.activeElement instanceof HTMLInputElement)) {
if (ev.code.startsWith("Digit"))
document.forms.buy_product.pcode.value += ev.code.substring(5)
if (ev.code == "Enter")
document.forms.buy_product.submit()
if (ev.code.startsWith("Digit")) {
if (document.forms.buy_product.pcode)
return document.forms.buy_product.pcode.value += ev.code.substring(5)
} else if (ev.code == "Enter") {
if (document.forms.buy_product)
return document.forms.buy_product.submit()
if (document.forms.user_creation)
return document.forms.user_creation.submit()
} else if (ev.code.startsWith("Key") || ev.code == "Space") {
if (document.forms.user_creation)
return document.forms.user_creation.create_user.value += ev.key
} else if (ev.code == "Backspace") {
if (document.forms.user_creation)
return document.forms.user_creation.create_user.value = ""
}
}
})

View file

@ -8,8 +8,7 @@
}
.trans {
background: linear-gradient(
#60d0fa50 0%,
background: linear-gradient(#60d0fa50 0%,
#60d0fa50 19%,
#f5acba50 20%,
#f5acba50 39%,
@ -17,8 +16,7 @@
#FFFFFF50 59%,
#f5acba50 60%,
#f5acba50 79%,
#60d0fa50 80%
);
#60d0fa50 80%);
}
body {
@ -86,10 +84,6 @@ nav> :last-child {
border-radius: 4px;
}
.notif > * {
color: black;
}
.notif.error {
background-color: rgb(118, 13, 13);
}
@ -99,14 +93,14 @@ nav> :last-child {
}
/* landing page */
form.creation {
form#user_creation {
background-color: var(--b2);
padding: 1em;
margin-top: 2em;
border-radius: 4px;
}
form.creation>h3 {
form#user_creation>h3 {
margin: 5px;
margin-right: 2em;
}
@ -120,7 +114,7 @@ input[type="text"] {
min-width: 10em;
}
form.creation>* {
form#user_creation>* {
display: inline-block;
margin-right: 1.5em;
}
@ -303,7 +297,9 @@ input:not([type=submit]) {
}
@media print {
nav, .container {
nav,
.container {
display: none;
}
@ -327,7 +323,8 @@ input:not([type=submit]) {
display: block;
}
.userlist a, ul {
.userlist a,
ul {
display: block;
width: 100%;
}