add 404 page for incorrect download codes
This commit is contained in:
parent
106c99d398
commit
9d87934cf4
8 changed files with 92 additions and 36 deletions
14
static/js/util.js
Normal file
14
static/js/util.js
Normal 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`;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue