documents page fixed
This commit is contained in:
1 parent
eed3a3c007
commit
ed9dae3760
13 files changed
+156
-105
No files matched your search
@@ -1,27 +0,0 @@
|
||||
function ext(filname) {
|
||||
let getExt = name => /\.(\w+)$/.exec(name)[1]
|
||||
let defaultExt = ext => ext.toUpperCase()
|
||||
|
||||
const exts = ['png', 'pdf', 'jpg', 'jpeg', 'gif', 'doc']
|
||||
const extd = ['ПНГ', 'ПДФ', 'ЖПГ', 'ЖПГ', 'ГИФ', 'ДОК']
|
||||
|
||||
let ext = getExt(filname)
|
||||
const i = exts.indexOf(ext)
|
||||
|
||||
return i > -1
|
||||
? extd[i]
|
||||
: defaultExt(ext)
|
||||
}
|
||||
|
||||
function size(bytes, precision = 1) {
|
||||
if (isNaN(parseFloat(bytes)) || !isFinite(bytes)) return ''
|
||||
|
||||
const units = ['байт', 'КБ', 'МБ', 'ГБ', 'ТБ', 'ПБ']
|
||||
const number = Math.floor(Math.log(bytes) / Math.log(1024))
|
||||
|
||||
const size = (bytes / Math.pow(1024, Math.floor(number))).toFixed(precision)
|
||||
return `${size} ${units[number]}`
|
||||
}
|
||||
|
||||
exports.ext = ext
|
||||
exports.size = size
|
||||
@@ -0,0 +1,23 @@
|
||||
const getExt = (name: string) => /\.(\w+)$/.exec(name)[1]
|
||||
const defaultExt = (ext: string) => ext.toUpperCase()
|
||||
const exts = ['png', 'pdf', 'jpg', 'jpeg', 'gif', 'doc']
|
||||
const extd = ['ПНГ', 'ПДФ', 'ЖПГ', 'ЖПГ', 'ГИФ', 'ДОК']
|
||||
const units = ['байт', 'КБ', 'МБ', 'ГБ', 'ТБ', 'ПБ']
|
||||
|
||||
export function ext(filname: string): string {
|
||||
const ext = getExt(filname)
|
||||
const i = exts.indexOf(ext)
|
||||
|
||||
return i > -1
|
||||
? extd[i]
|
||||
: defaultExt(ext)
|
||||
}
|
||||
|
||||
export function size(bytes: any, precision = 1): string {
|
||||
if (isNaN(parseFloat(bytes)) || !isFinite(bytes)) return ''
|
||||
|
||||
const number = Math.floor(Math.log(bytes) / Math.log(1024))
|
||||
const size = (bytes / Math.pow(1024, Math.floor(number))).toFixed(precision)
|
||||
|
||||
return `${size} ${units[number]}`
|
||||
}
|
||||
Reference in new issue
Block a user