Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
3d0d4795
Commit
3d0d4795
authored
13 years ago
by
Robin Appelman
Browse files
Options
Downloads
Patches
Plain Diff
improved humanFileSize for js
parent
62cd89da
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/js/js.js
+11
-15
11 additions, 15 deletions
core/js/js.js
with
11 additions
and
15 deletions
core/js/js.js
+
11
−
15
View file @
3d0d4795
...
@@ -450,22 +450,18 @@ $.fn.filterAttr = function(attr_name, attr_value) {
...
@@ -450,22 +450,18 @@ $.fn.filterAttr = function(attr_name, attr_value) {
return
this
.
filter
(
function
()
{
return
$
(
this
).
attr
(
attr_name
)
===
attr_value
;
});
return
this
.
filter
(
function
()
{
return
$
(
this
).
attr
(
attr_name
)
===
attr_value
;
});
};
};
function
humanFileSize
(
bytes
){
function
humanFileSize
(
size
)
{
if
(
bytes
<
1024
){
humanList
=
[
'
B
'
,
'
kB
'
,
'
MB
'
,
'
GB
'
,
'
TB
'
];
return
bytes
+
'
B
'
;
// Calculate Log with base 1024: size = 1024 ** order
}
order
=
Math
.
floor
(
Math
.
log
(
size
)
/
Math
.
log
(
1024
));
bytes
=
Math
.
round
(
bytes
/
1024
,
1
);
// Stay in range of the byte sizes that are defined
if
(
bytes
<
1024
){
order
=
Math
.
min
(
humanList
.
length
,
order
);
return
bytes
+
'
kB
'
;
readableFormat
=
humanList
[
order
];
}
relativeSize
=
(
size
/
Math
.
pow
(
1024
,
order
)).
toFixed
(
1
);
bytes
=
Math
.
round
(
bytes
/
1024
,
1
);
if
(
relativeSize
.
substr
(
relativeSize
.
length
-
2
,
2
)
==
'
.0
'
){
if
(
bytes
<
1024
){
relativeSize
=
relativeSize
.
substr
(
0
,
relativeSize
.
length
-
2
);
return
bytes
+
'
MB
'
;
}
}
return
relativeSize
+
'
'
+
readableFormat
;
// Wow, heavy duty for owncloud
bytes
=
Math
.
round
(
bytes
/
1024
,
1
);
return
bytes
+
'
GB
'
;
}
}
function
simpleFileSize
(
bytes
)
{
function
simpleFileSize
(
bytes
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment