blob: c8ee73ee2f0729bd5b8b74b99f7ff679030a9ebc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
( function ( mw, uw ) {
var scaleMsgKeys = [ 'size-bytes', 'size-kilobytes', 'size-megabytes', 'size-gigabytes' ];
uw.units = {
/**
* Format a size in bytes for output, using an appropriate
* unit (bytes, K, MB, GB, or TB) according to the magnitude in question
*
* Units above K get 2 fixed decimal places.
*
* @param {number} size Number of bytes
* @return {string} formatted size
*/
bytes: function ( size ) {
var i = 0;
while ( size >= 1024 && i < scaleMsgKeys.length - 1 ) {
size /= 1024.0;
i++;
}
return mw.message( scaleMsgKeys[ i ], size.toFixed( i > 1 ? 2 : 0 ) ).text();
}
};
}( mediaWiki, mediaWiki.uploadWizard ) );
|