add 404 page for incorrect download codes

This commit is contained in:
xenofem 2022-05-03 18:31:50 -04:00
parent 106c99d398
commit 9d87934cf4
8 changed files with 92 additions and 36 deletions

14
static/js/util.js Normal file
View file

@ -0,0 +1,14 @@
const UNITS = [
{ name: 'GB', size: Math.pow(10, 9) },
{ name: 'MB', size: Math.pow(10, 6) },
{ name: 'KB', size: Math.pow(10, 3) },
];
function displaySize(bytes) {
for (const unit of UNITS) {
if (bytes >= unit.size) {
return `${(bytes / unit.size).toFixed(1)}${unit.name}`;
}
}
return `${bytes}B`;
}