aboutsummaryrefslogtreecommitdiff
path: root/strichliste.lua
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-10-31 01:44:12 +0100
committermetamuffin <metamuffin@disroot.org>2024-10-31 01:44:12 +0100
commita98f08d6c272a0d0aedd8e2408404e9584b4bb9b (patch)
tree55b37737214b4cb40ab8e24418eac18a2b1a835e /strichliste.lua
parent2eb6754ca4d130e6bf29944646e61345c6e2de7a (diff)
downloadabrechenbarkeit-a98f08d6c272a0d0aedd8e2408404e9584b4bb9b.tar
abrechenbarkeit-a98f08d6c272a0d0aedd8e2408404e9584b4bb9b.tar.bz2
abrechenbarkeit-a98f08d6c272a0d0aedd8e2408404e9584b4bb9b.tar.zst
improved things
Diffstat (limited to 'strichliste.lua')
-rwxr-xr-xstrichliste.lua19
1 files changed, 12 insertions, 7 deletions
diff --git a/strichliste.lua b/strichliste.lua
index 818cdab..be31ed0 100755
--- a/strichliste.lua
+++ b/strichliste.lua
@@ -115,9 +115,9 @@ local function form_data()
end
local function format_duration(t)
- if t > 86400 then return string.format("%d days", t / 86400) end
- if t > 3600 then return string.format("%d hours", t / 3600) end
- if t > 60 then return string.format("%d minutes", t / 60) 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 hour%s", t / 3600, math.floor(t / 3600) ~= 1 and "s" or "") 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)
end
@@ -253,7 +253,7 @@ local function r_user(username)
<input type="submit" value="Buy" />
</form>
]])
- print("<div class=\"amount-presets\">")
+ print([[<div class="amount-presets">]])
for _, type in ipairs({ 1, -1 }) do
for _, amount in ipairs({ 50, 100, 150, 200, 500, 1000 }) do
print(string.format([[
@@ -281,7 +281,7 @@ local function r_log(filter)
<tr>
<td>%d (%s ago)</td>
<td>%s</td>
- <td class=\"amount-%s\">%.02f€</td>
+ <td class="amount-%s">%.02f€</td>
<td>%s</td>
<td>
<form action="/%s" method="POST">
@@ -318,8 +318,13 @@ local function r_index()
]])
print("<ul>")
for username, balance in pairs(balances()) do
- print(string.format("<li><a href=\"/%s\">%s</a>: %.02f€</li>", escape(username), escape(username),
- balance / 100))
+ print(string.format([[
+ <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
print("</ul>")
end)