Apply Javascript styleguide
This commit is contained in:
parent
752ce964c8
commit
6e0f351093
30 changed files with 364 additions and 375 deletions
|
@ -9,20 +9,16 @@ export function formatDate(timestamp) {
|
|||
|
||||
export function formatSize(size) {
|
||||
if (size >= 1073741824) {
|
||||
size = Math.round((size / 1073741824) * 10) / 10 + 'GB';
|
||||
} else {
|
||||
if (size >= 1048576) {
|
||||
size = Math.round((size / 1048576) * 10) / 10 + 'MB';
|
||||
} else {
|
||||
if (size >= 1024) {
|
||||
size = Math.round((size / 1024) * 10) / 10 + 'KB';
|
||||
} else {
|
||||
size = Math.round(size) + 'B';
|
||||
}
|
||||
}
|
||||
return Math.round((size / 1073741824) * 10) / 10 + 'GB';
|
||||
}
|
||||
return size;
|
||||
};
|
||||
if (size >= 1048576) {
|
||||
return Math.round((size / 1048576) * 10) / 10 + 'MB';
|
||||
}
|
||||
if (size >= 1024) {
|
||||
return Math.round((size / 1024) * 10) / 10 + 'KB';
|
||||
}
|
||||
return Math.round(size) + 'B';
|
||||
}
|
||||
|
||||
export function formatFile(file) {
|
||||
const formattedFile = {
|
||||
|
@ -36,7 +32,7 @@ export function formatFile(file) {
|
|||
readableSize: formatSize(file.file_size),
|
||||
type: sniff(file.file_name),
|
||||
trashed: (file.status === 'trashed'),
|
||||
status: file.status
|
||||
status: file.status,
|
||||
};
|
||||
|
||||
if (file.width) {
|
||||
|
@ -45,7 +41,7 @@ export function formatFile(file) {
|
|||
const ext = (file.file_name.split('.').pop().toLowerCase() === 'psd' ? '.png' : '');
|
||||
formattedFile.direct = {
|
||||
'150x': fileHost + '/file/150/' + file._id + '/' + file.file_name + ext, // eslint-disable-line no-underscore-dangle
|
||||
'970x': fileHost + '/file/970/' + file._id + '/' + file.file_name + ext // eslint-disable-line no-underscore-dangle
|
||||
'970x': fileHost + '/file/970/' + file._id + '/' + file.file_name + ext, // eslint-disable-line no-underscore-dangle
|
||||
};
|
||||
}
|
||||
return formattedFile;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue