Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
02a40e55
Commit
02a40e55
authored
Apr 19, 2016
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(ui) add byteFormat to base javascript file
parent
f40a9f73
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
0 deletions
+14
-0
opnsense_ui.js
src/opnsense/www/js/opnsense_ui.js
+14
-0
No files found.
src/opnsense/www/js/opnsense_ui.js
View file @
02a40e55
...
@@ -29,6 +29,20 @@
...
@@ -29,6 +29,20 @@
* User interface shared components, requires opnsense.js for supporting functions.
* User interface shared components, requires opnsense.js for supporting functions.
*/
*/
/**
* format bytes
* @param bytes number of bytes to format
* @param decimals decimal places
* @return string
*/
function
byteFormat
(
bytes
,
decimals
=
0
)
{
var
kb
=
1024
;
var
ndx
=
Math
.
floor
(
Math
.
log
(
bytes
)
/
Math
.
log
(
kb
)
);
var
fileSizeTypes
=
[
"
Bytes
"
,
"
KB
"
,
"
MB
"
,
"
GB
"
,
"
TB
"
,
"
PB
"
,
"
EB
"
,
"
ZB
"
,
"
YB
"
];
return
(
bytes
/
Math
.
pow
(
kb
,
ndx
)).
toFixed
(
decimals
)
+
'
'
+
fileSizeTypes
[
ndx
];
}
/**
/**
* save form to server
* save form to server
* @param url endpoint url
* @param url endpoint url
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment