From a98f08d6c272a0d0aedd8e2408404e9584b4bb9b Mon Sep 17 00:00:00 2001 From: metamuffin Date: Thu, 31 Oct 2024 01:44:12 +0100 Subject: [PATCH] improved things --- strichliste.lua | 19 ++++++++++++------- 1 file 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) ]]) - print("
") + print([[
]]) 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) %d (%s ago) %s - %.02f€ + %.02f€ %s
@@ -318,8 +318,13 @@ local function r_index() ]]) print("
    ") for username, balance in pairs(balances()) do - print(string.format("
  • %s: %.02f€
  • ", escape(username), escape(username), - balance / 100)) + print(string.format([[ +
  • %s: %.02f€
  • + ]], + urlencode(username), + escape(username), + balance >= 0 and "pos" or "neg", balance / 100 + )) end print("
") end)