improved things

This commit is contained in:
metamuffin 2024-10-31 01:44:12 +01:00
parent 2eb6754ca4
commit a98f08d6c2
No known key found for this signature in database
GPG key ID: 718F9749DCDBD654

View file

@ -115,9 +115,9 @@ local function form_data()
end end
local function format_duration(t) local function format_duration(t)
if t > 86400 then return string.format("%d days", t / 86400) end if t > 86400 then return string.format("%d day%s", t / 86400, math.floor(t / 86400) ~= 1 and "s" or "") end
if t > 3600 then return string.format("%d hours", t / 3600) end if t > 3600 then return string.format("%d hour%s", t / 3600, math.floor(t / 3600) ~= 1 and "s" or "") end
if t > 60 then return string.format("%d minutes", t / 60) end if t > 60 then return string.format("%d minute%s", t / 60, math.floor(t / 60) ~= 1 and "s" or "") end
return string.format("%d seconds", t) return string.format("%d seconds", t)
end end
@ -253,7 +253,7 @@ local function r_user(username)
<input type="submit" value="Buy" /> <input type="submit" value="Buy" />
</form> </form>
]]) ]])
print("<div class=\"amount-presets\">") print([[<div class="amount-presets">]])
for _, type in ipairs({ 1, -1 }) do for _, type in ipairs({ 1, -1 }) do
for _, amount in ipairs({ 50, 100, 150, 200, 500, 1000 }) do for _, amount in ipairs({ 50, 100, 150, 200, 500, 1000 }) do
print(string.format([[ print(string.format([[
@ -281,7 +281,7 @@ local function r_log(filter)
<tr> <tr>
<td>%d (%s ago)</td> <td>%d (%s ago)</td>
<td>%s</td> <td>%s</td>
<td class=\"amount-%s\">%.02f€</td> <td class="amount-%s">%.02f</td>
<td>%s</td> <td>%s</td>
<td> <td>
<form action="/%s" method="POST"> <form action="/%s" method="POST">
@ -318,8 +318,13 @@ local function r_index()
]]) ]])
print("<ul>") print("<ul>")
for username, balance in pairs(balances()) do for username, balance in pairs(balances()) do
print(string.format("<li><a href=\"/%s\">%s</a>: %.02f€</li>", escape(username), escape(username), print(string.format([[
balance / 100)) <li><a href="/%s">%s</a>: <span class="amount-%s">%.02f</span></li>
]],
urlencode(username),
escape(username),
balance >= 0 and "pos" or "neg", balance / 100
))
end end
print("</ul>") print("</ul>")
end) end)