Use simpler number formatting method and add viewport meta tag

This commit is contained in:
nein.wtf 2022-02-17 15:46:55 +01:00
commit a07ff5673e
2 changed files with 10 additions and 10 deletions

View file

@ -6,6 +6,7 @@ Write([[
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Covid Deaths</title> <title>Covid Deaths</title>
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>⚫</text></svg>"> <link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>⚫</text></svg>">
<style> <style>
@ -36,17 +37,16 @@ for v in db:nrows(query) do
rows[#rows + 1] = v rows[#rows + 1] = v
end end
-- taken from http://lua-users.org/wiki/FormattingNumbers, thanks!
function format_int(number) function format_int(number)
-- taken from https://stackoverflow.com/questions/10989788/format-integer-in-lua#10992898. thanks! local formatted = number
local i, j, minus, int, fraction = tostring(number):find('([-]?)(%d+)([.]?%d*)') while true do
formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1&thinsp;%2')
-- reverse the int-string and append a six-per-em to all blocks of 3 digits if (k==0) then
thinsp = "&thinsp;" break
int = int:reverse():gsub("(%d%d%d)", "%1" .. thinsp:reverse()) end
end
-- reverse the int-string back remove an optional six-per-em and put the return formatted
-- optional minus and fractional part back
return minus .. int:reverse():gsub("^&thinsp;", "") .. fraction
end end
local deaths_yesterday = rows[1]["sum_deaths"] - rows[2]["sum_deaths"] local deaths_yesterday = rows[1]["sum_deaths"] - rows[2]["sum_deaths"]

Binary file not shown.