Use simpler number formatting method and add viewport meta tag
This commit is contained in:
parent
1a71a6296d
commit
a07ff5673e
2 changed files with 10 additions and 10 deletions
20
index.lua
20
index.lua
|
|
@ -6,6 +6,7 @@ Write([[
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<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>">
|
||||
<style>
|
||||
|
|
@ -36,17 +37,16 @@ for v in db:nrows(query) do
|
|||
rows[#rows + 1] = v
|
||||
end
|
||||
|
||||
-- taken from http://lua-users.org/wiki/FormattingNumbers, thanks!
|
||||
function format_int(number)
|
||||
-- taken from https://stackoverflow.com/questions/10989788/format-integer-in-lua#10992898. thanks!
|
||||
local i, j, minus, int, fraction = tostring(number):find('([-]?)(%d+)([.]?%d*)')
|
||||
|
||||
-- reverse the int-string and append a six-per-em to all blocks of 3 digits
|
||||
thinsp = " "
|
||||
int = int:reverse():gsub("(%d%d%d)", "%1" .. thinsp:reverse())
|
||||
|
||||
-- reverse the int-string back remove an optional six-per-em and put the
|
||||
-- optional minus and fractional part back
|
||||
return minus .. int:reverse():gsub("^ ", "") .. fraction
|
||||
local formatted = number
|
||||
while true do
|
||||
formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1 %2')
|
||||
if (k==0) then
|
||||
break
|
||||
end
|
||||
end
|
||||
return formatted
|
||||
end
|
||||
|
||||
local deaths_yesterday = rows[1]["sum_deaths"] - rows[2]["sum_deaths"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue