diff --git a/.gitignore b/.gitignore index 9acb106..1641179 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ -dist/ +dist*/ bin/ +.tmp/ .env *.exe *.log diff --git a/web/static/common.js b/web/static/common.js new file mode 100644 index 0000000..a4f9588 --- /dev/null +++ b/web/static/common.js @@ -0,0 +1,28 @@ +function relativeTime(unixSeconds) { + const seconds = Math.max(0, Math.floor(Date.now() / 1000) - unixSeconds); + if (seconds < 5) { + return "just now"; + } + if (seconds < 60) { + return `${seconds}s ago`; + } + const minutes = Math.floor(seconds / 60); + if (minutes < 60) { + return `${minutes}m ago`; + } + const hours = Math.floor(minutes / 60); + return `${hours}h ago`; +} + +function escapeHTML(value) { + return String(value) + .replaceAll("&", "&") + .replaceAll("<", "<") + .replaceAll(">", ">") + .replaceAll('"', """) + .replaceAll("'", "'"); +} + +function fact(label, value) { + return `